Permalink
Browse files

Alias [] to feature for the dsl

  • Loading branch information...
1 parent 1df7ff3 commit 44943da410fac8d3064be81d4d99c14cfdad1c10 @jnunemaker committed Aug 2, 2012
Showing with 18 additions and 0 deletions.
  1. +2 −0 lib/flipper/dsl.rb
  2. +16 −0 spec/flipper/dsl_spec.rb
View
@@ -24,6 +24,8 @@ def feature(name)
features[name.to_sym] ||= Flipper::Feature.new(name, @adapter)
end
+ alias :[] :feature
+
def group(name)
Flipper.group(name)
end
View
@@ -72,6 +72,22 @@ def feature(name)
end
end
+ describe "#[]" do
+ before do
+ @result = subject[:stats]
+ end
+
+ it "returns instance of feature with correct name and adapter" do
+ @result.should be_instance_of(Flipper::Feature)
+ @result.name.should eq(:stats)
+ @result.adapter.should eq(adapter)
+ end
+
+ it "memoizes the feature" do
+ subject[:stats].should equal(@result)
+ end
+ end
+
describe "#group" do
context "for registered group" do
before do

0 comments on commit 44943da

Please sign in to comment.