From 91b8557459b68e6a895f0f352298e70e9c89c349 Mon Sep 17 00:00:00 2001 From: Ochi-Shoichi5539 Date: Wed, 17 Jan 2024 23:56:34 +0900 Subject: [PATCH] add specs for set method that has a third positional argument in its definition --- spec/commands/set_spec.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/commands/set_spec.rb b/spec/commands/set_spec.rb index b14000a..7196689 100644 --- a/spec/commands/set_spec.rb +++ b/spec/commands/set_spec.rb @@ -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