spec/commands/expire_spec.rb in mock_redis-0.13.2 vs spec/commands/expire_spec.rb in mock_redis-0.14.0

- old
+ new

@@ -5,15 +5,15 @@ @key = 'mock-redis-test:expire' @redises.set(@key, 'spork') end it "returns true for a key that exists" do - @redises.expire(@key, 1).should be_true + @redises.expire(@key, 1).should == true end it "returns false for a key that does not exist" do - @redises.expire('mock-redis-test:nonesuch', 1).should be_false + @redises.expire('mock-redis-test:nonesuch', 1).should == false end it "removes a key immediately when seconds==0" do @redises.expire(@key, 0) @redises.get(@key).should be_nil @@ -89,7 +89,23 @@ @mock.lindex(@key, 0).should_not be_nil end end + context 'with two key expirations' do + let(:other_key) { 'mock-redis-test:expire-other' } + + before { @redises.set(other_key, 'spork-other') } + + it 'removes keys after enough time has passed' do + @mock.expire(@key, 5) + @mock.expire(other_key, 10) + + Time.stub(:now).and_return(@now + 5) + @mock.get(@key).should be_nil + + Time.stub(:now).and_return(@now + 10) + @mock.get(other_key).should be_nil + end + end end end