rspec-repeat 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/HISTORY.md +8 -1
- data/README.md +23 -4
- data/lib/rspec/repeat.rb +2 -2
- data/lib/rspec/repeat/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59d577d9272c369c5c1619fc93dedd5e4df187cd
|
4
|
+
data.tar.gz: 36e055e49a981acfa79ea392624b1c0d566bdc5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc5010cff6d26c3a369ad7cd39b231dac2fabf5a9ccfcb398c17f3d08f66cab594273563ea4a3ac641dd00ca040bd28bfbd6aa13056823bd45196eadd1496c33
|
7
|
+
data.tar.gz: ffe2c0ccf93974766c68bd779ee991da80e7e73ec7c7815f25582fd61469c809d883ac9758a8e601ec7c53cdfa831fb39444311023fc7145a16adf888b60d76e
|
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -7,10 +7,10 @@ describe 'a stubborn test' do
|
|
7
7
|
include Rspec::Repeat
|
8
8
|
|
9
9
|
around do |example|
|
10
|
-
repeat example,
|
10
|
+
repeat example, 10.times
|
11
11
|
end
|
12
12
|
|
13
|
-
it 'works' do
|
13
|
+
it 'works, eventually' do
|
14
14
|
expect(rand(2)).to eq 0
|
15
15
|
end
|
16
16
|
end
|
@@ -22,9 +22,22 @@ end
|
|
22
22
|
|
23
23
|
## Advanced usage
|
24
24
|
|
25
|
+
### Options
|
26
|
+
|
27
|
+
```
|
28
|
+
repeat example, 3.times, { options }
|
29
|
+
```
|
30
|
+
|
31
|
+
You can pass an `options` hash:
|
32
|
+
|
33
|
+
- __clear_let__ *(Boolean)* - if *false*, `let` declarations will not be cleared.
|
34
|
+
- __exceptions__ *(Array)* - if given, it will only retry exception classes from this list.
|
35
|
+
- __wait__ *(Numeric)* - seconds to wait between each retry.
|
36
|
+
- __verbose__ *(Boolean)* - if *true*, it will print messages upon failure.
|
37
|
+
|
25
38
|
### Attaching to tags
|
26
39
|
|
27
|
-
This will allow you to repeat any example
|
40
|
+
This will allow you to repeat any example multiple times by tagging it.
|
28
41
|
|
29
42
|
```rb
|
30
43
|
# rails_helper.rb or spec_helper.rb
|
@@ -43,7 +56,7 @@ end
|
|
43
56
|
|
44
57
|
### Attaching to features
|
45
58
|
|
46
|
-
This will make all `spec/features/` retry thrice. Perfect for
|
59
|
+
This will make all `spec/features/` retry thrice. Perfect for Poltergeist/Selenium tests that intermittently fail for no reason.
|
47
60
|
|
48
61
|
```rb
|
49
62
|
# rails_helper.rb or spec_helper.rb
|
@@ -54,6 +67,12 @@ RSpec.configure do
|
|
54
67
|
end
|
55
68
|
```
|
56
69
|
|
70
|
+
In these cases, it'd be smart to restrict which exceptions to be retried.
|
71
|
+
|
72
|
+
```rb
|
73
|
+
repeat example, 3.times, exceptions: [ Net::ReadTimeout ]
|
74
|
+
```
|
75
|
+
|
57
76
|
<br>
|
58
77
|
|
59
78
|
## Acknowledgement
|
data/lib/rspec/repeat.rb
CHANGED
@@ -45,7 +45,7 @@ module RSpec
|
|
45
45
|
example.instance_variable_set :@exception, nil
|
46
46
|
ex.run
|
47
47
|
break if example.exception.nil?
|
48
|
-
break if matches_exceptions?(exceptions, example.exception)
|
48
|
+
break if !matches_exceptions?(exceptions, example.exception)
|
49
49
|
print_failure(i, example) if verbose
|
50
50
|
clear_memoize(ctx) if clear_let
|
51
51
|
sleep wait if wait.to_i > 0
|
@@ -72,7 +72,7 @@ module RSpec
|
|
72
72
|
|
73
73
|
# Checks if `exception` is in `exceptions`
|
74
74
|
def matches_exceptions?(exceptions, exception)
|
75
|
-
return unless exceptions
|
75
|
+
return true unless exceptions
|
76
76
|
exceptions.any? do |exception_klass|
|
77
77
|
exception.is_a?(exception_klass)
|
78
78
|
end
|
data/lib/rspec/repeat/version.rb
CHANGED