spec/transactions_spec.rb in mock_redis-0.19.0 vs spec/transactions_spec.rb in mock_redis-0.20.0

- old
+ new

@@ -8,15 +8,15 @@ context '#multi' do it "responds with 'OK'" do @redises.multi.should == 'OK' end - it 'forbids nesting' do + it 'does not permit nesting' do @redises.multi lambda do @redises.multi - end.should raise_error(Redis::CommandError) + end.should raise_error(Redis::CommandError, 'ERR MULTI calls can not be nested') end it 'cleans state of transaction wrapper if exception occurs during transaction' do lambda do @redises.mock.multi do |_r| @@ -39,22 +39,22 @@ @redises.set('counter', 5) @redises.multi do |r| r.set('test', 1) r.incr('counter') end - @redises.get('counter').should == '6' - @redises.get('test').should == '1' + @redises.get('counter').should eq '6' + @redises.get('test').should eq '1' end - it 'forbids nesting via blocks' do + it 'permits nesting via blocks' do # Have to use only the mock here. redis-rb has a bug in it where # nested #multi calls raise NoMethodError because it gets a nil # where it's not expecting one. @redises.mock.multi do |r| lambda do r.multi {} - end.should raise_error(Redis::CommandError) + end.should_not raise_error end end it 'allows pipelined calls within multi blocks' do @redises.set('counter', 5) @@ -62,31 +62,19 @@ r.pipelined do |pr| pr.set('test', 1) pr.incr('counter') end end - @redises.get('counter').should == '6' - @redises.get('test').should == '1' + @redises.get('counter').should eq '6' + @redises.get('test').should eq '1' end - - it 'allows multi blocks within pipelined blocks' do - @redises.set('counter', 5) - @redises.pipelined do |pr| - pr.multi do |r| - r.set('test', 1) - r.incr('counter') - end - end - @redises.get('counter').should == '6' - @redises.get('test').should == '1' - end end context '#discard' do it "responds with 'OK' after #multi" do @redises.multi - @redises.discard.should == 'OK' + @redises.discard.should eq 'OK' end it "can't be run outside of #multi/#exec" do lambda do @redises.discard @@ -108,31 +96,31 @@ @string = 'mock-redis-test:string' @list = 'mock-redis-test:list' end it "makes commands respond with 'QUEUED'" do - @redises.set(@string, 'string').should == 'QUEUED' - @redises.lpush(@list, 'list').should == 'QUEUED' + @redises.set(@string, 'string').should eq 'QUEUED' + @redises.lpush(@list, 'list').should eq 'QUEUED' end it "gives you the commands' responses when you call #exec" do @redises.set(@string, 'string') @redises.lpush(@list, 'list') @redises.lpush(@list, 'list') - @redises.exec.should == ['OK', 1, 2] + @redises.exec.should eq ['OK', 1, 2] end it "does not raise exceptions, but rather puts them in #exec's response" do @redises.set(@string, 'string') @redises.lpush(@string, 'oops!') @redises.lpush(@list, 'list') responses = @redises.exec - responses[0].should == 'OK' + responses[0].should eq 'OK' responses[1].should be_a(Redis::CommandError) - responses[2].should == 1 + responses[2].should eq 1 end end context 'saving commands with multi block' do before(:each) do @@ -149,11 +137,11 @@ set_response = mult.set(@string, 'string') lpush_response = mult.lpush(@list, 'list') second_lpush_response = mult.lpush(@list, 'list') end - set_response.value.should == 'OK' - lpush_response.value.should == 1 - second_lpush_response.value.should == 2 + set_response.value.should eq 'OK' + lpush_response.value.should eq 1 + second_lpush_response.value.should eq 2 end end end