redness 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3862e8e860fee075ba25f5de2434a99af1b6072c
4
- data.tar.gz: d3322385369795e8a577cff257f15c446a13110d
3
+ metadata.gz: b4c9bff0bf476a0549dc3d83b9b46b399e6fe511
4
+ data.tar.gz: 217db2555acf708704f24c774cf580fe046da454
5
5
  SHA512:
6
- metadata.gz: 415af254a7f8b6fa44cd55b09875519ae4b207513b53fc17623c0dbfaca25a125e84dcba197b9f1e069414902ec921176af48562ae3391d414ec5bceda3e020a
7
- data.tar.gz: b094a27bf2d162d017d799e8dfc2e89cadb534b29ab1f7f8ef869e680e219c14ac4e68d993398a865b08679151385dc4b2e5cf7fa4d86d6babdd85eebde3b2a0
6
+ metadata.gz: cbf8e0434cb489adce9914bef551528fb734a9a808c97cc8ecc29a2d7574e4fc230b3871f40d53ab27cd30878cfb11663423db468cf9dbc71c27af59fce3251a
7
+ data.tar.gz: 4918ea9cbae280334c6cc62d3681a4d3bc99af8f11a251b276c3989ad22ae76f15abda2d2d84bbc95664b47619dfd20194e59a8f4605dd72c8c3a8ddefdc3c9d
@@ -3,6 +3,13 @@ require 'timeout'
3
3
  class Red
4
4
  class RedisUnavailable < StandardError; end
5
5
 
6
+ REDIS_ERRORS = [
7
+ RedisUnavailable,
8
+ Redis::CannotConnectError,
9
+ Redis::ConnectionError,
10
+ Redis::TimeoutError
11
+ ]
12
+
6
13
  class << self
7
14
  attr_accessor :redis
8
15
  end
@@ -21,7 +28,7 @@ class Red
21
28
 
22
29
  def execute_with_uncertainty(fail_return = [])
23
30
  yield
24
- rescue RedisUnavailable, Redis::CannotConnectError, Redis::TimeoutError
31
+ rescue *REDIS_ERRORS
25
32
  fail_return
26
33
  end
27
34
 
@@ -1,4 +1,4 @@
1
1
  module Redness
2
- VERSION="0.2.3"
2
+ VERSION="0.2.4"
3
3
  MAJOR, MINOR, TINY = VERSION.split(".")
4
4
  end
@@ -2,16 +2,36 @@ require_relative '../spec_integration_helper'
2
2
 
3
3
  describe Red do
4
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(:boom) { raise Red::RedisUnavailable }.should == :boom
5
+ context "when the block raises Red::RedisUnavailable" do
6
+ it "returns the given value" do
7
+ Red.new.execute_with_uncertainty(:boom) do
8
+ raise Red::RedisUnavailable
9
+ end.should == :boom
10
+ end
11
+ end
12
+
13
+ context "when the block raises Redis::CannotConnectError" do
14
+ it "returns the given value" do
15
+ Red.new.execute_with_uncertainty(:boom) do
16
+ raise Redis::CannotConnectError
17
+ end.should == :boom
18
+ end
7
19
  end
8
20
 
9
- it "should return the given value if the block raises a Redis::CannotConnectError" do
10
- Red.new.execute_with_uncertainty(:boom) { raise Redis::CannotConnectError }.should == :boom
21
+ context "when the block raises a Redis::ConnectionError" do
22
+ it "returns the given value" do
23
+ Red.new.execute_with_uncertainty(:boom) do
24
+ raise Redis::ConnectionError
25
+ end.should == :boom
26
+ end
11
27
  end
12
28
 
13
- it "should return the given value if the block raises a Redis::TimeoutError" do
14
- Red.new.execute_with_uncertainty(:boom) { raise Redis::TimeoutError }.should == :boom
29
+ context "when the block raises Redis::TimeoutError" do
30
+ it "returns the given value" do
31
+ Red.new.execute_with_uncertainty(:boom) do
32
+ raise Redis::TimeoutError
33
+ end.should == :boom
34
+ end
15
35
  end
16
36
  end
17
37
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Baldur Gudbjornsson
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2015-12-21 00:00:00.000000000 Z
17
+ date: 2016-02-26 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: json