rspec-retry_ex 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -0
- data/.travis.yml +6 -5
- data/README.md +31 -0
- data/lib/rspec/retry_ex/retry_handler.rb +18 -5
- data/lib/rspec/retry_ex/version.rb +1 -1
- data/lib/rspec/retry_ex.rb +8 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3def93de8ee015ace346b71f85e60fcb55a81221e6c68b4a041155686f3ed6e7
|
4
|
+
data.tar.gz: 578ccd8221b246ede71243aea35a8fdb4940f773000d03278ced66180c075847
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f19a0d5b8a8908147a1d78442ae1466a25cb954bced5b723fbedc0a996065ad89f71f48d6599929a971d978a88970e8c3a50aadfa6d113f4d3deb30d8d98dde
|
7
|
+
data.tar.gz: 3fa5052e60f01aeb9999d8c84ba71cc82c426cd5f85602b6cae9a814a7b02b7d32bac2eb71a47b602b6fa3f2d277bc2ab671998198f996b5e9156ef54aef013c
|
data/.rubocop.yml
CHANGED
@@ -2,6 +2,9 @@ AllCops:
|
|
2
2
|
Exclude:
|
3
3
|
- rspec-retry_ex.gemspec
|
4
4
|
- tmp/**/*
|
5
|
+
- Rakefile
|
6
|
+
- Gemfile
|
7
|
+
- spec/spec_helper.rb
|
5
8
|
|
6
9
|
Metrics/LineLength:
|
7
10
|
Max: 100
|
@@ -17,3 +20,15 @@ Layout/IndentationConsistency:
|
|
17
20
|
|
18
21
|
Metrics/CyclomaticComplexity:
|
19
22
|
Max: 10
|
23
|
+
|
24
|
+
Style/TrailingCommaInArrayLiteral:
|
25
|
+
EnforcedStyleForMultiline: comma
|
26
|
+
|
27
|
+
Style/TrailingCommaInHashLiteral:
|
28
|
+
EnforcedStyleForMultiline: comma
|
29
|
+
|
30
|
+
Style/FrozenStringLiteralComment:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Style/NumericPredicate:
|
34
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -2,9 +2,9 @@ sudo: false
|
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
4
|
- 2.2.10
|
5
|
-
- 2.3.
|
6
|
-
- 2.4.
|
7
|
-
- 2.5.
|
5
|
+
- 2.3.8
|
6
|
+
- 2.4.5
|
7
|
+
- 2.5.3
|
8
8
|
gemfile:
|
9
9
|
- gemfiles/rspec_33x.gemfile
|
10
10
|
- gemfiles/rspec_34x.gemfile
|
@@ -16,14 +16,15 @@ branches:
|
|
16
16
|
only:
|
17
17
|
- master
|
18
18
|
before_install:
|
19
|
-
- gem
|
20
|
-
- gem install bundler
|
19
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
20
|
+
- gem install bundler -v '< 2'
|
21
21
|
before_script:
|
22
22
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
23
23
|
- chmod +x ./cc-test-reporter
|
24
24
|
- ./cc-test-reporter before-build
|
25
25
|
script:
|
26
26
|
- bundle exec rspec spec
|
27
|
+
- rubocop
|
27
28
|
after_script:
|
28
29
|
- |
|
29
30
|
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
data/README.md
CHANGED
@@ -66,6 +66,37 @@ scenario "Some scenario" do
|
|
66
66
|
end
|
67
67
|
```
|
68
68
|
|
69
|
+
## Configuration
|
70
|
+
|
71
|
+
Errors to retry is customizable.
|
72
|
+
|
73
|
+
Only `RSpec::Expectations::ExpectationNotMetError` is retried by default.
|
74
|
+
|
75
|
+
Here is an example of configuration in `spec_helper.rb` or `rails_helper.rb`.
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
RSpec.configure do |config|
|
79
|
+
config.rspec_retry_ex_retry_errors = [
|
80
|
+
RSpec::Expectations::ExpectationNotMetError,
|
81
|
+
Selenium::WebDriver::Error::WebDriverError
|
82
|
+
]
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
86
|
+
Or options for `retry_ex`.
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
scenario "Some scenario" do
|
90
|
+
visit "/some_page"
|
91
|
+
|
92
|
+
fill_in "postcode", with: "1300012"
|
93
|
+
retry_ex(count: 3, retry_errors: [Selenium::WebDriver::Error::WebDriverError]) do
|
94
|
+
expect(page).to have_select("ward", selected: "Sumida")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
```
|
99
|
+
|
69
100
|
## Contributing
|
70
101
|
You should follow the steps below:
|
71
102
|
|
@@ -2,10 +2,11 @@ module RSpec
|
|
2
2
|
module RetryEx
|
3
3
|
class RetryHandler
|
4
4
|
def initialize(**options)
|
5
|
-
@count
|
6
|
-
@before_retry
|
7
|
-
@after_retry
|
8
|
-
@counter
|
5
|
+
@count = options[:count] || 1
|
6
|
+
@before_retry = options[:before_retry]
|
7
|
+
@after_retry = options[:after_retry]
|
8
|
+
@counter = 0
|
9
|
+
@retry_errors = initialize_retry_errors(options[:retry_errors])
|
9
10
|
end
|
10
11
|
|
11
12
|
def run
|
@@ -13,7 +14,7 @@ module RSpec
|
|
13
14
|
@counter += 1
|
14
15
|
yield
|
15
16
|
success_message
|
16
|
-
rescue
|
17
|
+
rescue *@retry_errors => e
|
17
18
|
call_around_retry(after_retry)
|
18
19
|
failure_message(e, count)
|
19
20
|
retry if @counter < count
|
@@ -26,11 +27,13 @@ module RSpec
|
|
26
27
|
|
27
28
|
def call_around_retry(around_retry)
|
28
29
|
return if around_retry.nil?
|
30
|
+
|
29
31
|
around_retry.call
|
30
32
|
end
|
31
33
|
|
32
34
|
def success_message
|
33
35
|
return unless @counter > 1
|
36
|
+
|
34
37
|
message = "Congratulations! #{ordinalize(@counter)} try has succeeded!.\n"
|
35
38
|
RSpec.configuration.reporter.message(message)
|
36
39
|
end
|
@@ -61,6 +64,16 @@ module RSpec
|
|
61
64
|
end
|
62
65
|
end
|
63
66
|
# rubocop:enable Metrics/MethodLength
|
67
|
+
|
68
|
+
def initialize_retry_errors(retry_errors)
|
69
|
+
if retry_errors.is_a?(Array) && !retry_errors.empty?
|
70
|
+
retry_errors
|
71
|
+
elsif !RSpec.configuration.rspec_retry_ex_retry_errors.empty?
|
72
|
+
RSpec.configuration.rspec_retry_ex_retry_errors
|
73
|
+
else
|
74
|
+
[RSpec::Expectations::ExpectationNotMetError]
|
75
|
+
end
|
76
|
+
end
|
64
77
|
end
|
65
78
|
end
|
66
79
|
end
|
data/lib/rspec/retry_ex.rb
CHANGED
@@ -2,6 +2,12 @@ require "rspec/retry_ex/retry_handler"
|
|
2
2
|
|
3
3
|
module RSpec
|
4
4
|
module RetryEx
|
5
|
+
def self.setup
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.add_setting :rspec_retry_ex_retry_errors, default: []
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
def retry_ex(**options)
|
6
12
|
handler = RetryHandler.new(options)
|
7
13
|
handler.run do
|
@@ -10,3 +16,5 @@ module RSpec
|
|
10
16
|
end
|
11
17
|
end
|
12
18
|
end
|
19
|
+
|
20
|
+
RSpec::RetryEx.setup
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-retry_ex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yuyasat
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|
@@ -171,8 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0'
|
173
173
|
requirements: []
|
174
|
-
|
175
|
-
rubygems_version: 2.7.6
|
174
|
+
rubygems_version: 3.0.3
|
176
175
|
signing_key:
|
177
176
|
specification_version: 4
|
178
177
|
summary: retry rspec one target `expect`
|