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

Fix get set reversibility #158

Merged
merged 2 commits into from
Jan 30, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/mock_redis/string_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def decrby(key, n)
end

def get(key)
key = key.to_s
assert_stringy(key)
data[key]
end
Expand Down
1 change: 1 addition & 0 deletions spec/commands/get_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

@redises.set(key, 'hello')
@redises.get(key.to_s).should == 'hello'
@redises.get(key).should == 'hello'
end

it_should_behave_like 'a string-only command'
Expand Down
4 changes: 2 additions & 2 deletions spec/commands/xadd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
end

it 'raises exception if id of 0 is added to an empty stream' do
expect { @redises.xadd('unknown-stream', { key: 'value' }, id: '0') }
expect { @redises.xadd('mock-redis-test:unknown-stream', { key: 'value' }, id: '0') }
.to raise_error(
Redis::CommandError,
'ERR The ID specified in XADD is equal or smaller than the target ' \
Expand All @@ -58,7 +58,7 @@
end

it 'does not raise exception on empty stream with id of 0 and positive sequence number' do
expect { @redises.xadd('unknown-stream', { key: 'value' }, id: '0-1') }
expect { @redises.xadd('mock-redis-test:unknown-stream', { key: 'value' }, id: '0-1') }
.to_not raise_error
end

Expand Down