Skip to content

Commit

Permalink
added a test for active_features
Browse files Browse the repository at this point in the history
  • Loading branch information
theflow committed Feb 28, 2011
1 parent 9f0ff99 commit 7e87f70
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/feature_flipper/config.rb
Expand Up @@ -38,6 +38,10 @@ def self.states=(states)
@states = states
end

def self.active_features
features.keys.select { |feature| is_active?(feature) }
end

def self.get_state(feature_name)
feature = features[feature_name]
feature ? feature[:state] : nil
Expand Down Expand Up @@ -69,10 +73,6 @@ def self.is_active?(feature_name)
state == true
end
end

def self.active_features
self.features.collect { |key, value| self.is_active?(key) ? key : nil }.compact
end
end

class Mapper
Expand Down
12 changes: 12 additions & 0 deletions test/feature_flipper_test.rb
Expand Up @@ -70,6 +70,18 @@
assert_equal :dev, all_features[:dev_feature][:state]
assert_equal 'dev feature', all_features[:dev_feature][:description]
end

test 'should be able to get active features' do
Rails.stubs(:env).returns('production')
FeatureFlipper::Config.ensure_config_is_loaded
active_features = FeatureFlipper::Config.active_features

assert_equal 3, active_features.size
assert active_features.include?(:live_feature)
assert active_features.include?(:boolean_feature)
assert active_features.include?(:proc_feature)
end

end

context 'dynamic feature groups' do
Expand Down

0 comments on commit 7e87f70

Please sign in to comment.