Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow feature listing. Because it will be useful for flipper-ui list and... #10

Closed
wants to merge 1 commit into from

2 participants

@jonduarte

... manipulate features.

@jnunemaker
Owner

Interesting. The main reason I had not done this or even thought about this was that I am assuming that people might want to run the UI outside of the application, where they would might have access to the same data store, but not necessarily the code.

I actually just ensured that features get added to a set in the adapter whenever they are enabled or disabled in 6b63363.

After seeing this, I'm thinking that we should make DSL#features return adapter.set_members('features') and change the existing features method to something like memoized_features, as that is more what it is doing.

What are your thoughts on this?

@jonduarte

Maybe DSL#features using adpater.set_members('features') will not work.
Because I ran the flipper-ui tests and its fails here:

1) Flipper::UI::Middleware GET /flipper renders view
     Failure/Error: last_response.body.should match(/stats/i)
     ... ./spec/flipper-ui/middleware_spec.rb:41 ... 

Looking at the code I saw that this line: https://github.com/jnunemaker/flipper-ui/blob/master/lib/flipper/ui/middleware.rb#L79 is returning an empty set.

So, when I changed

@features = flipper.adapter.set_members('features').map { |name| Feature.new(name) }

to

@features = flipper.send(:features).map { |name| Feature.new(name) }

it worked.

I don't know if I'm missing something... and I couldn't understand why Adapter#set_members('features') is returning empty.

When I run examples/basic.rb in the first situation, flipper view show only the logo
So, when I changed the middleware, it list all the features added.

@jnunemaker
Owner

I believe it is because I haven't released latest flipper. If you lock flipper to master instead of a gem version it should work.

@jnunemaker
Owner

Sorry for the confusion. I think I have it locked locally to my WIP by using :path in the gemfile.

@jonduarte

Nice, You're right. I changed to github and it worked.
Thanks, I'll close this.

@jonduarte jonduarte closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 13, 2012
  1. @jonduarte
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 2 deletions.
  1. +0 −2  lib/flipper/dsl.rb
  2. +10 −0 spec/flipper/dsl_spec.rb
View
2  lib/flipper/dsl.rb
@@ -46,8 +46,6 @@ def actors(number)
Flipper::Types::PercentageOfActors.new(number)
end
- private
-
def features
@features ||= {}
end
View
10 spec/flipper/dsl_spec.rb
@@ -170,4 +170,14 @@ def feature(name)
@result.value.should eq(17)
end
end
+
+ describe "#features" do
+ it "returns a list of features" do
+ subject[:search].enable
+ subject[:log].disable
+ subject[:metrics].enable subject.random(5)
+
+ subject.features.should have(3).features
+ end
+ end
end
Something went wrong with that request. Please try again.