spec/persistence_spec.rb in modis-4.0.0 vs spec/persistence_spec.rb in modis-4.0.1

- old
+ new

@@ -109,12 +109,17 @@ expect(model.persisted?).to be true end it 'does not track the ID if the underlying Redis command failed' do redis = double(hmset: double(value: nil), sadd: nil) - expect(model.class).to receive(:transaction).and_yield(redis) - expect(redis).to receive(:pipelined).and_yield + if Gem::Version.new(Redis::VERSION) > Gem::Version.new('4.6.0') + expect(model.class).to receive(:transaction).and_yield(Redis::PipelinedConnection.new(Redis::Pipeline::Multi.new(redis))) + expect(redis).to receive(:pipelined).and_yield(Redis::PipelinedConnection.new(Redis::Pipeline.new(redis))) + else + expect(model.class).to receive(:transaction).and_yield(redis) + expect(redis).to receive(:pipelined).and_yield(redis) + end model.save expect { model.class.find(model.id) }.to raise_error(Modis::RecordNotFound) end it 'does not perform validation if validate: false' do @@ -133,11 +138,16 @@ model.age = 10 model.save! model.age = 11 redis = double expect(redis).to receive(:hmset).with("modis:persistence_spec:mock_model:1", ["age", "\v"]).and_return(double(value: 'OK')) - expect(model.class).to receive(:transaction).and_yield(redis) - expect(redis).to receive(:pipelined).and_yield + if Gem::Version.new(Redis::VERSION) > Gem::Version.new('4.6.0') + expect(model.class).to receive(:transaction).and_yield(Redis::PipelinedConnection.new(Redis::Pipeline::Multi.new(redis))) + expect(redis).to receive(:pipelined).and_yield(Redis::PipelinedConnection.new(Redis::Pipeline.new(redis))) + else + expect(model.class).to receive(:transaction).and_yield(redis) + expect(redis).to receive(:pipelined).and_yield(redis) + end model.save! expect(model.age).to eq(11) end end