From 1b3e9b17ce2965abaa169065f4e5c90e7660a86d Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Mon, 1 Mar 2021 20:37:51 -0700 Subject: [PATCH] Fix hmset exception and xadd spec errors (#206) --- lib/mock_redis/hash_methods.rb | 2 +- spec/commands/xadd_spec.rb | 12 ++++++------ spec/commands/xlen_spec.rb | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/mock_redis/hash_methods.rb b/lib/mock_redis/hash_methods.rb index eeb83d7b..688976d2 100644 --- a/lib/mock_redis/hash_methods.rb +++ b/lib/mock_redis/hash_methods.rb @@ -94,7 +94,7 @@ def hmset(key, *kvpairs) assert_has_args(kvpairs, 'hmset') if kvpairs.length.odd? - raise Redis::CommandError, err_msg || 'ERR wrong number of arguments for HMSET' + raise Redis::CommandError, err_msg || 'ERR wrong number of arguments for \'hmset\' command' end kvpairs.each_slice(2) do |(k, v)| diff --git a/spec/commands/xadd_spec.rb b/spec/commands/xadd_spec.rb index 729edd82..ff299fc0 100644 --- a/spec/commands/xadd_spec.rb +++ b/spec/commands/xadd_spec.rb @@ -14,20 +14,20 @@ it 'returns an id based on the timestamp' do t = Time.now.to_i - id = @redises.xadd(@key, key: 'value') - expect(@redises.xadd(@key, key: 'value')).to match(/#{t}\d{3}-0/) + id = @redises.xadd(@key, { key: 'value' }) + expect(@redises.xadd(@key, { key: 'value' })).to match(/#{t}\d{3}-0/) end it 'adds data with symbols' do - @redises.xadd(@key, symbol_key: :symbol_value) + @redises.xadd(@key, { symbol_key: :symbol_value }) expect(@redises.xrange(@key, '-', '+').last[1]) .to eq('symbol_key' => 'symbol_value') end it 'increments the sequence number with the same timestamp' do Timecop.freeze do - @redises.xadd(@key, key: 'value') - expect(@redises.xadd(@key, key: 'value')).to match(/\d+-1/) + @redises.xadd(@key, { key: 'value' }) + expect(@redises.xadd(@key, { key: 'value' })).to match(/\d+-1/) end end @@ -67,7 +67,7 @@ it 'caters for the current time being before the last time' do t = (Time.now.to_f * 1000).to_i + 2000 @redises.xadd(@key, { key: 'value' }, id: "#{t}-0") - expect(@redises.xadd(@key, key: 'value')).to match(/#{t}-1/) + expect(@redises.xadd(@key, { key: 'value' })).to match(/#{t}-1/) end it 'appends a sequence number if it is missing' do diff --git a/spec/commands/xlen_spec.rb b/spec/commands/xlen_spec.rb index 5fe8d43e..eeaa509a 100644 --- a/spec/commands/xlen_spec.rb +++ b/spec/commands/xlen_spec.rb @@ -14,9 +14,9 @@ it 'returns the number of items in the stream' do expect(@redises.xlen(@key)).to eq 0 - @redises.xadd(@key, key: 'value') + @redises.xadd(@key, { key: 'value' }) expect(@redises.xlen(@key)).to eq 1 - 3.times { @redises.xadd(@key, key: 'value') } + 3.times { @redises.xadd(@key, { key: 'value' }) } expect(@redises.xlen(@key)).to eq 4 end end