redness 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/redness/red.rb +1 -1
- data/lib/redness/version.rb +1 -1
- data/spec/redness/red_spec.rb +14 -0
- metadata +1 -1
data/lib/redness/red.rb
CHANGED
@@ -21,7 +21,7 @@ class Red
|
|
21
21
|
|
22
22
|
def execute_with_uncertainty(fail_return = [])
|
23
23
|
yield
|
24
|
-
rescue RedisUnavailable, Redis::CannotConnectError,
|
24
|
+
rescue RedisUnavailable, Redis::CannotConnectError, Redis::TimeoutError
|
25
25
|
fail_return
|
26
26
|
end
|
27
27
|
|
data/lib/redness/version.rb
CHANGED
data/spec/redness/red_spec.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
require_relative '../spec_integration_helper'
|
2
2
|
|
3
3
|
describe Red do
|
4
|
+
describe "#execute_with_uncertainty" do
|
5
|
+
it "should return the given value if the block raises a Red::RedisUnavailable" do
|
6
|
+
Red.new.execute_with_uncertainty(2) { raise Red::RedisUnavailable }.should == 2
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should return the given value if the block raises a Redis::CannotConnectError" do
|
10
|
+
Red.new.execute_with_uncertainty(2) { raise Redis::CannotConnectError }.should == 2
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return the given value if the block raises a Redis::TimeoutError" do
|
14
|
+
Red.new.execute_with_uncertainty(2) { raise Redis::TimeoutError }.should == 2
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
4
18
|
describe "#multi_with_caution" do
|
5
19
|
it "should not try call discard if the multi fails" do
|
6
20
|
Red.redis.stub(:multi).and_raise(Redis::TimeoutError)
|