Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise error if passing empty array to mget #191

Merged
merged 1 commit into from Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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