rspec-retry 0.6.0 → 0.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5bf1468afddcf01b5636087d6a3d439a36a6a8df9c8101215b397bc2bc5684d5
4
- data.tar.gz: 13a446f999361c54a86a5db02ef65893cacad2e80c553bc9bb173a09961c3fd5
3
+ metadata.gz: b497e79a6594a6695a21850042e6a83c85c4db499a3df21c0fd057dffbcf9e10
4
+ data.tar.gz: 21e43954dcb45663a451ba3525ae28c37221eccf3cc7e213960541e2f74ad6b5
5
5
  SHA512:
6
- metadata.gz: fac97737f2346315e373ac932f26442652b32a30dac92eae08edb65053aaad2a0155b0a2043b070c56639487fa0cdea7d15e0ec26e0f80b355a4c439fb6c8b6f
7
- data.tar.gz: 4a75f75b96fac155424b490ae39d252d0d819cc8f45c5e5e6108b6b1ed002bf0fdff159929ee68aa7af113420d69b02bce5c40a6ed5cf6f0cc7b4354f31c3dde
6
+ metadata.gz: 24735a1a4cb83b5b4e11d6e485ef617233ed52cd56ad63413d7cc9c465fe9033e131d2da5e392f038187f33582df18f2fce5bf21b6fdd2ff99ef05c15151b6ec
7
+ data.tar.gz: 1767d99d1578bf9b3bdf41f1db0a10aaa88c088dd14a75fffd63ab44e8413e884173fa37364909eecae88a9f293e0a9dfdd87e10fec498b69e98b434da4e9d6e
data/README.md CHANGED
@@ -8,8 +8,8 @@ specified number of times until the example succeeds.
8
8
 
9
9
  | Rspec Version | Rspec-Retry Version |
10
10
  |---------------|---------------------|
11
- | > 3.8 | 0.6.0 but untested |
12
- | > 3.3, <= 3.8 | 0.6.0             |
11
+ | > 3.8 | 0.6.1 but untested |
12
+ | > 3.3, <= 3.8 | 0.6.1             |
13
13
  | 3.2       | 0.4.6             |
14
14
  | 2.14.8       | 0.4.4             |
15
15
 
@@ -1,6 +1,11 @@
1
+ # 0.6.1 - 2018-06-11
2
+ ## enhancements
3
+ add more flexible method of retrying (thanks @varyform / #48)
4
+ store retry attempts in example metadata (thanks @aeberlin / #43)
5
+
1
6
  # 0.6.0 - 2018-05-15
2
7
  ## enhancements
3
- add exponential backoff option (thanks @patveith, @thedrow / #91, #94, #95)
8
+ add exponential backoff option (thanks @patveith, @thedrow / #91, #94, #95)
4
9
  better documentation (thanks @swrobel / #90)
5
10
 
6
11
  # 0.5.7 - 2018-03-13
@@ -21,7 +26,7 @@ added support for rspec 3.6.0 (thanks @dthorsen / #76)
21
26
 
22
27
  # 0.5.3 - 2017-01-11
23
28
  ## enhancements
24
- printing summary of rspec to output not STDOUT (thanks @trevorcreech / #68)
29
+ printing summary of rspec to output not STDOUT (thanks @trevorcreech / #68)
25
30
  removing some development dependencies
26
31
 
27
32
  # 0.5.2 - 2016-10-03
@@ -38,8 +43,9 @@ drop support for rspec 3.2, added support for 3.4, 3.5
38
43
  # 0.4.6 - 2016-8-8
39
44
  ## bugfixes
40
45
  failure message was off by 1 (thanks @anthonywoo, @vgrigoruk / #57)
46
+
41
47
  ## enhancements
42
- add the `exceptions_to_hard_fail` options (thanks @james-dominy, @ShockwaveNN / #59)
48
+ add the `exceptions_to_hard_fail` options (thanks @james-dominy, @ShockwaveNN / #59)
43
49
  add retry reporter & api for accessing retry from reporter (thanks @tdeo / #54)
44
50
 
45
51
  # 0.4.5 - 2015-11-4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- rspec-retry (0.6.0)
4
+ rspec-retry (0.6.1)
5
5
  rspec-core (> 3.3)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- rspec-retry (0.6.0)
4
+ rspec-retry (0.6.1)
5
5
  rspec-core (> 3.3)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- rspec-retry (0.6.0)
4
+ rspec-retry (0.6.1)
5
5
  rspec-core (> 3.3)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- rspec-retry (0.6.0)
4
+ rspec-retry (0.6.1)
5
5
  rspec-core (> 3.3)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- rspec-retry (0.6.0)
4
+ rspec-retry (0.6.1)
5
5
  rspec-core (> 3.3)
6
6
 
7
7
  GEM
@@ -13,6 +13,9 @@ module RSpec
13
13
  config.add_setting :clear_lets_on_failure, :default => true
14
14
  config.add_setting :display_try_failure_messages, :default => false
15
15
 
16
+ # retry based on example metadata
17
+ config.add_setting :retry_count_condition, :default => ->(_) { nil }
18
+
16
19
  # If a list of exceptions is provided and 'retry' > 1, we only retry if
17
20
  # the exception that was raised by the example is NOT in that list. Otherwise
18
21
  # we ignore the 'retry' value and fail immediately.
@@ -44,11 +47,8 @@ module RSpec
44
47
  current_example.attempts ||= 0
45
48
  end
46
49
 
47
- # context.example is deprecated, but RSpec.current_example is not
48
- # available until RSpec 3.0.
49
50
  def current_example
50
- RSpec.respond_to?(:current_example) ?
51
- RSpec.current_example : @ex.example
51
+ @current_example ||= RSpec.current_example
52
52
  end
53
53
 
54
54
  def retry_count
@@ -56,6 +56,7 @@ module RSpec
56
56
  (
57
57
  ENV['RSPEC_RETRY_RETRY_COUNT'] ||
58
58
  ex.metadata[:retry] ||
59
+ RSpec.configuration.retry_count_condition.call(ex) ||
59
60
  RSpec.configuration.default_retry_count
60
61
  ).to_i,
61
62
  1
@@ -116,6 +117,8 @@ module RSpec
116
117
  end
117
118
  end
118
119
 
120
+ example.metadata[:retry_attempts] = self.attempts
121
+
119
122
  example.clear_exception
120
123
  ex.run
121
124
 
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  class Retry
3
- VERSION = "0.6.0"
3
+ VERSION = "0.6.1"
4
4
  end
5
5
  end
@@ -56,6 +56,15 @@ describe RSpec::Retry do
56
56
  end
57
57
  end
58
58
 
59
+ context 'with lambda condition' do
60
+ before(:all) { set_expectations([false, true]) }
61
+
62
+ it "should get retry count from condition call", retry_me_once: true do
63
+ expect(true).to be(shift_expectation)
64
+ expect(count).to eq(2)
65
+ end
66
+ end
67
+
59
68
  context 'with :retry => 0' do
60
69
  after(:all) { @@this_ran_once = nil }
61
70
  it 'should still run once', retry: 0 do
@@ -124,6 +133,38 @@ describe RSpec::Retry do
124
133
  end
125
134
 
126
135
  describe "with a list of exceptions to retry on", :retry => 2, :exceptions_to_retry => [RetryError] do
136
+ context do
137
+ let(:rspec_version) { RSpec::Core::Version::STRING }
138
+
139
+ let(:example_code) do
140
+ %{
141
+ $count ||= 0
142
+ $count += 1
143
+
144
+ raise NameError unless $count > 2
145
+ }
146
+ end
147
+
148
+ let!(:example_group) do
149
+ $count, $example_code = 0, example_code
150
+
151
+ RSpec.describe("example group", exceptions_to_retry: [NameError], retry: 3).tap do |this|
152
+ this.run # initialize for rspec 3.3+ with no examples
153
+ end
154
+ end
155
+
156
+ let(:retry_attempts) do
157
+ example_group.examples.first.metadata[:retry_attempts]
158
+ end
159
+
160
+ it 'should retry and match attempts metadata' do
161
+ example_group.example { instance_eval($example_code) }
162
+ example_group.run
163
+
164
+ expect(retry_attempts).to eq(2)
165
+ end
166
+ end
167
+
127
168
  context "the example throws an exception contained in the retry list" do
128
169
  it "retries the maximum number of times" do
129
170
  raise RetryError unless count > 1
@@ -22,4 +22,6 @@ RSpec.configure do |config|
22
22
  config.around :each, :overridden do |ex|
23
23
  ex.run_with_retry retry: 3
24
24
  end
25
+
26
+ config.retry_count_condition = ->(example) { example.metadata[:retry_me_once] ? 2 : nil }
25
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-retry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Mito
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-05-15 00:00:00.000000000 Z
12
+ date: 2018-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec-core