-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add specs for
expire
-related commands options nx
, xx
, lt
and …
…`gt`
- Loading branch information
1 parent
7c071ff
commit b5ea96a
Showing
7 changed files
with
156 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
spec/support/shared_examples/raises_on_invalid_expire_command_options.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
RSpec.shared_examples_for 'raises on invalid expire command options' do |command| | ||
[%i[nx xx], %i[nx lt], %i[nx gt], %i[lt gt]].each do |options| | ||
context "with `#{options[0]}` and `#{options[1]}` options" do | ||
it 'raises `Redis::CommandError`' do | ||
expect { @mock.public_send(command, @key, 1, **options.zip([true, true]).to_h) } | ||
.to raise_error( | ||
Redis::CommandError, | ||
'ERR NX and XX, GT or LT options at the same time are not compatible' | ||
) | ||
end | ||
end | ||
|
||
context 'with unexpected key' do | ||
it 'raises `ArgumentError`' do | ||
expect { @mock.public_send(command, @key, 1, foo: true) } | ||
.to raise_error(ArgumentError) | ||
end | ||
end | ||
end | ||
end |