-
Notifications
You must be signed in to change notification settings - Fork 157
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
Issue 281 v5 sadd srem return value #293
Changes from all commits
9aa386a
48191fa
2c6aa8e
249b9b3
1a77105
6da7580
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,19 @@ | |
before { @key = 'mock-redis-test:sadd' } | ||
|
||
context 'sadd' do | ||
it 'returns true if the set did not already contain member' do | ||
expect(@redises.sadd(@key, 1)).to eq(true) | ||
end | ||
context 'adapts to redis-rd version 4 and 5 outputs' do | ||
include MockRedis::UtilityMethods | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just trying to reuse the |
||
|
||
it 'returns false if the set did already contain member' do | ||
@redises.sadd(@key, 1) | ||
expect(@redises.sadd(@key, 1)).to eq(false) | ||
let(:positive_response) { redis_gem_v5? ? 1 : true } | ||
let(:negative_response) { redis_gem_v5? ? 0 : false } | ||
it 'returns true if the set did not already contain member' do | ||
expect(@redises.sadd(@key, 1)).to eq(positive_response) | ||
end | ||
|
||
it 'returns false if the set did already contain member' do | ||
@redises.sadd(@key, 1) | ||
expect(@redises.sadd(@key, 1)).to eq(negative_response) | ||
end | ||
end | ||
|
||
it 'adds member to the set' do | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,24 +8,31 @@ | |
@redises.sadd(@key, 'ernie') | ||
end | ||
|
||
it 'returns true if member is in the set' do | ||
expect(@redises.srem(@key, 'bert')).to eq(true) | ||
end | ||
context 'adapts to redis-rd version 4 and 5 outputs' do | ||
include MockRedis::UtilityMethods | ||
|
||
let(:positive_response) { redis_gem_v5? ? 1 : true } | ||
let(:negative_response) { redis_gem_v5? ? 0 : false } | ||
|
||
it 'returns false if member is not in the set' do | ||
expect(@redises.srem(@key, 'cookiemonster')).to eq(false) | ||
it 'returns positive response if member is in the set' do | ||
expect(@redises.srem(@key, 'bert')).to eq(positive_response) | ||
end | ||
|
||
it 'returns negative response if member is not in the set' do | ||
expect(@redises.srem(@key, 'cookiemonster')).to eq(negative_response) | ||
end | ||
|
||
it 'stringifies member' do | ||
@redises.sadd(@key, '1') | ||
expect(@redises.srem(@key, 1)).to eq(positive_response) | ||
end | ||
end | ||
|
||
it 'removes member from the set' do | ||
@redises.srem(@key, 'ernie') | ||
expect(@redises.smembers(@key)).to eq(['bert']) | ||
end | ||
|
||
it 'stringifies member' do | ||
@redises.sadd(@key, '1') | ||
expect(@redises.srem(@key, 1)).to eq(true) | ||
end | ||
|
||
Comment on lines
-24
to
-28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved to the version specific block |
||
it 'cleans up empty sets' do | ||
@redises.smembers(@key).each { |m| @redises.srem(@key, m) } | ||
expect(@redises.get(@key)).to be_nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
@redises.set(key, '') | ||
expect do | ||
@redises.send(method, *args) | ||
end.to raise_error(defined?(default_error) ? default_error : RuntimeError) | ||
end.to raise_error(defined?(default_error) ? default_error : Redis::BaseError) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the version 5 BaseError now inherits from |
||
expect(@redises.get(key)).to eq('') | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mimicing the behavior from
sadd