rspec-wait 0.0.9 → 0.0.10
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 +5 -5
- data/lib/rspec/wait/handler.rb +6 -9
- data/lib/rspec/wait/target.rb +15 -10
- data/lib/rspec/wait/version.rb +9 -0
- data/lib/rspec/wait.rb +2 -1
- data/rspec-wait.gemspec +35 -14
- metadata +32 -52
- data/.gitignore +0 -15
- data/.rspec +0 -4
- data/.travis.yml +0 -29
- data/CHANGELOG.md +0 -33
- data/CONTRIBUTING.md +0 -48
- data/Gemfile +0 -3
- data/Rakefile +0 -6
- data/gemfiles/rspec_2_11.gemfile +0 -9
- data/gemfiles/rspec_2_12.gemfile +0 -9
- data/gemfiles/rspec_2_13.gemfile +0 -9
- data/gemfiles/rspec_2_14.gemfile +0 -9
- data/gemfiles/rspec_3_0.gemfile +0 -9
- data/gemfiles/rspec_3_1.gemfile +0 -9
- data/gemfiles/rspec_3_2.gemfile +0 -9
- data/gemfiles/rspec_3_3.gemfile +0 -9
- data/gemfiles/rspec_3_4.gemfile +0 -9
- data/gemfiles/rspec_3_5.gemfile +0 -9
- data/spec/spec_helper.rb +0 -6
- data/spec/wait_for_spec.rb +0 -162
- data/spec/wait_spec.rb +0 -176
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 51f26caeca0b3d18669805db3143077ac97f408e129fbd36c2bc8d5dac9bb709
|
4
|
+
data.tar.gz: b7a60846e5c5459e75acb628f10e8daaf2a1276fbb15956d32a90dc64f9b5474
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8ff555f454d246bb4412ba9197e3bd3ddde4609cfe82d1fc0bff50578f9fe86e756b23fd208fa914da4dba49e7cb72cf307d9be334317a88b1833eb3313ab84
|
7
|
+
data.tar.gz: 8ad28a71663a471032f65912731c3081bc96c84007385354312931595d126db14c9da0bf2139a63d8ec3f3eb707b495efb57932d681db949c0ac4eaa942e7c87
|
data/lib/rspec/wait/handler.rb
CHANGED
@@ -7,15 +7,12 @@ module RSpec
|
|
7
7
|
failure = nil
|
8
8
|
|
9
9
|
Timeout.timeout(RSpec.configuration.wait_timeout) do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
sleep RSpec.configuration.wait_delay
|
17
|
-
retry
|
18
|
-
end
|
10
|
+
begin
|
11
|
+
actual = target.respond_to?(:call) ? target.call : target
|
12
|
+
super(actual, *args, &block)
|
13
|
+
rescue RSpec::Expectations::ExpectationNotMetError => failure
|
14
|
+
sleep RSpec.configuration.wait_delay
|
15
|
+
retry
|
19
16
|
end
|
20
17
|
end
|
21
18
|
rescue Timeout::Error
|
data/lib/rspec/wait/target.rb
CHANGED
@@ -7,13 +7,14 @@ module RSpec
|
|
7
7
|
# From: https://github.com/rspec/rspec-expectations/blob/v3.0.0/lib/rspec/expectations/expectation_target.rb#L30-L41
|
8
8
|
def self.for(value, block, options = {})
|
9
9
|
if UndefinedValue.equal?(value)
|
10
|
-
unless block
|
11
|
-
|
12
|
-
end
|
10
|
+
raise ArgumentError, "You must pass either an argument or a block to `wait_for`." unless block
|
11
|
+
|
13
12
|
new(block, options)
|
14
13
|
elsif block
|
15
14
|
raise ArgumentError, "You cannot pass both an argument and a block to `wait_for`."
|
16
15
|
else
|
16
|
+
warn "[DEPRECATION] As of rspec-wait version 1.0, " \
|
17
|
+
"neither wait_for nor wait.for will accept an argument, only a block."
|
17
18
|
new(value, options)
|
18
19
|
end
|
19
20
|
end
|
@@ -26,22 +27,26 @@ module RSpec
|
|
26
27
|
|
27
28
|
# From: https://github.com/rspec/rspec-expectations/blob/v3.0.0/lib/rspec/expectations/expectation_target.rb#L53-L54
|
28
29
|
def to(matcher = nil, message = nil, &block)
|
29
|
-
prevent_operator_matchers(:to
|
30
|
-
with_wait
|
30
|
+
prevent_operator_matchers(:to) unless matcher
|
31
|
+
with_wait do
|
32
|
+
PositiveHandler.handle_matcher(@target, matcher, message, &block)
|
33
|
+
end
|
31
34
|
end
|
32
35
|
|
33
36
|
# From: https://github.com/rspec/rspec-expectations/blob/v3.0.0/lib/rspec/expectations/expectation_target.rb#L66-L67
|
34
37
|
def not_to(matcher = nil, message = nil, &block)
|
35
|
-
prevent_operator_matchers(:not_to
|
36
|
-
with_wait
|
38
|
+
prevent_operator_matchers(:not_to) unless matcher
|
39
|
+
with_wait do
|
40
|
+
NegativeHandler.handle_matcher(@target, matcher, message, &block)
|
41
|
+
end
|
37
42
|
end
|
38
43
|
|
39
|
-
|
44
|
+
alias to_not not_to
|
40
45
|
|
41
46
|
private
|
42
47
|
|
43
|
-
def with_wait
|
44
|
-
Wait.with_wait(@wait_options)
|
48
|
+
def with_wait(&block)
|
49
|
+
Wait.with_wait(@wait_options, &block)
|
45
50
|
end
|
46
51
|
end
|
47
52
|
end
|
data/lib/rspec/wait.rb
CHANGED
@@ -3,6 +3,7 @@ require "rspec/wait/error"
|
|
3
3
|
require "rspec/wait/handler"
|
4
4
|
require "rspec/wait/proxy"
|
5
5
|
require "rspec/wait/target"
|
6
|
+
require "rspec/wait/version"
|
6
7
|
|
7
8
|
module RSpec
|
8
9
|
module Wait
|
@@ -40,7 +41,7 @@ RSpec.configure do |config|
|
|
40
41
|
config.add_setting(:wait_delay, default: 0.1)
|
41
42
|
|
42
43
|
config.around do |example|
|
43
|
-
if options = example.metadata[:wait]
|
44
|
+
if (options = example.metadata[:wait])
|
44
45
|
with_wait(options) { example.run }
|
45
46
|
else
|
46
47
|
example.run
|
data/rspec-wait.gemspec
CHANGED
@@ -1,21 +1,42 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/rspec/wait/version"
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
4
|
-
spec.name
|
5
|
-
spec.
|
6
|
+
spec.name = "rspec-wait"
|
7
|
+
spec.summary = "Wait for conditions in RSpec"
|
8
|
+
spec.description = "RSpec::Wait enables time-resilient expectations in your RSpec test suite."
|
9
|
+
spec.version = RSpec::Wait::VERSION
|
10
|
+
|
11
|
+
spec.author = "Steve Richert"
|
12
|
+
spec.email = "steve.richert@hey.com"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.homepage = "https://github.com/laserlemon/rspec-wait"
|
15
|
+
|
16
|
+
spec.metadata = {
|
17
|
+
"allowed_push_host" => "https://rubygems.org",
|
18
|
+
"bug_tracker_uri" => "https://github.com/laserlemon/rspec-wait/issues",
|
19
|
+
"funding_uri" => "https://github.com/sponsors/laserlemon",
|
20
|
+
"homepage_uri" => "https://github.com/laserlemon/rspec-wait",
|
21
|
+
"rubygems_mfa_required" => "true",
|
22
|
+
"source_code_uri" => "https://github.com/laserlemon/rspec-wait",
|
23
|
+
}
|
6
24
|
|
7
|
-
spec.
|
8
|
-
spec.
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.homepage = "https://github.com/laserlemon/rspec-wait"
|
12
|
-
spec.license = "MIT"
|
25
|
+
spec.required_ruby_version = ">= 2.2"
|
26
|
+
spec.add_dependency "rspec", ">= 3.0"
|
27
|
+
spec.add_development_dependency "bundler"
|
28
|
+
spec.add_development_dependency "rake"
|
13
29
|
|
14
|
-
spec.files
|
15
|
-
|
30
|
+
spec.files = Dir.glob([
|
31
|
+
"rspec-wait.gemspec",
|
32
|
+
"lib/**/*.rb",
|
33
|
+
"LICENSE.txt",
|
34
|
+
])
|
16
35
|
|
17
|
-
spec.
|
36
|
+
spec.extra_rdoc_files = ["README.md"]
|
18
37
|
|
19
|
-
spec.
|
20
|
-
|
38
|
+
spec.post_install_message = <<-MSG
|
39
|
+
[rspec-wait] RSpec::Wait 1.0 has arrived! Please upgrade for the latest and greatest.
|
40
|
+
[rspec-wait] See what's changed here: https://github.com/laserlemon/rspec-wait/blob/-/CHANGELOG.md
|
41
|
+
MSG
|
21
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-wait
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Richert
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,87 +16,71 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '4'
|
19
|
+
version: '3.0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '3'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '4'
|
26
|
+
version: '3.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: bundler
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
|
-
- - "
|
31
|
+
- - ">="
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
33
|
+
version: '0'
|
40
34
|
type: :development
|
41
35
|
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
|
-
- - "
|
38
|
+
- - ">="
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
40
|
+
version: '0'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: rake
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
|
-
- - "
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
|
-
- - "
|
52
|
+
- - ">="
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
61
|
-
description: Wait
|
62
|
-
email: steve.richert@
|
54
|
+
version: '0'
|
55
|
+
description: RSpec::Wait enables time-resilient expectations in your RSpec test suite.
|
56
|
+
email: steve.richert@hey.com
|
63
57
|
executables: []
|
64
58
|
extensions: []
|
65
|
-
extra_rdoc_files:
|
59
|
+
extra_rdoc_files:
|
60
|
+
- README.md
|
66
61
|
files:
|
67
|
-
- ".gitignore"
|
68
|
-
- ".rspec"
|
69
|
-
- ".travis.yml"
|
70
|
-
- CHANGELOG.md
|
71
|
-
- CONTRIBUTING.md
|
72
|
-
- Gemfile
|
73
62
|
- LICENSE.txt
|
74
63
|
- README.md
|
75
|
-
- Rakefile
|
76
|
-
- gemfiles/rspec_2_11.gemfile
|
77
|
-
- gemfiles/rspec_2_12.gemfile
|
78
|
-
- gemfiles/rspec_2_13.gemfile
|
79
|
-
- gemfiles/rspec_2_14.gemfile
|
80
|
-
- gemfiles/rspec_3_0.gemfile
|
81
|
-
- gemfiles/rspec_3_1.gemfile
|
82
|
-
- gemfiles/rspec_3_2.gemfile
|
83
|
-
- gemfiles/rspec_3_3.gemfile
|
84
|
-
- gemfiles/rspec_3_4.gemfile
|
85
|
-
- gemfiles/rspec_3_5.gemfile
|
86
64
|
- lib/rspec/wait.rb
|
87
65
|
- lib/rspec/wait/error.rb
|
88
66
|
- lib/rspec/wait/handler.rb
|
89
67
|
- lib/rspec/wait/proxy.rb
|
90
68
|
- lib/rspec/wait/target.rb
|
69
|
+
- lib/rspec/wait/version.rb
|
91
70
|
- rspec-wait.gemspec
|
92
|
-
- spec/spec_helper.rb
|
93
|
-
- spec/wait_for_spec.rb
|
94
|
-
- spec/wait_spec.rb
|
95
71
|
homepage: https://github.com/laserlemon/rspec-wait
|
96
72
|
licenses:
|
97
73
|
- MIT
|
98
|
-
metadata:
|
99
|
-
|
74
|
+
metadata:
|
75
|
+
allowed_push_host: https://rubygems.org
|
76
|
+
bug_tracker_uri: https://github.com/laserlemon/rspec-wait/issues
|
77
|
+
funding_uri: https://github.com/sponsors/laserlemon
|
78
|
+
homepage_uri: https://github.com/laserlemon/rspec-wait
|
79
|
+
rubygems_mfa_required: 'true'
|
80
|
+
source_code_uri: https://github.com/laserlemon/rspec-wait
|
81
|
+
post_install_message: |
|
82
|
+
[rspec-wait] RSpec::Wait 1.0 has arrived! Please upgrade for the latest and greatest.
|
83
|
+
[rspec-wait] See what's changed here: https://github.com/laserlemon/rspec-wait/blob/-/CHANGELOG.md
|
100
84
|
rdoc_options: []
|
101
85
|
require_paths:
|
102
86
|
- lib
|
@@ -104,19 +88,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
88
|
requirements:
|
105
89
|
- - ">="
|
106
90
|
- !ruby/object:Gem::Version
|
107
|
-
version: '
|
91
|
+
version: '2.2'
|
108
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
93
|
requirements:
|
110
94
|
- - ">="
|
111
95
|
- !ruby/object:Gem::Version
|
112
96
|
version: '0'
|
113
97
|
requirements: []
|
114
|
-
|
115
|
-
|
116
|
-
signing_key:
|
98
|
+
rubygems_version: 3.4.10
|
99
|
+
signing_key:
|
117
100
|
specification_version: 4
|
118
101
|
summary: Wait for conditions in RSpec
|
119
|
-
test_files:
|
120
|
-
- spec/spec_helper.rb
|
121
|
-
- spec/wait_for_spec.rb
|
122
|
-
- spec/wait_spec.rb
|
102
|
+
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
before_install:
|
2
|
-
- gem update bundler rake
|
3
|
-
branches:
|
4
|
-
only:
|
5
|
-
- master
|
6
|
-
cache: bundler
|
7
|
-
env:
|
8
|
-
global:
|
9
|
-
- secure: | # CODECLIMATE_REPO_TOKEN
|
10
|
-
lK3tYDk/63jRamEfGKbC27mPAoV7XsebCurx6doeisv1r4926lyPY4B9ZoSu
|
11
|
-
OeVmjXQWHX9U7IgPH1C+zoIh1wVHVA8h5FVuqlGUMlA6IJi2xaI+ChEo3WeD
|
12
|
-
FRlk1Q5fGhgp1mt59sMn3GZZ/mv31v+sd9iYC3AVIM0KrlMGGZQ=
|
13
|
-
gemfile:
|
14
|
-
- gemfiles/rspec_3_0.gemfile
|
15
|
-
- gemfiles/rspec_3_1.gemfile
|
16
|
-
- gemfiles/rspec_3_2.gemfile
|
17
|
-
- gemfiles/rspec_3_3.gemfile
|
18
|
-
- gemfiles/rspec_3_4.gemfile
|
19
|
-
- gemfiles/rspec_3_5.gemfile
|
20
|
-
language: ruby
|
21
|
-
matrix:
|
22
|
-
allow_failures:
|
23
|
-
- rvm: ruby-head
|
24
|
-
rvm:
|
25
|
-
- 2.1.10
|
26
|
-
- 2.2.5
|
27
|
-
- 2.3.1
|
28
|
-
- ruby-head
|
29
|
-
sudo: false
|
data/CHANGELOG.md
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
## 0.0.8 / 2015-11-14
|
2
|
-
|
3
|
-
* [ENHANCEMENT] Add support for RSpec 3.4
|
4
|
-
|
5
|
-
## 0.0.7 / 2015-06-16
|
6
|
-
|
7
|
-
* [ENHANCEMENT] Add support for RSpec 3.3
|
8
|
-
|
9
|
-
## 0.0.6 / 2015-06-12
|
10
|
-
|
11
|
-
* [BUGFIX] Fix the `to_not` alias in cases where the condition is not met
|
12
|
-
|
13
|
-
## 0.0.5 / 2015-01-04
|
14
|
-
|
15
|
-
* [ENHANCEMENT] Add support for RSpec 3.2
|
16
|
-
|
17
|
-
## 0.0.4 / 2014-12-18
|
18
|
-
|
19
|
-
* [FEATURE] Make RSpec::Wait's timeout and delay values configurable
|
20
|
-
* [FEATURE] Add the wait(3.seconds).for { something }.to(happen) syntax sugar
|
21
|
-
|
22
|
-
## 0.0.3 / 2014-10-29
|
23
|
-
|
24
|
-
* [ENHANCEMENT] Add support for RSpec 3.1
|
25
|
-
|
26
|
-
## 0.0.2 / 2014-06-11
|
27
|
-
|
28
|
-
* [ENHANCEMENT] Allow `wait_for` to accept either a value or block target
|
29
|
-
* [BUGFIX] Ensure blocks are re-evaluated with each iteration
|
30
|
-
|
31
|
-
## 0.0.1 / 2014-04-19
|
32
|
-
|
33
|
-
* Initial release!
|
data/CONTRIBUTING.md
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# Contributing to RSpec::Wait
|
2
|
-
|
3
|
-
RSpec::Wait is open source and contributions from the community are encouraged!
|
4
|
-
No contribution is too small.
|
5
|
-
|
6
|
-
Please consider:
|
7
|
-
|
8
|
-
* Adding a feature
|
9
|
-
* Squashing a bug
|
10
|
-
* Writing documentation
|
11
|
-
* Fixing a typo
|
12
|
-
* Correcting [style](https://github.com/styleguide/ruby)
|
13
|
-
|
14
|
-
## How do I contribute?
|
15
|
-
|
16
|
-
For the best chance of having your changes merged, please:
|
17
|
-
|
18
|
-
1. [Fork](https://github.com/laserlemon/rspec-wait/fork) the project.
|
19
|
-
2. [Write](http://en.wikipedia.org/wiki/Test-driven_development) a failing test.
|
20
|
-
3. [Commit](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) changes that fix the tests.
|
21
|
-
4. [Submit](https://github.com/laserlemon/rspec-wait/pulls) a pull request with *at least* one animated GIF.
|
22
|
-
5. Be patient.
|
23
|
-
|
24
|
-
If your proposed changes only affect documentation, include the following on a
|
25
|
-
new line in each of your commit messages:
|
26
|
-
|
27
|
-
```
|
28
|
-
[ci skip]
|
29
|
-
```
|
30
|
-
|
31
|
-
This will signal [Travis](https://travis-ci.org) that running the test suite is
|
32
|
-
not necessary for these changes.
|
33
|
-
|
34
|
-
## Bug Reports
|
35
|
-
|
36
|
-
If you are experiencing unexpected behavior and, after having read RSpec::Wait's
|
37
|
-
documentation, are convinced this behavior is a bug, please:
|
38
|
-
|
39
|
-
1. [Search](https://github.com/laserlemon/rspec-wait/issues) existing issues.
|
40
|
-
2. Collect enough information to reproduce the issue:
|
41
|
-
* RSpec::Wait version
|
42
|
-
* Ruby version
|
43
|
-
* RSpec version
|
44
|
-
* Specific setup conditions
|
45
|
-
* Description of expected behavior
|
46
|
-
* Description of actual behavior
|
47
|
-
3. [Submit](https://github.com/laserlemon/rspec-wait/issues/new) an issue.
|
48
|
-
4. Be patient.
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/gemfiles/rspec_2_11.gemfile
DELETED
data/gemfiles/rspec_2_12.gemfile
DELETED
data/gemfiles/rspec_2_13.gemfile
DELETED
data/gemfiles/rspec_2_14.gemfile
DELETED
data/gemfiles/rspec_3_0.gemfile
DELETED
data/gemfiles/rspec_3_1.gemfile
DELETED
data/gemfiles/rspec_3_2.gemfile
DELETED
data/gemfiles/rspec_3_3.gemfile
DELETED
data/gemfiles/rspec_3_4.gemfile
DELETED
data/gemfiles/rspec_3_5.gemfile
DELETED
data/spec/spec_helper.rb
DELETED
data/spec/wait_for_spec.rb
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
describe "wait_for" do
|
2
|
-
let!(:progress) { "" }
|
3
|
-
|
4
|
-
before do
|
5
|
-
Thread.new do
|
6
|
-
2.times do
|
7
|
-
sleep 1
|
8
|
-
progress << "."
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
context "to" do
|
14
|
-
it "passes immediately" do
|
15
|
-
expect {
|
16
|
-
wait_for { progress }.to eq("")
|
17
|
-
}.not_to raise_error
|
18
|
-
end
|
19
|
-
|
20
|
-
it "waits for the matcher to pass" do
|
21
|
-
expect {
|
22
|
-
wait_for { progress }.to eq(".")
|
23
|
-
}.not_to raise_error
|
24
|
-
end
|
25
|
-
|
26
|
-
it "re-evaluates the actual value" do
|
27
|
-
expect {
|
28
|
-
wait_for { progress.dup }.to eq(".")
|
29
|
-
}.not_to raise_error
|
30
|
-
end
|
31
|
-
|
32
|
-
it "fails if the matcher never passes" do
|
33
|
-
expect {
|
34
|
-
wait_for { progress }.to eq("...")
|
35
|
-
}.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "times out if the block never finishes" do
|
39
|
-
expect {
|
40
|
-
wait_for { sleep 11; progress }.to eq("..")
|
41
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "respects a timeout specified in configuration" do
|
45
|
-
original_timeout = RSpec.configuration.wait_timeout
|
46
|
-
RSpec.configuration.wait_timeout = 3
|
47
|
-
|
48
|
-
begin
|
49
|
-
expect {
|
50
|
-
wait_for { sleep 4; progress }.to eq("..")
|
51
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
52
|
-
ensure
|
53
|
-
RSpec.configuration.wait_timeout = original_timeout
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
it "respects a timeout specified in options", wait: { timeout: 3 } do
|
58
|
-
expect {
|
59
|
-
wait_for { sleep 4; progress }.to eq("..")
|
60
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "raises an error occuring in the block" do
|
64
|
-
expect {
|
65
|
-
wait_for { raise RuntimeError }.to eq("..")
|
66
|
-
}.to raise_error(RuntimeError)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "prevents operator matchers" do
|
70
|
-
expect {
|
71
|
-
wait_for { progress }.to == "."
|
72
|
-
}.to raise_error(ArgumentError)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "accepts a value rather than a block" do
|
76
|
-
expect {
|
77
|
-
wait_for(progress).to eq(".")
|
78
|
-
}.not_to raise_error
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context "not_to" do
|
83
|
-
it "passes immediately" do
|
84
|
-
expect {
|
85
|
-
wait_for { progress }.not_to eq("..")
|
86
|
-
}.not_to raise_error
|
87
|
-
end
|
88
|
-
|
89
|
-
it "waits for the matcher not to pass" do
|
90
|
-
expect {
|
91
|
-
wait_for { progress }.not_to eq("")
|
92
|
-
}.not_to raise_error
|
93
|
-
end
|
94
|
-
|
95
|
-
it "re-evaluates the actual value" do
|
96
|
-
expect {
|
97
|
-
wait_for { progress.dup }.not_to eq("")
|
98
|
-
}.not_to raise_error
|
99
|
-
end
|
100
|
-
|
101
|
-
it "fails if the matcher always passes" do
|
102
|
-
expect {
|
103
|
-
wait_for { progress }.not_to be_a(String)
|
104
|
-
}.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
105
|
-
end
|
106
|
-
|
107
|
-
it "times out if the block never finishes" do
|
108
|
-
expect {
|
109
|
-
wait_for { sleep 11; progress }.not_to eq("..")
|
110
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
111
|
-
end
|
112
|
-
|
113
|
-
it "respects a timeout specified in configuration" do
|
114
|
-
original_timeout = RSpec.configuration.wait_timeout
|
115
|
-
RSpec.configuration.wait_timeout = 3
|
116
|
-
|
117
|
-
begin
|
118
|
-
expect {
|
119
|
-
wait_for { sleep 4; progress }.not_to eq("..")
|
120
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
121
|
-
ensure
|
122
|
-
RSpec.configuration.wait_timeout = original_timeout
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
it "respects a timeout specified in options", wait: { timeout: 3 } do
|
127
|
-
expect {
|
128
|
-
wait_for { sleep 4; progress }.not_to eq("..")
|
129
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
130
|
-
end
|
131
|
-
|
132
|
-
it "raises an error occuring in the block" do
|
133
|
-
expect {
|
134
|
-
wait_for { raise RuntimeError }.not_to eq("")
|
135
|
-
}.to raise_error(RuntimeError)
|
136
|
-
end
|
137
|
-
|
138
|
-
it "respects the to_not alias when expectation is met" do
|
139
|
-
expect {
|
140
|
-
wait_for { true }.to_not eq(false)
|
141
|
-
}.not_to raise_error
|
142
|
-
end
|
143
|
-
|
144
|
-
it "respects the to_not alias when expectation is not met" do
|
145
|
-
expect {
|
146
|
-
wait_for { true }.to_not eq(true)
|
147
|
-
}.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
148
|
-
end
|
149
|
-
|
150
|
-
it "prevents operator matchers" do
|
151
|
-
expect {
|
152
|
-
wait_for { progress }.not_to == ".."
|
153
|
-
}.to raise_error(ArgumentError)
|
154
|
-
end
|
155
|
-
|
156
|
-
it "accepts a value rather than a block" do
|
157
|
-
expect {
|
158
|
-
wait_for(progress).not_to eq("..")
|
159
|
-
}.not_to raise_error
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
data/spec/wait_spec.rb
DELETED
@@ -1,176 +0,0 @@
|
|
1
|
-
describe "wait" do
|
2
|
-
let!(:progress) { "" }
|
3
|
-
|
4
|
-
before do
|
5
|
-
Thread.new do
|
6
|
-
2.times do
|
7
|
-
sleep 1
|
8
|
-
progress << "."
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
context "for" do
|
14
|
-
context "to" do
|
15
|
-
it "passes immediately" do
|
16
|
-
expect {
|
17
|
-
wait.for { progress }.to eq("")
|
18
|
-
}.not_to raise_error
|
19
|
-
end
|
20
|
-
|
21
|
-
it "waits for the matcher to pass" do
|
22
|
-
expect {
|
23
|
-
wait.for { progress }.to eq(".")
|
24
|
-
}.not_to raise_error
|
25
|
-
end
|
26
|
-
|
27
|
-
it "re-evaluates the actual value" do
|
28
|
-
expect {
|
29
|
-
wait.for { progress.dup }.to eq(".")
|
30
|
-
}.not_to raise_error
|
31
|
-
end
|
32
|
-
|
33
|
-
it "fails if the matcher never passes" do
|
34
|
-
expect {
|
35
|
-
wait.for { progress }.to eq("...")
|
36
|
-
}.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "times out if the block never finishes" do
|
40
|
-
expect {
|
41
|
-
wait.for { sleep 11; progress }.to eq("..")
|
42
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "respects a timeout specified in configuration" do
|
46
|
-
original_timeout = RSpec.configuration.wait_timeout
|
47
|
-
RSpec.configuration.wait_timeout = 3
|
48
|
-
|
49
|
-
begin
|
50
|
-
expect {
|
51
|
-
wait.for { sleep 4; progress }.to eq("..")
|
52
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
53
|
-
ensure
|
54
|
-
RSpec.configuration.wait_timeout = original_timeout
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it "respects a timeout specified in options", wait: { timeout: 3 } do
|
59
|
-
expect {
|
60
|
-
wait.for { sleep 4; progress }.to eq("..")
|
61
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "respects a timeout specified as an argument" do
|
65
|
-
expect {
|
66
|
-
wait(3).for { sleep 4; progress }.to eq("..")
|
67
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
68
|
-
end
|
69
|
-
|
70
|
-
it "raises an error occuring in the block" do
|
71
|
-
expect {
|
72
|
-
wait.for { raise RuntimeError }.to eq("..")
|
73
|
-
}.to raise_error(RuntimeError)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "prevents operator matchers" do
|
77
|
-
expect {
|
78
|
-
wait.for { progress }.to == "."
|
79
|
-
}.to raise_error(ArgumentError)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "accepts a value rather than a block" do
|
83
|
-
expect {
|
84
|
-
wait.for(progress).to eq(".")
|
85
|
-
}.not_to raise_error
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context "not_to" do
|
90
|
-
it "passes immediately" do
|
91
|
-
expect {
|
92
|
-
wait.for { progress }.not_to eq("..")
|
93
|
-
}.not_to raise_error
|
94
|
-
end
|
95
|
-
|
96
|
-
it "waits for the matcher not to pass" do
|
97
|
-
expect {
|
98
|
-
wait.for { progress }.not_to eq("")
|
99
|
-
}.not_to raise_error
|
100
|
-
end
|
101
|
-
|
102
|
-
it "re-evaluates the actual value" do
|
103
|
-
expect {
|
104
|
-
wait.for { progress.dup }.not_to eq("")
|
105
|
-
}.not_to raise_error
|
106
|
-
end
|
107
|
-
|
108
|
-
it "fails if the matcher always passes" do
|
109
|
-
expect {
|
110
|
-
wait.for { progress }.not_to be_a(String)
|
111
|
-
}.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
112
|
-
end
|
113
|
-
|
114
|
-
it "times out if the block never finishes" do
|
115
|
-
expect {
|
116
|
-
wait.for { sleep 11; progress }.not_to eq("..")
|
117
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
118
|
-
end
|
119
|
-
|
120
|
-
it "respects a timeout specified in configuration" do
|
121
|
-
original_timeout = RSpec.configuration.wait_timeout
|
122
|
-
RSpec.configuration.wait_timeout = 3
|
123
|
-
|
124
|
-
begin
|
125
|
-
expect {
|
126
|
-
wait.for { sleep 4; progress }.not_to eq("..")
|
127
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
128
|
-
ensure
|
129
|
-
RSpec.configuration.wait_timeout = original_timeout
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
it "respects a timeout specified in options", wait: { timeout: 3 } do
|
134
|
-
expect {
|
135
|
-
wait.for { sleep 4; progress }.not_to eq("..")
|
136
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
137
|
-
end
|
138
|
-
|
139
|
-
it "respects a timeout specified as an argument" do
|
140
|
-
expect {
|
141
|
-
wait(3).for { sleep 4; progress }.not_to eq("..")
|
142
|
-
}.to raise_error(RSpec::Wait::TimeoutError)
|
143
|
-
end
|
144
|
-
|
145
|
-
it "raises an error occuring in the block" do
|
146
|
-
expect {
|
147
|
-
wait.for { raise RuntimeError }.not_to eq("")
|
148
|
-
}.to raise_error(RuntimeError)
|
149
|
-
end
|
150
|
-
|
151
|
-
it "respects the to_not alias when expectation is met" do
|
152
|
-
expect {
|
153
|
-
wait(1).for { true }.to_not eq(false)
|
154
|
-
}.not_to raise_error
|
155
|
-
end
|
156
|
-
|
157
|
-
it "respects the to_not alias when expectation is not met" do
|
158
|
-
expect {
|
159
|
-
wait(1).for { true }.to_not eq(true)
|
160
|
-
}.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
161
|
-
end
|
162
|
-
|
163
|
-
it "prevents operator matchers" do
|
164
|
-
expect {
|
165
|
-
wait.for { progress }.not_to == ".."
|
166
|
-
}.to raise_error(ArgumentError)
|
167
|
-
end
|
168
|
-
|
169
|
-
it "accepts a value rather than a block" do
|
170
|
-
expect {
|
171
|
-
wait.for(progress).not_to eq("..")
|
172
|
-
}.not_to raise_error
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|