Skip to content

Commit

Permalink
Make call method command name case-insensitive (#287)
Browse files Browse the repository at this point in the history
Redis commands are case-insensitive.

`redis-rb` behavior:

```
[1] redis_connection.call(["sET", "foo", 1])
"OK"
[2] redis_connection.call(["GET", "foo"])
"1"
```
  • Loading branch information
viralpraxis authored Nov 16, 2023
1 parent ff02359 commit 202bde6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mock_redis/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def initialize_copy(_source)
# Redis commands go below this line and above 'private'

def call(command, &_block)
public_send(*command)
public_send(command[0].downcase, *command[1..])
end

def auth(_)
Expand Down
10 changes: 10 additions & 0 deletions spec/commands/pipelined_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,15 @@

expect(results).to eq([value1, 'OK', 'foobar'])
end

it 'works correctly with mixed-case commands' do
results = @redises.pipelined do |redis|
redis.call(['Get', key1])
redis.call(['SET', key2, 'foobar'])
redis.call(['gET', key2])
end

expect(results).to eq([value1, 'OK', 'foobar'])
end
end
end

0 comments on commit 202bde6

Please sign in to comment.