rspec-retry 0.2.1 → 0.3.0
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 +7 -0
- data/README.md +4 -0
- data/lib/rspec/retry.rb +16 -7
- data/lib/rspec/retry/version.rb +1 -1
- data/spec/lib/rspec/retry_spec.rb +1 -1
- metadata +13 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f84a3f3775b6c16acbc11baa98c1920f6465dd6
|
4
|
+
data.tar.gz: bf3b2b1fb8d7173d336c68987f29a4b8927a40bf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 97b01e500f2413ddcb66c94abc0b168dbace57d96685f76540f5d6ca443bbed7b673261165e052cb432ba80e40cd79ec3007e5136c12905295d96ea2e125eb26
|
7
|
+
data.tar.gz: 76c096d54dac36b2383acfb7fac67222f5eb481cfd15af1193c1c23407e9b9960e552a20f678acde34ebc5021da7a98d0f238ab3c8bb67d7419593cb32ac868d
|
data/README.md
CHANGED
@@ -36,6 +36,9 @@ it 'should randomly success', :retry => 3 do
|
|
36
36
|
rand(2).should == 1
|
37
37
|
end
|
38
38
|
|
39
|
+
it 'should succeed after a while', :retry => 3, :retry_wait=>10 do
|
40
|
+
command('service myservice status').should == 'started'
|
41
|
+
end
|
39
42
|
# run spec (following log is shown if verbose_retry options is true)
|
40
43
|
# RSpec::Retry: 2nd try ./spec/lib/random_spec.rb:49
|
41
44
|
# RSpec::Retry: 3rd try ./spec/lib/random_spec.rb:49
|
@@ -45,6 +48,7 @@ end
|
|
45
48
|
|
46
49
|
- __:verbose_retry__(default: *false*) Print retry status
|
47
50
|
- __:default_retry_count__(default: *1*) If retry count is not set in example, this value is used by default
|
51
|
+
- __:retry_wait__(default: *0*) Seconds to wait between retries
|
48
52
|
- __:clear_lets_on_failure__(default: *true*) Clear memoized value for ``let`` before retrying
|
49
53
|
|
50
54
|
## Contributing
|
data/lib/rspec/retry.rb
CHANGED
@@ -8,28 +8,37 @@ module RSpec
|
|
8
8
|
RSpec.configure do |config|
|
9
9
|
config.add_setting :verbose_retry, :default => false
|
10
10
|
config.add_setting :default_retry_count, :default => 1
|
11
|
+
config.add_setting :default_sleep_interval, :default => 0
|
11
12
|
config.add_setting :clear_lets_on_failure, :default => true
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
# context.example is deprecated, but RSpec.current_example is not
|
15
|
+
# available until RSpec 3.0.
|
16
|
+
fetch_current_example = RSpec.respond_to?(:current_example) ?
|
17
|
+
proc { RSpec.current_example } : proc { |context| context.example }
|
15
18
|
|
16
|
-
|
19
|
+
config.around(:each) do |ex|
|
20
|
+
example = fetch_current_example.call(self)
|
21
|
+
retry_count = ex.metadata[:retry] || RSpec.configuration.default_retry_count
|
22
|
+
sleep_interval = ex.metadata[:retry_wait] || RSpec.configuration.default_sleep_interval
|
23
|
+
|
24
|
+
clear_lets = ex.metadata[:clear_lets_on_failure]
|
17
25
|
clear_lets = RSpec.configuration.clear_lets_on_failure if clear_lets.nil?
|
18
26
|
|
19
27
|
retry_count.times do |i|
|
20
28
|
if RSpec.configuration.verbose_retry?
|
21
29
|
if i > 0
|
22
|
-
message = "RSpec::Retry: #{RSpec::Retry.ordinalize(i + 1)} try #{
|
30
|
+
message = "RSpec::Retry: #{RSpec::Retry.ordinalize(i + 1)} try #{example.location}"
|
23
31
|
message = "\n" + message if i == 1
|
24
32
|
RSpec.configuration.reporter.message(message)
|
25
33
|
end
|
26
34
|
end
|
27
|
-
|
28
|
-
|
35
|
+
example.clear_exception
|
36
|
+
ex.run
|
29
37
|
|
30
|
-
break if
|
38
|
+
break if example.exception.nil?
|
31
39
|
|
32
40
|
self.clear_lets if clear_lets
|
41
|
+
sleep sleep_interval if sleep_interval.to_i > 0
|
33
42
|
end
|
34
43
|
end
|
35
44
|
end
|
data/lib/rspec/retry/version.rb
CHANGED
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-retry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Yusuke Mito
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-23 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: guard-rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: pry-debugger
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: retry randomly failing example
|
@@ -80,27 +73,26 @@ files:
|
|
80
73
|
- spec/spec_helper.rb
|
81
74
|
homepage: http://github.com/y310/rspec-retry
|
82
75
|
licenses: []
|
76
|
+
metadata: {}
|
83
77
|
post_install_message:
|
84
78
|
rdoc_options: []
|
85
79
|
require_paths:
|
86
80
|
- lib
|
87
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
82
|
requirements:
|
90
|
-
- -
|
83
|
+
- - '>='
|
91
84
|
- !ruby/object:Gem::Version
|
92
85
|
version: '0'
|
93
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
87
|
requirements:
|
96
|
-
- -
|
88
|
+
- - '>='
|
97
89
|
- !ruby/object:Gem::Version
|
98
90
|
version: '0'
|
99
91
|
requirements: []
|
100
92
|
rubyforge_project:
|
101
|
-
rubygems_version:
|
93
|
+
rubygems_version: 2.0.14
|
102
94
|
signing_key:
|
103
|
-
specification_version:
|
95
|
+
specification_version: 4
|
104
96
|
summary: retry randomly failing example
|
105
97
|
test_files:
|
106
98
|
- spec/lib/rspec/retry_spec.rb
|