Skip to content
Browse files

Add tests and a little more gem config

  • Loading branch information...
1 parent d930934 commit 1c48fb7b10b33737a29031f77233a6bd8b5dc72f Dave Miller committed Mar 28, 2012
Showing with 121 additions and 30 deletions.
  1. +1 −1 Gemfile
  2. +73 −12 Gemfile.lock
  3. +2 −2 Rakefile
  4. +39 −6 spec/chihuahua_spec.rb
  5. +1 −9 spec/spec_helper.rb
  6. +5 −0 vendor/assets/javascripts/chihuahua.js.erb
View
2 Gemfile
@@ -11,5 +11,5 @@ group :development, :test do
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.8.3"
gem "rcov", ">= 0"
- gem "activesupport", "~> 3.0.5"
+ gem 'rails', '~> 3.1'
end
View
85 Gemfile.lock
@@ -1,20 +1,77 @@
GEM
remote: http://rubygems.org/
specs:
- activesupport (3.0.5)
- columnize (0.3.6)
+ actionmailer (3.2.2)
+ actionpack (= 3.2.2)
+ mail (~> 2.4.0)
+ actionpack (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ journey (~> 1.0.1)
+ rack (~> 1.4.0)
+ rack-cache (~> 1.1)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.1.2)
+ activemodel (3.2.2)
+ activesupport (= 3.2.2)
+ builder (~> 3.0.0)
+ activerecord (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
+ arel (~> 3.0.2)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
+ activesupport (3.2.2)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ arel (3.0.2)
+ builder (3.0.0)
diff-lcs (1.1.3)
+ erubis (2.7.0)
git (1.2.5)
+ hike (1.2.1)
+ i18n (0.6.0)
jeweler (1.8.3)
bundler (~> 1.0)
git (>= 1.2.5)
rake
rdoc
+ journey (1.0.3)
json (1.6.6)
- linecache (0.46)
- rbx-require-relative (> 0.0.4)
+ mail (2.4.4)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.18)
+ multi_json (1.2.0)
+ polyglot (0.3.3)
+ rack (1.4.1)
+ rack-cache (1.2)
+ rack (>= 0.4)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.2.2)
+ actionmailer (= 3.2.2)
+ actionpack (= 3.2.2)
+ activerecord (= 3.2.2)
+ activeresource (= 3.2.2)
+ activesupport (= 3.2.2)
+ bundler (~> 1.0)
+ railties (= 3.2.2)
+ railties (3.2.2)
+ actionpack (= 3.2.2)
+ activesupport (= 3.2.2)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
rake (0.9.2.2)
- rbx-require-relative (0.0.9)
rcov (1.0.0)
rdoc (3.12)
json (~> 1.4)
@@ -26,20 +83,24 @@ GEM
rspec-expectations (2.8.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.8.0)
- ruby-debug (0.10.4)
- columnize (>= 0.1)
- ruby-debug-base (~> 0.10.4.0)
- ruby-debug-base (0.10.4)
- linecache (>= 0.3)
+ sprockets (2.1.2)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.32)
PLATFORMS
ruby
DEPENDENCIES
- activesupport (~> 3.0.5)
bundler (~> 1.0.0)
jeweler (~> 1.8.3)
+ rails (~> 3.1)
rcov
rdoc (~> 3.12)
rspec (~> 2.8.0)
- ruby-debug
View
4 Rakefile
@@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
gem.name = "chihuahua"
gem.homepage = "http://github.com/mildavw/chihuahua"
gem.license = "MIT"
- gem.summary = %Q{TODO: one-line summary of your gem}
- gem.description = %Q{TODO: longer description of your gem}
+ gem.summary = %Q{Rails feature flagging}
+ gem.description = %Q{Basic feature flagging/flipping for Rails 3.1 or later. Features are enabled by environment on deploy}
gem.email = "dave.miller@renewfund.com"
gem.authors = ["Dave Miller"]
# dependencies defined in Gemfile
View
45 spec/chihuahua_spec.rb
@@ -1,13 +1,46 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Chihuahua" do
-
- before :all do
- debugger
+
+ before :each do
Chihuahua.stub(:load_enabled_features_from_yaml_file => [:awesome_feature])
end
-
- it "tests something" do
- p Chihuahua.enabled_features
+
+ context '#enabled?' do
+ it "returns true when enabled" do
+ Chihuahua.enabled?(:awesome_feature)
+ end
+ it "returns false when disabled" do
+ Chihuahua.enabled?(:horrible_feature)
+ end
+ end
+
+ it "#enable sets enabled properly" do
+ Chihuahua.enable(:cool_feature)
+ Chihuahua.enabled?(:cool_feature).should be_true
+ end
+
+ it "#disable sets enabled properly" do
+ Chihuahua.disable(:lame_feature)
+ Chihuahua.enabled?(:lame_feature).should be_false
end
+
+ context "#set" do
+ it "sets enabled properly" do
+ Chihuahua.set(:lame_feature, false)
+ Chihuahua.enabled?(:lame_feature).should be_false
+ end
+ it "sets disabled properly" do
+ Chihuahua.set(:cool_feature, true)
+ Chihuahua.enabled?(:cool_feature).should be_true
+ end
+ end
+
+ it '#reset! resets' do
+ Chihuahua.set(:awesome_feature, false)
+ Chihuahua.enabled?(:awesome_feature).should be_false
+ Chihuahua.reset!
+ Chihuahua.enabled?(:awesome_feature).should be_true
+ end
+
end
View
10 spec/spec_helper.rb
@@ -5,12 +5,4 @@
require 'bundler'
require 'rspec'
require 'active_support'
-require 'chihuahua'
-
-# Requires supporting files with custom matchers and macros, etc,
-# in ./support/ and its subdirectories.
-Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
-
-RSpec.configure do |config|
- config.mock_with :rspec
-end
+require 'chihuahua'
View
5 vendor/assets/javascripts/chihuahua.js.erb
@@ -0,0 +1,5 @@
+# TODO: Make sure this gets loaded afresh (no pipeline compiling )
+var showFeature = function(feature) {
+ var config = <%= Chihuahua.enabled_features.to_json %>;
+ return (config.indexOf(feature) >= 0);
+}

0 comments on commit 1c48fb7

Please sign in to comment.
Something went wrong with that request. Please try again.