Skip to content

Commit

Permalink
Merge 3e52ea2 into 7535981
Browse files Browse the repository at this point in the history
  • Loading branch information
snmgian committed Sep 26, 2018
2 parents 7535981 + 3e52ea2 commit 5fed259
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/mock_redis/pipelined_wrapper.rb
Expand Up @@ -40,7 +40,12 @@ def pipelined(_options = {})
send(*future.command)
end
future.store_result(result)
result

if future.command[0] == :multi
result
else
[result]
end
rescue StandardError => e
e
end
Expand Down
26 changes: 26 additions & 0 deletions spec/commands/pipelined_spec.rb
Expand Up @@ -39,4 +39,30 @@
future.class.should be MockRedis::Future
end
end

context 'with pipelined operations returning array replies' do
let(:key1) { 'colors' }
let(:key2) { 'seasons' }
let(:value1) { %w(blue yellow) }
let(:value2) { %w(summer winter) }

before do
@redises.rpush(key1, value1)
@redises.rpush(key2, value2)
end

after do
@redises.del key1
@redises.del key2
end

it 'returns an array of the array replies' do
results = @redises.pipelined do |redis|
@redises.lrange(key1, 0, -1)
@redises.lrange(key2, 0, -1)
end

results.should == [value1, value2]
end
end
end

0 comments on commit 5fed259

Please sign in to comment.