spec/pause/action_spec.rb in pause-0.0.5 vs spec/pause/action_spec.rb in pause-0.0.6

- old
+ new

@@ -25,11 +25,11 @@ describe "#increment!" do it "should increment" do time = Time.now Timecop.freeze time do - Pause.analyzer.should_receive(:increment).with(action, time.to_i, 1) + Pause.adapter.should_receive(:increment).with(action.key, time.to_i, 1) action.increment! end end end @@ -56,11 +56,10 @@ action.ok?.should be_true action.increment! 1, time action.ok?.should be_false - end it "should return false and silently fail if redis is not available" do Redis.any_instance.stub(:zrange) { raise Redis::CannotConnectError } time = period_marker(resolution, Time.now.to_i) @@ -97,11 +96,11 @@ rate_limit.timestamp.should == expected_rate_limit.timestamp end end end - describe "#tracked_identifiers" do + describe ".tracked_identifiers" do it "should return all the identifiers tracked (but not blocked) so far" do action.increment! other_action.increment! action.ok? @@ -110,11 +109,11 @@ MyNotification.tracked_identifiers.should include(action.identifier) MyNotification.tracked_identifiers.should include(other_action.identifier) end end - describe "#rate_limited_identifiers" do + describe ".rate_limited_identifiers" do it "should return all the identifiers blocked" do action.increment!(100, Time.now.to_i) other_action.increment!(100, Time.now.to_i) action.ok? @@ -123,11 +122,11 @@ MyNotification.rate_limited_identifiers.should include(action.identifier) MyNotification.rate_limited_identifiers.should include(other_action.identifier) end end - describe "#unblock_all" do + describe ".unblock_all" do it "should unblock all the identifiers for a scope" do 10.times { action.increment! } other_action.increment! action.ok? @@ -138,9 +137,21 @@ MyNotification.unblock_all MyNotification.rate_limited_identifiers.should be_empty MyNotification.tracked_identifiers.should == [other_action.identifier] + end + end + + describe "#unblock" do + it 'unblocks the specified id' do + 10.times { action.increment! } + + expect(action.ok?).to be_false + + action.unblock + + expect(action.ok?).to be_true end end end describe Pause::Action, ".check" do