spec/redis-copy/strategy_spec.rb in redis-copy-0.0.2 vs spec/redis-copy/strategy_spec.rb in redis-copy-0.0.3

- old
+ new

@@ -30,15 +30,10 @@ return [:raised, exception] end end shared_examples_for(RedisCopy::Strategy) do - let(:ui) { double.as_null_object } - let(:strategy) { strategy_class.new(source, destination, ui)} - let(:source) { Redis.new(db: 14) } - let(:destination) { Redis.new(db: 15) } - let(:multiplex) { RedisMultiplex.new(source, destination) } let(:key) { rand(16**128).to_s(16) } after(:each) { multiplex.both { |redis| redis.del(key) } } context '#copy' do context 'string' do @@ -330,14 +325,38 @@ end end end describe RedisCopy::Strategy do + let(:options) { Hash.new } # append using before(:each) { options.update(foo: true) } + let(:ui) { double.as_null_object } + let(:strategy) { strategy_class.new(source, destination, ui, options)} + let(:multiplex) { RedisMultiplex.new(source, destination) } + let(:source) { Redis.new(db: 14) } + let(:destination) { Redis.new(db: 15) } + describe :New do let(:strategy_class) { RedisCopy::Strategy::New } it_should_behave_like RedisCopy::Strategy end describe :Classic do let(:strategy_class) { RedisCopy::Strategy::Classic } it_should_behave_like RedisCopy::Strategy + context '#maybe_pipeline' do + it 'should not pipeline' do + source.should_not_receive(:pipelined) + strategy.maybe_pipeline(source) { } + end + end + + context 'with pipeline enabled' do + before(:each) { options.update pipeline: true } + it_should_behave_like RedisCopy::Strategy + context '#maybe_pipeline' do + it 'should pipeline' do + source.should_receive(:pipelined) + strategy.maybe_pipeline(source) { } + end + end + end end end