Skip to content
Permalink
Browse files
Better test for Backend#reconnect
While we were testing it, we didn't actually test the real condition:
https://coveralls.io/files/4962020

Now, we're actually falling through to that line and handling things the
right way.
  • Loading branch information
steveklabnik committed Apr 28, 2013
1 parent 2ae4899 commit 4e3ff761198ccecaa78ddcfd19b6e120e67ca293
Showing 1 changed file with 13 additions and 3 deletions.
@@ -20,10 +20,10 @@
redis = Class.new do
def client
@client ||= Class.new do
attr_accessor :count

def reconnect
@count ||= 0
return if @count == 2

@count += 1
raise Redis::BaseConnectionError
end
@@ -35,8 +35,18 @@ def reconnect

# not actually stubbing right now?
Kernel.stub(:sleep, nil) do
client.reconnect
rescued = false

begin
client.reconnect
rescue Resque::Backend::ConnectionError
rescued = true
assert_equal 3, client.store.client.count
end

assert rescued
end

end
end
end

0 comments on commit 4e3ff76

Please sign in to comment.