rspec-retry_ex 0.1.0.pre.patch → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +86 -0
- data/.rubocop.yml +6 -0
- data/README.md +33 -2
- data/lib/rspec/retry_ex/retry_handler.rb +13 -2
- data/lib/rspec/retry_ex/version.rb +1 -1
- data/lib/rspec/retry_ex.rb +10 -1
- data/rspec-retry_ex.gemspec +2 -1
- metadata +24 -10
- data/.travis.yml +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15aa4ca3ed684d9ff143035798e820c0662356f3637be5258e424f8211f14304
|
4
|
+
data.tar.gz: 506a29213d69ed7402fe5807e5af830dabf95d978e801e77bc663c68dde4255d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 005e1e5643567aa9d33425db96d54dbef95e0b5991ffb7b3226e1d99cbf3ffa080cc87d599217f23bda00fcaf313f44eaa948e3c82784c747df7b02e92f8a257
|
7
|
+
data.tar.gz: c59451099d0a9320376d4b0ea4971ceb68015f86c5270d1f4ee148a8583586b3922395a45c5ffe256427cced444a77320d73258d7c4f589c9484ff8b08a7ae0d
|
@@ -0,0 +1,86 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
setup_and_run_test_on_3_0_3:
|
4
|
+
parallelism: 1
|
5
|
+
docker:
|
6
|
+
- image: circleci/ruby:3.0.3
|
7
|
+
environment:
|
8
|
+
BUNDLE_JOBS: 3
|
9
|
+
BUNDLE_RETRY: 3
|
10
|
+
BUNDLE_PATH: vendor/bundle
|
11
|
+
steps:
|
12
|
+
- checkout
|
13
|
+
- run:
|
14
|
+
name: echo ruby version
|
15
|
+
command: ruby --version
|
16
|
+
- run:
|
17
|
+
name: Which bundler?
|
18
|
+
command: bundle -v
|
19
|
+
- restore_cache:
|
20
|
+
keys:
|
21
|
+
- v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "rspec-retry_ex.gemspec" }}
|
22
|
+
- v1-gem-cache-{{ arch }}-{{ .Branch }}-
|
23
|
+
- v1-gem-cache-{{ arch }}-
|
24
|
+
- run:
|
25
|
+
name: Bundle Install
|
26
|
+
command: bundle install --path vendor/bundle --clean
|
27
|
+
- save_cache:
|
28
|
+
key: v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "rspec-retry_ex.gemspec" }}
|
29
|
+
paths:
|
30
|
+
- vendor/bundle
|
31
|
+
- run:
|
32
|
+
name: Run rspec in parallel
|
33
|
+
command: |
|
34
|
+
bundle exec rspec --profile 10 \
|
35
|
+
--format RspecJunitFormatter \
|
36
|
+
--out test_results/rspec.xml \
|
37
|
+
--format progress \
|
38
|
+
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
39
|
+
# Save test results for timing analysis
|
40
|
+
- store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
|
41
|
+
path: test_results
|
42
|
+
setup_and_run_test_on_2_7_3:
|
43
|
+
parallelism: 1
|
44
|
+
docker:
|
45
|
+
- image: circleci/ruby:2.7.3
|
46
|
+
environment:
|
47
|
+
BUNDLE_JOBS: 3
|
48
|
+
BUNDLE_RETRY: 3
|
49
|
+
BUNDLE_PATH: vendor/bundle
|
50
|
+
steps:
|
51
|
+
- checkout
|
52
|
+
- run:
|
53
|
+
name: echo ruby version
|
54
|
+
command: ruby --version
|
55
|
+
- run:
|
56
|
+
name: Which bundler?
|
57
|
+
command: bundle -v
|
58
|
+
- restore_cache:
|
59
|
+
keys:
|
60
|
+
- v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "rspec-retry_ex.gemspec" }}
|
61
|
+
- v1-gem-cache-{{ arch }}-{{ .Branch }}-
|
62
|
+
- v1-gem-cache-{{ arch }}-
|
63
|
+
- run:
|
64
|
+
name: Bundle Install
|
65
|
+
command: bundle install --path vendor/bundle --clean
|
66
|
+
- save_cache:
|
67
|
+
key: v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "rspec-retry_ex.gemspec" }}
|
68
|
+
paths:
|
69
|
+
- vendor/bundle
|
70
|
+
- run:
|
71
|
+
name: Run rspec in parallel
|
72
|
+
command: |
|
73
|
+
bundle exec rspec --profile 10 \
|
74
|
+
--format RspecJunitFormatter \
|
75
|
+
--out test_results/rspec.xml \
|
76
|
+
--format progress \
|
77
|
+
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
78
|
+
# Save test results for timing analysis
|
79
|
+
- store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
|
80
|
+
path: test_results
|
81
|
+
workflows:
|
82
|
+
version: 2
|
83
|
+
setup_and_run_test:
|
84
|
+
jobs:
|
85
|
+
- setup_and_run_test_on_2_7_3
|
86
|
+
- setup_and_run_test_on_3_0_3
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# RSpec::RetryEx
|
2
|
-
[![
|
2
|
+
[![CircleCI](https://circleci.com/gh/yuyasat/rspec-retry_ex/tree/master.svg?style=svg)](https://circleci.com/gh/yuyasat/rspec-retry_ex/tree/master)
|
3
3
|
[![Maintainability](https://api.codeclimate.com/v1/badges/e5524b7a5cd965dd362e/maintainability)](https://codeclimate.com/github/yuyasat/rspec-retry_ex/maintainability)
|
4
4
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/e5524b7a5cd965dd362e/test_coverage)](https://codeclimate.com/github/yuyasat/rspec-retry_ex/test_coverage)
|
5
5
|
|
@@ -8,7 +8,7 @@ RSpec::RetryEx retrys failing rspec "expect" instead of "example", "it" or "scen
|
|
8
8
|
## Motivation
|
9
9
|
Feature test or System test sometimes fails randomely. There are so many reasons for failing. One of them is that the browser does not response smoothly to JavaScript animation. However it responses somoothly in a few tries. As a result, a few retries should be executed in feature test of system test.
|
10
10
|
|
11
|
-
Thanks to [
|
11
|
+
Thanks to [rspec-retry](https://github.com/NoRedInk/rspec-retry) gem, a few retries can be executed by "scenario" unit. However we sometimes want to try to retry by "expect" unit because the scenario is so long and most "expect"s usually pass and specific "expect" often fails.
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
@@ -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
|
|
@@ -6,6 +6,7 @@ module RSpec
|
|
6
6
|
@before_retry = options[:before_retry]
|
7
7
|
@after_retry = options[:after_retry]
|
8
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
|
@@ -39,7 +40,7 @@ module RSpec
|
|
39
40
|
|
40
41
|
def failure_message(error, count)
|
41
42
|
message = "#{ordinalize(@counter)} try has failed.\n"
|
42
|
-
message += "
|
43
|
+
message += "=>#{error}" if @counter == count
|
43
44
|
RSpec.configuration.reporter.message(message)
|
44
45
|
end
|
45
46
|
|
@@ -63,6 +64,16 @@ module RSpec
|
|
63
64
|
end
|
64
65
|
end
|
65
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
|
66
77
|
end
|
67
78
|
end
|
68
79
|
end
|
data/lib/rspec/retry_ex.rb
CHANGED
@@ -1,12 +1,21 @@
|
|
1
|
+
require "rspec/core"
|
1
2
|
require "rspec/retry_ex/retry_handler"
|
2
3
|
|
3
4
|
module RSpec
|
4
5
|
module RetryEx
|
6
|
+
def self.setup
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.add_setting :rspec_retry_ex_retry_errors, default: []
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
5
12
|
def retry_ex(**options)
|
6
|
-
handler = RetryHandler.new(options)
|
13
|
+
handler = RetryHandler.new(**options)
|
7
14
|
handler.run do
|
8
15
|
yield
|
9
16
|
end
|
10
17
|
end
|
11
18
|
end
|
12
19
|
end
|
20
|
+
|
21
|
+
RSpec::RetryEx.setup
|
data/rspec-retry_ex.gemspec
CHANGED
@@ -22,9 +22,10 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
spec.add_runtime_dependency(%{rspec-core}, '>3.3')
|
25
|
-
spec.add_development_dependency "bundler", "
|
25
|
+
spec.add_development_dependency "bundler", ">= 1"
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
27
|
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "rspec_junit_formatter"
|
28
29
|
spec.add_development_dependency "rubocop"
|
29
30
|
spec.add_development_dependency "pry"
|
30
31
|
spec.add_development_dependency "appraisal"
|
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.3.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: 2022-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1
|
33
|
+
version: '1'
|
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
|
-
version: '1
|
40
|
+
version: '1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec_junit_formatter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rubocop
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,11 +143,11 @@ executables: []
|
|
129
143
|
extensions: []
|
130
144
|
extra_rdoc_files: []
|
131
145
|
files:
|
146
|
+
- ".circleci/config.yml"
|
132
147
|
- ".codeclimate.yml"
|
133
148
|
- ".gitignore"
|
134
149
|
- ".rspec"
|
135
150
|
- ".rubocop.yml"
|
136
|
-
- ".travis.yml"
|
137
151
|
- Appraisals
|
138
152
|
- CODE_OF_CONDUCT.md
|
139
153
|
- Gemfile
|
@@ -167,11 +181,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
167
181
|
version: '0'
|
168
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
183
|
requirements:
|
170
|
-
- - "
|
184
|
+
- - ">="
|
171
185
|
- !ruby/object:Gem::Version
|
172
|
-
version:
|
186
|
+
version: '0'
|
173
187
|
requirements: []
|
174
|
-
rubygems_version: 3.0.3
|
188
|
+
rubygems_version: 3.0.3.1
|
175
189
|
signing_key:
|
176
190
|
specification_version: 4
|
177
191
|
summary: retry rspec one target `expect`
|
data/.travis.yml
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.2.10
|
5
|
-
- 2.3.8
|
6
|
-
- 2.4.5
|
7
|
-
- 2.5.3
|
8
|
-
gemfile:
|
9
|
-
- gemfiles/rspec_33x.gemfile
|
10
|
-
- gemfiles/rspec_34x.gemfile
|
11
|
-
- gemfiles/rspec_35x.gemfile
|
12
|
-
- gemfiles/rspec_36x.gemfile
|
13
|
-
- gemfiles/rspec_37x.gemfile
|
14
|
-
- gemfiles/rspec_38x.gemfile
|
15
|
-
branches:
|
16
|
-
only:
|
17
|
-
- master
|
18
|
-
before_install:
|
19
|
-
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
20
|
-
- gem install bundler -v '< 2'
|
21
|
-
before_script:
|
22
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
23
|
-
- chmod +x ./cc-test-reporter
|
24
|
-
- ./cc-test-reporter before-build
|
25
|
-
script:
|
26
|
-
- bundle exec rspec spec
|
27
|
-
- rubocop
|
28
|
-
after_script:
|
29
|
-
- |
|
30
|
-
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
31
|
-
./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT;
|
32
|
-
fi
|
33
|
-
|