attempt_to 0.4 → 0.4.1

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: 9cee4b7546988224234bf6ce6290c5af576b1db1
4
- data.tar.gz: 1ec8e3c7ec2105db8e2326e7131bd3c6b34dc233
3
+ metadata.gz: 0b9f1808d7b047596ab94f63627d656a739dcc30
4
+ data.tar.gz: 18341f2615619c48603cc72cf76bd752213aed10
5
5
  SHA512:
6
- metadata.gz: 02eb2d298df2af64bc20b0dc00fbd603c89c6eb0e20db89d4140f29a42b2fb2406bb465a1f8d4cd2718c58880af6a4be98144e2d4f0511c1c25eefb35bc2c145
7
- data.tar.gz: 8f5baa089c594cdb1ac94aa004563b0a7992adcb33e56e7682067682bad4f83f3e0bf067792ba11263159ff28a79fea9b8295abd233c8d3d5dad46cf4cd23946
6
+ metadata.gz: 8ec78a27174da0f5a37ffedec3f8aa187842e062b699b76aec0a643e7abecdc3bde7459d57589adb777223ebfc85796c4d31761a974367df3c57afd0791c1bd5
7
+ data.tar.gz: 20e808ba0cfe5b918e708cab898eadf803eb06a1d641e72a3c014fec9c81fdc851b110f8c15775df86514b33c9c1b286a2c1a089df1b2a80601945123fe09bf0
@@ -21,7 +21,8 @@ module AttemptTo
21
21
  while not success
22
22
  begin
23
23
  success = yield
24
- rescue Exception
24
+ rescue Exception => e
25
+ raise e if e.message == 'execution expired' # Bug in Ruby 2.0. The rescue rescues a timeout object of a weird class type
25
26
  end
26
27
  end
27
28
  }
@@ -1,4 +1,4 @@
1
1
 
2
2
  module AttemptTo
3
- VERSION = "0.4"
3
+ VERSION = "0.4.1"
4
4
  end
@@ -1,6 +1,7 @@
1
1
 
2
2
  require 'attempt_to'
3
3
  require 'socket'
4
+ require 'timeout'
4
5
 
5
6
  describe "Attempt to do something a couple of times, if it fails, bail out." do
6
7
 
@@ -63,4 +64,7 @@ describe "Attempt to do something a couple of times, if it fails, bail out." do
63
64
  expect { attempt_to_with_timeout(0.3) { false } }.to raise_error(Timeout::Error, "execution expired")
64
65
  end
65
66
 
67
+ it "will return a Timeout when the condition never happens as it takes too long" do
68
+ expect { attempt_to_with_timeout(0.3) { sleep(2) } }.to raise_error(Timeout::Error, "execution expired")
69
+ end
66
70
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attempt_to
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bas Vodde
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-05 00:00:00.000000000 Z
11
+ date: 2014-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.0.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.0.0
41
41
  description: AttemptTo calls a code block and re-tries it if it throws an exception.
@@ -62,12 +62,12 @@ require_paths:
62
62
  - lib
63
63
  required_ruby_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
65
+ - - '>='
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  requirements:
70
- - - ">="
70
+ - - '>='
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []