spec/flipper/dsl_spec.rb in flipper-0.2.1 vs spec/flipper/dsl_spec.rb in flipper-0.3.0
- old
+ new
@@ -115,37 +115,19 @@
end
end
end
describe "#actor" do
- context "for something that responds to id" do
- it "returns actor instance with identifier set to id" do
- user = Struct.new(:id).new(23)
- actor = subject.actor(user)
- actor.should be_instance_of(Flipper::Types::Actor)
- actor.identifier.should eq(23)
- end
- end
-
context "for something that responds to identifier" do
it "returns actor instance with identifier set to id" do
user = Struct.new(:identifier).new(45)
actor = subject.actor(user)
actor.should be_instance_of(Flipper::Types::Actor)
actor.identifier.should eq(45)
end
end
- context "for something that responds to identifier and id" do
- it "returns actor instance with identifier set to identifier" do
- user = Struct.new(:id, :identifier).new(1, 50)
- actor = subject.actor(user)
- actor.should be_instance_of(Flipper::Types::Actor)
- actor.identifier.should eq(50)
- end
- end
-
context "for a number" do
it "returns actor instance with identifer set to number" do
actor = subject.actor(33)
actor.should be_instance_of(Flipper::Types::Actor)
actor.identifier.should eq(33)
@@ -171,10 +153,14 @@
end
it "sets value" do
@result.value.should eq(5)
end
+
+ it "is aliased to percentage_of_random" do
+ @result.should eq(subject.percentage_of_random(@result.value))
+ end
end
describe "#actors" do
before do
@result = subject.actors(17)
@@ -184,8 +170,36 @@
@result.should be_instance_of(Flipper::Types::PercentageOfActors)
end
it "sets value" do
@result.value.should eq(17)
+ end
+
+ it "is aliased to percentage_of_actors" do
+ @result.should eq(subject.percentage_of_actors(@result.value))
+ end
+ end
+
+ describe "#features" do
+ context "with no features enabled/disabled" do
+ it "defaults to empty set" do
+ subject.features.should eq(Set.new)
+ end
+ end
+
+ context "with features enabled and disabled" do
+ before do
+ subject[:stats].enable
+ subject[:cache].enable
+ subject[:search].disable
+ end
+
+ it "returns set of feature instances" do
+ subject.features.should be_instance_of(Set)
+ subject.features.each do |feature|
+ feature.should be_instance_of(Flipper::Feature)
+ end
+ subject.features.map(&:name).map(&:to_s).sort.should eq(['cache', 'search', 'stats'])
+ end
end
end
end