Skip to content

Commit

Permalink
Raise error if passing empty array to mget (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuk09 committed Jun 25, 2020
1 parent 8ee7af4 commit 5466af8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/mock_redis/string_methods.rb
Expand Up @@ -154,9 +154,10 @@ def incrbyfloat(key, n)
end

def mget(*keys)
keys.flatten!

assert_has_args(keys, 'mget')

keys.flatten!
keys.map do |key|
get(key) if stringy?(key)
end
Expand Down
6 changes: 6 additions & 0 deletions spec/commands/mget_spec.rb
Expand Up @@ -49,5 +49,11 @@
@redises.mget
end.should raise_error(Redis::CommandError)
end

it 'raises an error if you pass it empty array' do
lambda do
@redises.mget([])
end.should raise_error(Redis::CommandError)
end
end
end

0 comments on commit 5466af8

Please sign in to comment.