rspec-eventually 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspec/eventually/version.rb +1 -1
- data/lib/rspec/eventually.rb +10 -21
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95f25fba6427d1d12273581efe60dfecdda04e65
|
4
|
+
data.tar.gz: 6a9bb02287f285d58cafeaa9705b7fe40ae239d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9a666e1d8331a53512e5226701a7f00bf3ca606f9be728c1cb9de71028abd4bfdd941fa056c637ac47a0b483efad12c395f32c76212c049fed6bb8075a18a11
|
7
|
+
data.tar.gz: 5034559418f24b9de333dc7e3fe907377cd7cf5ceea2baa223f84c2a1dd083cd93754bc8a6436e5fc9ede2ef4fd2da9a5d88ef2d4e62b924c9fd6caae36892ea
|
data/lib/rspec/eventually.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rspec/eventually/version'
|
2
2
|
require 'rspec/core'
|
3
|
+
require 'timeout'
|
3
4
|
|
4
5
|
module Rspec
|
5
6
|
module Eventually
|
@@ -12,6 +13,7 @@ module Rspec
|
|
12
13
|
class FailedMatcherError < StandardError; end
|
13
14
|
|
14
15
|
class Eventually
|
16
|
+
attr_reader :timeout, :pause, :suppress_errors
|
15
17
|
def by_suppressing_errors
|
16
18
|
tap { @suppress_errors = true }
|
17
19
|
end
|
@@ -21,7 +23,9 @@ module Rspec
|
|
21
23
|
@tries = 0
|
22
24
|
@negative = false
|
23
25
|
@custom_msg = custom_msg
|
24
|
-
@
|
26
|
+
@timeout = Rspec::Eventually.timeout
|
27
|
+
@pause = Rspec::Eventually.pause
|
28
|
+
@suppress_errors = false
|
25
29
|
end
|
26
30
|
|
27
31
|
def matches?(expected_block)
|
@@ -48,10 +52,6 @@ module Rspec
|
|
48
52
|
true
|
49
53
|
end
|
50
54
|
|
51
|
-
def suppress_errors
|
52
|
-
@suppress_errors || false
|
53
|
-
end
|
54
|
-
|
55
55
|
def within(timeout)
|
56
56
|
tap { @timeout = timeout }
|
57
57
|
end
|
@@ -64,28 +64,17 @@ module Rspec
|
|
64
64
|
|
65
65
|
def eventually_matches?(expected_block)
|
66
66
|
target_matches?(expected_block) || fail(FailedMatcherError)
|
67
|
-
rescue => e
|
68
|
-
if
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
else
|
73
|
-
raise
|
74
|
-
end
|
67
|
+
rescue StandardError => e
|
68
|
+
raise if !e.is_a?(FailedMatcherError) && !suppress_errors
|
69
|
+
sleep pause
|
70
|
+
@tries += 1
|
71
|
+
retry
|
75
72
|
end
|
76
73
|
|
77
74
|
def target_matches?(expected_block)
|
78
75
|
result = @target.matches? expected_block.call
|
79
76
|
@negative ? !result : result
|
80
77
|
end
|
81
|
-
|
82
|
-
def timeout
|
83
|
-
@timeout || Rspec::Eventually.timeout
|
84
|
-
end
|
85
|
-
|
86
|
-
def pause
|
87
|
-
@pause || Rspec::Eventually.pause
|
88
|
-
end
|
89
78
|
end
|
90
79
|
|
91
80
|
def eventually(target, custom_msg = nil)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-eventually
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hawk Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.6.13
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Make your matchers match eventually
|