Skip to content

Commit

Permalink
Remove method == from Redis::Future
Browse files Browse the repository at this point in the history
This helps to have a more consistent errors when operating with
Redis::Future inside a pipelined block
  • Loading branch information
GustavoCaso committed Sep 19, 2019
1 parent a2c562c commit abf097b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/redis/pipeline.rb
Expand Up @@ -132,6 +132,9 @@ class Future < BasicObject

attr_reader :timeout

# Avoid allowing people to use == inside a pipelined
undef :==

def initialize(command, transformation, timeout)
@command = command
@transformation = transformation
Expand Down Expand Up @@ -161,6 +164,7 @@ def is_a?(other)
self.class.ancestors.include?(other)
end


def class
Future
end
Expand Down
8 changes: 8 additions & 0 deletions test/pipelining_commands_test.rb
Expand Up @@ -126,6 +126,14 @@ def test_futures_raise_when_trying_to_access_their_values_too_early
end
end

def test_futures_raise_when_trying_to_compare_their_value_too_early
r.pipelined do
assert_raises(NoMethodError) do
r.sadd("foo", 1) == 1
end
end
end

def test_futures_raise_when_command_errors_and_needs_transformation
assert_raises(Redis::CommandError) do
r.pipelined do
Expand Down

0 comments on commit abf097b

Please sign in to comment.