spec/rollout_spec.rb in rollout-1.2.0 vs spec/rollout_spec.rb in rollout-2.0.0a
- old
+ new
@@ -58,12 +58,12 @@
@rollout.define_group(:fivesonly) { |user| user.id == 5 }
@rollout.activate_group(:chat, :all)
@rollout.activate_group(:chat, :fivesonly)
@rollout.activate_user(:chat, stub(:id => 51))
@rollout.activate_percentage(:chat, 100)
- @rollout.activate_globally(:chat)
- @rollout.deactivate_all(:chat)
+ @rollout.activate(:chat)
+ @rollout.deactivate(:chat)
end
it "removes all of the groups" do
@rollout.should_not be_active(:chat, stub(:id => 0))
end
@@ -111,11 +111,11 @@
end
end
describe "activating a feature globally" do
before do
- @rollout.activate_globally(:chat)
+ @rollout.activate(:chat)
end
it "activates the feature" do
@rollout.should be_active(:chat)
end
@@ -163,60 +163,72 @@
end
end
describe "deactivating the feature globally" do
before do
- @rollout.activate_globally(:chat)
- @rollout.deactivate_globally(:chat)
+ @rollout.activate(:chat)
+ @rollout.deactivate(:chat)
end
it "becomes inactivate" do
@rollout.should_not be_active(:chat)
end
end
- describe "#info" do
- context "global features" do
- let(:features) { [:signup, :chat, :table] }
+ it "keeps a list of features" do
+ @rollout.activate(:chat)
+ @rollout.features.should be_include(:chat)
+ end
- before do
- features.each do |f|
- @rollout.activate_globally(f)
- end
- end
-
- it "returns all global features" do
- @rollout.info.should eq({ :global => features.reverse })
- end
+ describe "#get" do
+ before do
+ @rollout.activate_percentage(:chat, 10)
+ @rollout.activate_group(:chat, :caretakers)
+ @rollout.activate_group(:chat, :greeters)
+ @rollout.activate(:signup)
+ @rollout.activate_user(:chat, stub(:id => 42))
end
- describe "with a percentage set" do
- before do
- @rollout.activate_percentage(:chat, 10)
- @rollout.activate_group(:chat, :caretakers)
- @rollout.activate_group(:chat, :greeters)
- @rollout.activate_globally(:signup)
- @rollout.activate_user(:chat, stub(:id => 42))
- end
+ it "returns the feature object" do
+ feature = @rollout.get(:chat)
+ feature.groups.should == [:caretakers, :greeters]
+ feature.percentage.should == 10
+ feature.users.should == [42]
+ feature.to_hash.should == {
+ :groups => [:caretakers, :greeters],
+ :percentage => 10,
+ :users => [42]
+ }
- it "returns info about all the activations" do
- @rollout.info(:chat).should == {
- :percentage => 10,
- :groups => [:greeters, :caretakers],
- :users => [42],
- :global => [:signup]
- }
- end
+ feature = @rollout.get(:signup)
+ feature.groups.should be_empty
+ feature.users.should be_empty
+ feature.percentage.should == 100
end
+ end
- describe "without a percentage set" do
- it "the percentage defaults to 0" do
- @rollout.info(:chat).should == {
- :percentage => 0,
- :groups => [],
- :users => [],
- :global => []
- }
- end
+ describe "migration mode" do
+ before do
+ @legacy = Rollout::Legacy.new(@redis)
+ @legacy.activate_percentage(:chat, 12)
+ @legacy.activate_user(:chat, stub(:id => 42))
+ @legacy.activate_user(:chat, stub(:id => 24))
+ @legacy.activate_group(:chat, :dope_people)
+ @rollout = Rollout.new(@redis, :migrate => true)
+ end
+
+ it "imports the settings from the legacy rollout once" do
+ @rollout.get(:chat).to_hash.should == {
+ :percentage => 12,
+ :users => [24, 42],
+ :groups => [:dope_people]
+ }
+ @legacy.deactivate_all(:chat)
+ @rollout.get(:chat).to_hash.should == {
+ :percentage => 12,
+ :users => [24, 42],
+ :groups => [:dope_people]
+ }
+ @redis.get("feature:chat").should_not be_nil
end
end
end