Skip to content

Commit

Permalink
Proof of concept commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Winston Teo authored and Winston Teo committed Mar 15, 2012
0 parents commit b2a7083
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.gem
.bundle
pkg/*
.idea
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in cactus.gemspec
gemspec
14 changes: 14 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
PATH
remote: .
specs:
cactus (0.0.1)

GEM
remote: http://rubygems.org/
specs:

PLATFORMS
ruby

DEPENDENCIES
cactus!
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require "bundler/gem_tasks"
21 changes: 21 additions & 0 deletions cactus.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)

require "cactus/version"

Gem::Specification.new do |s|
s.name = "cactus"
s.version = Cactus::VERSION
s.authors = ["Winston Teo Yong Wei"]
s.email = ["[email protected]"]
s.homepage = ""
s.summary = %q{CSS BDD framework}
s.description = %q{Test your CSS}

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

# s.add_development_dependency "rspec"
end
5 changes: 5 additions & 0 deletions lib/cactus.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require "cactus/version"

# Rails Helper
lib_path = File.dirname(__FILE__)
require "#{lib_path}/cactus/rails/engine.rb" if defined?(Rails)
13 changes: 13 additions & 0 deletions lib/cactus/rails/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require "#{File.dirname(__FILE__)}/helpers/view_helper"

module Cactus
module Rails
class Engine < ::Rails::Engine
initializer "cactus" do
ActiveSupport.on_load(:action_controller) do
include Cactus::Rails::ViewHelper
end
end
end
end
end
17 changes: 17 additions & 0 deletions lib/cactus/rails/helpers/view_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Cactus
module Rails
module ViewHelper
extend ActiveSupport::Concern

included do
helper_method "cactus"
end

def cactus
html = "<script src='/assets/cactus.js' type='text/javascript'></script>"
html += "<script src='/cactus_specs/spec.js' type='text/javascript'></script>"
html.html_safe
end
end
end
end
3 changes: 3 additions & 0 deletions lib/cactus/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Cactus
VERSION = "0.0.2"
end
15 changes: 15 additions & 0 deletions vendor/assets/javascripts/cactus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var cactus = {};

cactus.ensure = function(dom, att) {
var dom = dom;
var att = att;
var css = $(dom).css(att);

return {
toEqual: function(expected) {
if(css !== expected) {
console.log("Expected " + dom + ":" + att + " to equal " + expected + " but got " + css + " instead." );
}
}
}
};

0 comments on commit b2a7083

Please sign in to comment.