guilleiguaran/fakeredis — pull request #95 by timherby (2014-02-11 00:38:37+00:00)
Title: Adds robustness to the zremrangebyrank method

I'm running into an error when removing the last item of a set, and then trying to trim a set down to a specific cap. With Redis, I don't need to check the length of a set before calling ```zremrangebyrank``` so I don't want to put that check in my production code. The set is missing because it gets removed by ```remove_key_for_empty_collection```.

Here is the pseudocode for repro. This block will apply a diff update to an existing list, but fails in FakeRedis if the last item gets removed:
```ruby
if items_to_remove.any?
list.redis.zrem list.key, items_to_remove.map { |i| list.to_redis(i) }
end

if items_to_add.any?
list.merge items_to_add
end

# prune the list to fit within the cap
list.remrangebyrank(0, -1 - Settings.buffer_size)
```

This pull request adds the same validation all the other methods use (see ```zrevrangebyscore```), and also moves the method above next to its cousin ```zremrangebyscore``` rather than being next to the disssimilar ```zinterstore``` and ```zunionstore```