Add support for optional count
arg in rpop
#308
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
rpop
accepts an optionalcount
argument to indicate how many elements should be removed and returned from the listSee https://github.com/redis/redis-rb/blob/9938411bd44383b795e05df900abce4df66daaef/lib/redis/commands/lists.rb#L114
Also had to change the shared examples a little bit to be able to pass the arguments they use and make a more accurate expectation on the error.
I think the
args_for_method
is making an assumption when thearity < 0
and always using[1, 2]
(+ the key), but that doesn't work in all cases. In particular,rpop
now hasarity
-2
(because it has 1 required arg + 1 optional) so callingrpop(key, 1, 2)
was causing an argument error instead ofRedis::CommandError
(which we expect because of the redis value not being a list).At first I tried to change
args_for_method
but it made other tests fail. And i suspect it won't be possible to have a generic args generator only based on arity (because some methods for example accept*args
but the logic requires 1 or 2 args)That's why i thought it might be a good idea for each test that includes the shared example to indicate what the correct args to make a valid call should be, but let me know what you think!