Skip to content

Commit

Permalink
Added random shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Aug 2, 2012
1 parent 9db60de commit b0e371e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/flipper/dsl.rb
Expand Up @@ -42,6 +42,10 @@ def actor(actor_or_number)
Flipper::Types::Actor.new(identifier)
end

def random(number)
Flipper::Types::PercentageOfRandom.new(number)
end

private

def features
Expand Down
14 changes: 14 additions & 0 deletions spec/flipper/dsl_spec.rb
Expand Up @@ -138,4 +138,18 @@ def feature(name)
end
end
end

describe "#random" do
before do
@result = subject.random(5)
end

it "returns percentage of random" do
@result.should be_instance_of(Flipper::Types::PercentageOfRandom)
end

it "sets value" do
@result.value.should eq(5)
end
end
end

0 comments on commit b0e371e

Please sign in to comment.