rspec-wait 0.0.8 → 1.0.0.rc1
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/LICENSE.txt +17 -18
- data/README.md +143 -32
- data/lib/rspec/wait/handler.rb +25 -17
- data/lib/rspec/wait/proxy.rb +15 -3
- data/lib/rspec/wait/target.rb +23 -29
- data/lib/rspec/wait/version.rb +7 -0
- data/lib/rspec/wait.rb +33 -21
- data/lib/rspec-wait.rb +3 -0
- data/rspec-wait.gemspec +30 -14
- metadata +33 -54
- data/.gitignore +0 -15
- data/.rspec +0 -4
- data/.travis.yml +0 -33
- 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/lib/rspec/wait/error.rb +0 -7
- data/spec/spec_helper.rb +0 -6
- data/spec/wait_for_spec.rb +0 -162
- data/spec/wait_spec.rb +0 -176
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
|