Skip to content

Commit

Permalink
add specs for set method that has a third positional argument in its …
Browse files Browse the repository at this point in the history
…definition
  • Loading branch information
sho-work committed Jan 17, 2024
1 parent de403b2 commit 91b8557
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion spec/commands/set_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
require 'spec_helper'

RSpec.describe '#set(key, value)' do
RSpec.describe '#set(key, value, _hash)' do
let(:key) { 'mock-redis-test' }

it "responds with 'OK'" do
expect(@redises.set('mock-redis-test', 1)).to eq('OK')
end

context 'when the positional argument _hash exists' do
it "responds with 'OK'" do
# Testing MockRedis.new.set instead of @redises.set
# because the latter doesn't align with Redis's set method.
# In mock_redis, set accepts a third positional argument, _hash,
# to accommodate the difference with redis-store's set method,
# which takes three positional arguments, unlike the standard Redis set.
# Reference:
# Redis: https://github.com/redis/redis-rb/blob/09acb9026ab2deaca4c851e0bcdb0ef9318b1ee0/lib/redis/commands/strings.rb#L83
# Redis-store: https://github.com/redis-store/redis-store/blob/5c3fee1b8fba672eb2bd5bfaedb973b68d12b773/lib/redis/store/ttl.rb#L4
expect(MockRedis.new.set('mock-redis-test', 1, { key: 'value' })).to eq('OK')
end
end

context 'options' do
it 'raises an error for EX seconds = 0' do
expect do
Expand Down

0 comments on commit 91b8557

Please sign in to comment.