wrong 0.6.3-java → 0.7.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +10 -7
- data/lib/wrong.rb +1 -0
- data/lib/wrong/adapters/rspec.rb +4 -0
- data/lib/wrong/assert.rb +1 -2
- data/lib/wrong/chunk.rb +5 -170
- data/lib/wrong/close_to.rb +7 -1
- data/lib/wrong/config.rb +3 -3
- data/lib/wrong/d.rb +2 -1
- data/lib/wrong/failure_message.rb +109 -7
- data/lib/wrong/message/string_comparison.rb +1 -1
- data/lib/wrong/sexp_ext.rb +2 -1
- data/lib/wrong/terminal.rb +43 -0
- data/lib/wrong/version.rb +1 -1
- data/test/adapters/railsapp/app/controllers/application_controller.rb +3 -0
- data/test/adapters/railsapp/app/helpers/application_helper.rb +2 -0
- data/test/adapters/railsapp/config/application.rb +54 -0
- data/test/adapters/railsapp/config/boot.rb +6 -0
- data/test/adapters/railsapp/config/environment.rb +5 -0
- data/test/adapters/railsapp/config/environments/development.rb +30 -0
- data/test/adapters/railsapp/config/environments/production.rb +60 -0
- data/test/adapters/railsapp/config/environments/test.rb +42 -0
- data/test/adapters/railsapp/config/initializers/backtrace_silencers.rb +7 -0
- data/test/adapters/railsapp/config/initializers/inflections.rb +10 -0
- data/test/adapters/railsapp/config/initializers/mime_types.rb +5 -0
- data/test/adapters/railsapp/config/initializers/secret_token.rb +7 -0
- data/test/adapters/railsapp/config/initializers/session_store.rb +8 -0
- data/test/adapters/railsapp/config/initializers/wrap_parameters.rb +14 -0
- data/test/adapters/railsapp/config/routes.rb +58 -0
- data/test/adapters/railsapp/db/seeds.rb +7 -0
- data/test/adapters/railsapp/spec/spec_helper.rb +33 -0
- data/test/adapters/railsapp/spec/wrong_spec.rb +8 -0
- data/test/adapters/rspec_rails_test.rb +4 -4
- data/test/adapters/rspec_test.rb +2 -2
- data/test/assert_advanced_test.rb +9 -1
- data/test/chunk_test.rb +0 -200
- data/test/close_to_test.rb +34 -2
- data/test/d_test.rb +2 -2
- data/test/eventually_test.rb +27 -34
- data/test/failure_message_test.rb +212 -13
- data/test/test_helper.rb +2 -2
- metadata +47 -8
- data/lib/wrong/ruby2ruby_patch.rb +0 -37
@@ -12,11 +12,11 @@ include Wrong
|
|
12
12
|
# called rspec-rails-generate.sh -- if you dare
|
13
13
|
|
14
14
|
|
15
|
-
if RUBY_VERSION
|
15
|
+
if RUBY_VERSION >= "1.9.2" # too many issues with other versions
|
16
16
|
describe "testing rspec-rails" do
|
17
17
|
|
18
18
|
[2].each do |rspec_version|
|
19
|
-
it "in version #{rspec_version}" do
|
19
|
+
it "in rspec version #{rspec_version}" do
|
20
20
|
railsapp_dir = "#{here}/railsapp"
|
21
21
|
|
22
22
|
unless File.exist?(railsapp_dir)
|
@@ -32,7 +32,7 @@ describe "testing rspec-rails" do
|
|
32
32
|
FileUtils.rm "#{railsapp_dir}/Gemfile.lock", :force => true
|
33
33
|
|
34
34
|
# todo: extract into common function
|
35
|
-
sys "bundle check" do |output|
|
35
|
+
sys "bundle check", :ignore do |output|
|
36
36
|
unless output == "The Gemfile's dependencies are satisfied\n"
|
37
37
|
sys "bundle install --gemfile=#{railsapp_dir}/Gemfile"
|
38
38
|
end
|
@@ -47,7 +47,7 @@ describe "testing rspec-rails" do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
spec_output = sys "rspec spec/wrong_spec.rb",
|
50
|
-
(rspec_version == 1 || RUBY_VERSION =~ /^1\.8\./ || RUBY_VERSION == '1.9.1' ?
|
50
|
+
(rspec_version == 1 || RUBY_VERSION =~ /^1\.8\./ || RUBY_VERSION == '1.9.1' ? :ignore : 1) # RSpec v1 exits with 0 on failure :-(
|
51
51
|
end
|
52
52
|
|
53
53
|
assert { spec_output.include? "1 example, 1 failure" }
|
data/test/adapters/rspec_test.rb
CHANGED
@@ -20,7 +20,7 @@ describe "testing rspec" do
|
|
20
20
|
clear_bundler_env
|
21
21
|
FileUtils.rm "#{dir}/Gemfile.lock", :force => true
|
22
22
|
|
23
|
-
sys "bundle check",
|
23
|
+
sys "bundle check", :ignore do |output|
|
24
24
|
unless output == "The Gemfile's dependencies are satisfied\n"
|
25
25
|
sys "bundle install --gemfile=#{dir}/Gemfile --local"
|
26
26
|
end
|
@@ -35,7 +35,7 @@ describe "testing rspec" do
|
|
35
35
|
|
36
36
|
Bundler.with_clean_env do
|
37
37
|
# RSpec v1 exits with 0 on failure :-( (as do older rubies)
|
38
|
-
expected_status = (rspec_version == 1 || RUBY_VERSION =~ /^1\.8\./ || RUBY_VERSION == '1.9.1' ?
|
38
|
+
expected_status = (rspec_version == 1 || RUBY_VERSION =~ /^1\.8\./ || RUBY_VERSION == '1.9.1' ? :ignore : 1)
|
39
39
|
spec_output = sys "ruby #{dir}/failing_spec.rb", expected_status
|
40
40
|
end
|
41
41
|
end
|
@@ -16,7 +16,7 @@ describe "advanced assert features" do
|
|
16
16
|
assert_later { x > 10 }
|
17
17
|
end
|
18
18
|
|
19
|
-
assert(e.message =~ /Expected \(x > 10\), but.*x is 10/m, e.message)
|
19
|
+
assert(e.message =~ /Expected assert_later { \(x > 10\) }, but.*x is 10/m, e.message)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -48,4 +48,12 @@ describe "advanced assert features" do
|
|
48
48
|
|
49
49
|
# todo: test for finding it if you'd changed dirs into a parent or sibling or cousin dir
|
50
50
|
|
51
|
+
it "can compare two hashes" do
|
52
|
+
assert { {1=>2} == {1=>2} }
|
53
|
+
unless RUBY_VERSION < "1.9"
|
54
|
+
assert do
|
55
|
+
{a:2} == {a:2}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
51
59
|
end
|
data/test/chunk_test.rb
CHANGED
@@ -10,11 +10,6 @@ end
|
|
10
10
|
|
11
11
|
describe Chunk do
|
12
12
|
|
13
|
-
# normalize yaml
|
14
|
-
def y(s)
|
15
|
-
s.gsub(/--- $/, "---").chomp
|
16
|
-
end
|
17
|
-
|
18
13
|
describe "#from_block" do
|
19
14
|
it "reads the source location" do
|
20
15
|
file, line = __FILE__, __LINE__
|
@@ -193,199 +188,4 @@ z
|
|
193
188
|
end
|
194
189
|
end
|
195
190
|
|
196
|
-
describe "#details" do
|
197
|
-
def details(&block)
|
198
|
-
chunk = Chunk.from_block(block, 1)
|
199
|
-
chunk.details
|
200
|
-
end
|
201
|
-
|
202
|
-
it "returns an empty string if there are no parts" do
|
203
|
-
d = details { assert { true } }
|
204
|
-
assert d == ""
|
205
|
-
end
|
206
|
-
|
207
|
-
it "returns an string beginning with a newline if there are parts" do
|
208
|
-
x = 10
|
209
|
-
d = details { assert { x == 10 } }
|
210
|
-
assert d == "\n x is 10\n"
|
211
|
-
end
|
212
|
-
|
213
|
-
it "skips literals" do
|
214
|
-
d = details { assert { 10 == 11 } }
|
215
|
-
assert d == ""
|
216
|
-
end
|
217
|
-
|
218
|
-
it "shows lots of details" do
|
219
|
-
x = 10
|
220
|
-
d = details { assert { (x * (x - 10)) == (x / (x + 10)) } }
|
221
|
-
assert d == <<-DETAILS
|
222
|
-
|
223
|
-
(x * (x - 10)) is 0
|
224
|
-
x is 10
|
225
|
-
(x - 10) is 0
|
226
|
-
(x / (x + 10)) is 0
|
227
|
-
(x + 10) is 20
|
228
|
-
DETAILS
|
229
|
-
end
|
230
|
-
|
231
|
-
it "skips duplicates" do
|
232
|
-
x = 10
|
233
|
-
d = details { assert { (x + 5) == 1 + (x + 5) } }
|
234
|
-
assert d == <<-DETAILS
|
235
|
-
|
236
|
-
(x + 5) is 15
|
237
|
-
x is 10
|
238
|
-
(1 + (x + 5)) is 16
|
239
|
-
DETAILS
|
240
|
-
end
|
241
|
-
|
242
|
-
it "shows exceptions" do
|
243
|
-
d = details { assert { (raise "hi") == 1 } }
|
244
|
-
assert d == "\n raise(\"hi\") raises RuntimeError: hi\n"
|
245
|
-
end
|
246
|
-
|
247
|
-
it "indents newlines inside the exception message" do
|
248
|
-
d = details { assert { (raise "hello\nsailor") == 1 } }
|
249
|
-
assert d == "\n raise(\"hello\\nsailor\") raises RuntimeError: hello\n sailor\n"
|
250
|
-
end
|
251
|
-
|
252
|
-
it "abridges exceptions with no message" do
|
253
|
-
d = details { assert { (raise Exception.new) == 1 } }
|
254
|
-
assert d == "\n raise(Exception.new) raises Exception\n" +
|
255
|
-
" Exception.new is #<Exception: Exception>\n"
|
256
|
-
end
|
257
|
-
|
258
|
-
it "inspects values" do
|
259
|
-
x = "flavor:\tvanilla"
|
260
|
-
d = details { assert { x == "flavor:\tchocolate" } }
|
261
|
-
# this means it's a literal slash plus t inside double quotes -- i.e. it shows the escaped (inspected) string
|
262
|
-
assert d == "\n" + ' x is "flavor:\tvanilla"' + "\n"
|
263
|
-
end
|
264
|
-
|
265
|
-
it "splits lower-down details correctly (bug)" do
|
266
|
-
hash = {:flavor => "vanilla"}
|
267
|
-
exception_with_newlines = Exception.new(hash.to_yaml.chomp)
|
268
|
-
d = details {
|
269
|
-
rescuing { raise exception_with_newlines }.message.include?(":flavor: chocolate")
|
270
|
-
}
|
271
|
-
assert (y(d).include? "exception_with_newlines is #<Exception: ---\n :flavor: vanilla>"), d.inspect
|
272
|
-
end
|
273
|
-
|
274
|
-
it "skips assignments" do
|
275
|
-
y = 14
|
276
|
-
d = details { x = 7; y }
|
277
|
-
assert d !~ /x = 7/
|
278
|
-
assert d =~ /y is 14/
|
279
|
-
end
|
280
|
-
|
281
|
-
class Weirdo
|
282
|
-
def initialize(inspected_value)
|
283
|
-
@inspected_value = inspected_value
|
284
|
-
end
|
285
|
-
|
286
|
-
def inspect
|
287
|
-
@inspected_value
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
|
292
|
-
it "indents unescaped newlines inside the inspected value" do
|
293
|
-
x = Weirdo.new("first\nsecond\nthird")
|
294
|
-
d = details { assert { x == "foo" } }
|
295
|
-
assert d == "\n x is first\n second\n third\n"
|
296
|
-
end
|
297
|
-
|
298
|
-
describe '#pretty_value' do
|
299
|
-
before do
|
300
|
-
@chunk = chunk = Chunk.new(__FILE__, __LINE__ + 1); <<-CODE
|
301
|
-
true
|
302
|
-
CODE
|
303
|
-
end
|
304
|
-
|
305
|
-
after do
|
306
|
-
Chunk.terminal_width = 80
|
307
|
-
end
|
308
|
-
|
309
|
-
it 'inspects its value' do
|
310
|
-
assert @chunk.pretty_value(12) == "12"
|
311
|
-
assert @chunk.pretty_value("foo") == "\"foo\""
|
312
|
-
end
|
313
|
-
|
314
|
-
it 'escapes newlines in strings' do
|
315
|
-
assert @chunk.pretty_value("foo\nbar\nbaz") == "\"foo\\nbar\\nbaz\""
|
316
|
-
end
|
317
|
-
|
318
|
-
it 'indents newlines in raw inspect values (e.g. exceptions or YAML or whatever)' do
|
319
|
-
w = Weirdo.new("foo\nbar\nbaz")
|
320
|
-
assert @chunk.pretty_value(w) == "foo\n bar\n baz"
|
321
|
-
end
|
322
|
-
|
323
|
-
it "returns the terminal width" do
|
324
|
-
assert Chunk.terminal_width.is_a? Fixnum
|
325
|
-
assert Chunk.terminal_width > 0
|
326
|
-
end
|
327
|
-
|
328
|
-
it "can fake the terminal width" do
|
329
|
-
Chunk.terminal_width = 66
|
330
|
-
assert Chunk.terminal_width == 66
|
331
|
-
end
|
332
|
-
|
333
|
-
# def pretty_value(value, starting_col = 0, indent_wrapped_lines = 3, size = Chunk.terminal_size)
|
334
|
-
|
335
|
-
it 'inserts newlines in really long values, wrapped at the given width' do
|
336
|
-
abc = Weirdo.new("abcdefghijklmnopqrstuvwxyz")
|
337
|
-
pretty = @chunk.pretty_value(abc, 0, 0, 10)
|
338
|
-
assert pretty == <<-DONE.chomp
|
339
|
-
abcdefghij
|
340
|
-
klmnopqrst
|
341
|
-
uvwxyz
|
342
|
-
DONE
|
343
|
-
end
|
344
|
-
|
345
|
-
it 'inserts newlines in really long values, wrapped at the terminal width' do
|
346
|
-
Chunk.terminal_width = 10
|
347
|
-
abc = Weirdo.new("abcdefghijklmnopqrstuvwxyz")
|
348
|
-
pretty = @chunk.pretty_value(abc, 0, 0)
|
349
|
-
assert pretty == <<-DONE.chomp
|
350
|
-
abcdefghij
|
351
|
-
klmnopqrst
|
352
|
-
uvwxyz
|
353
|
-
DONE
|
354
|
-
end
|
355
|
-
|
356
|
-
it 'subtracts the starting column from the wrapped width of the first line' do
|
357
|
-
abc = Weirdo.new("abcdefghijklmnopqrstuvwxyz")
|
358
|
-
pretty = @chunk.pretty_value(abc, 2, 0, 10)
|
359
|
-
assert pretty == <<-DONE.chomp
|
360
|
-
abcdefgh
|
361
|
-
ijklmnopqr
|
362
|
-
stuvwxyz
|
363
|
-
DONE
|
364
|
-
end
|
365
|
-
|
366
|
-
it "indents wrapped lines" do
|
367
|
-
abc = Weirdo.new("abcdefghijklmnopqrstuvwxyz")
|
368
|
-
pretty = @chunk.pretty_value(abc, 2, 3, 10)
|
369
|
-
assert pretty == <<-DONE.chomp
|
370
|
-
abcdefgh
|
371
|
-
ijklmno
|
372
|
-
pqrstuv
|
373
|
-
wxyz
|
374
|
-
DONE
|
375
|
-
end
|
376
|
-
|
377
|
-
it "wraps correctly" do
|
378
|
-
hash = {:flavor => "vanilla"}
|
379
|
-
object = Weirdo.new(hash.to_yaml.chomp)
|
380
|
-
pretty = @chunk.pretty_value(object, 2, 3, 80)
|
381
|
-
assert y(pretty) == y(<<-DONE), pretty.inspect
|
382
|
-
---
|
383
|
-
:flavor: vanilla
|
384
|
-
DONE
|
385
|
-
end
|
386
|
-
|
387
|
-
|
388
|
-
end
|
389
|
-
|
390
|
-
end
|
391
191
|
end
|
data/test/close_to_test.rb
CHANGED
@@ -2,6 +2,7 @@ require "./test/test_helper"
|
|
2
2
|
require "wrong/close_to"
|
3
3
|
require "wrong"
|
4
4
|
require "bigdecimal"
|
5
|
+
require 'time'
|
5
6
|
|
6
7
|
describe "#close_to? (monkey patch for float comparison)" do
|
7
8
|
include Wrong
|
@@ -36,11 +37,42 @@ describe "#close_to? (monkey patch for float comparison)" do
|
|
36
37
|
deny { 5.close_to? 5.1 }
|
37
38
|
assert { 5.close_to? 5.1, 0.5 }
|
38
39
|
end
|
39
|
-
|
40
|
-
it "also works for bigdecimals" do
|
40
|
+
|
41
|
+
it "also works for bigdecimals" do
|
41
42
|
assert { BigDecimal.new("5.0").close_to? 5 }
|
42
43
|
assert { BigDecimal.new("5.0").close_to? 5.0001 }
|
43
44
|
deny { BigDecimal.new("5.0").close_to? 5.1 }
|
44
45
|
end
|
45
46
|
|
47
|
+
one_hour = 60 * 60
|
48
|
+
one_day = one_hour * 24
|
49
|
+
|
50
|
+
it "works for dates" do
|
51
|
+
monday = Date.parse("2000-01-02")
|
52
|
+
tuesday = Date.parse("2000-01-03")
|
53
|
+
assert { monday.close_to? monday }
|
54
|
+
deny { monday.close_to? tuesday }
|
55
|
+
assert { monday.close_to? tuesday, one_day + 1 }
|
56
|
+
end
|
57
|
+
|
58
|
+
it "works for times" do
|
59
|
+
noon = Time.parse("12:00:00")
|
60
|
+
one_pm = Time.parse("13:00:00")
|
61
|
+
one_pm_and_one_second = Time.parse("13:00:01")
|
62
|
+
assert { one_pm.close_to? one_pm }
|
63
|
+
assert { one_pm.close_to? one_pm_and_one_second, 2 }
|
64
|
+
deny { noon.close_to? one_pm }
|
65
|
+
assert { noon.close_to? one_pm, one_hour + 1 }
|
66
|
+
end
|
67
|
+
|
68
|
+
it "works for datetimes" do
|
69
|
+
noon = DateTime.parse("2000-01-01 12:00:00")
|
70
|
+
one_pm = DateTime.parse("2000-01-01 13:00:00")
|
71
|
+
one_pm_and_one_second = DateTime.parse("2000-01-01 13:00:01")
|
72
|
+
assert { one_pm.close_to? one_pm }
|
73
|
+
assert { one_pm.close_to? one_pm_and_one_second, 2 }
|
74
|
+
deny { noon.close_to? one_pm }
|
75
|
+
assert { noon.close_to? one_pm, one_hour + 1 }
|
76
|
+
end
|
77
|
+
|
46
78
|
end
|
data/test/d_test.rb
CHANGED
@@ -24,7 +24,7 @@ describe "d" do
|
|
24
24
|
|
25
25
|
it "pretty-prints the value" do
|
26
26
|
begin
|
27
|
-
Wrong::
|
27
|
+
Wrong::Terminal.width = 20
|
28
28
|
x = ["a" * 10, "b" * 10]
|
29
29
|
output = capturing do
|
30
30
|
d { x }
|
@@ -33,7 +33,7 @@ describe "d" do
|
|
33
33
|
"x is [\"aaaaaaaaaa\",\n \"bbbbbbbbbb\"]\n"
|
34
34
|
}
|
35
35
|
ensure
|
36
|
-
Wrong::
|
36
|
+
Wrong::Terminal.width = nil
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
data/test/eventually_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# based on
|
1
|
+
# based on
|
2
2
|
# * https://gist.github.com/1228927
|
3
3
|
# * https://github.com/pivotal/selenium/blob/master/lib/selenium/wait_for.rb
|
4
4
|
# see
|
@@ -30,7 +30,7 @@ describe "eventually" do
|
|
30
30
|
include Wrong::Helpers
|
31
31
|
include Wrong::D
|
32
32
|
|
33
|
-
# rolling our own mock clock and stubbing framework since we want these
|
33
|
+
# rolling our own mock clock and stubbing framework since we want these
|
34
34
|
# tests to run in MiniTest or in any version of RSpec
|
35
35
|
|
36
36
|
class ::Time
|
@@ -43,27 +43,27 @@ describe "eventually" do
|
|
43
43
|
def now= new_now
|
44
44
|
@now = new_now
|
45
45
|
end
|
46
|
-
end
|
46
|
+
end
|
47
47
|
end
|
48
48
|
|
49
49
|
def stub_it(receiver, method_name, &block)
|
50
50
|
receiver.singleton_class.send(:define_method, method_name, &block)
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
def unstub_it(receiver, method_name)
|
54
54
|
receiver.singleton_class.send(:remove_method, method_name)
|
55
55
|
end
|
56
56
|
|
57
57
|
before do
|
58
|
-
stub_it(self, :sleep) do |secs|
|
58
|
+
stub_it(self, :sleep) do |secs|
|
59
59
|
Time.now += secs
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
after do
|
64
64
|
unstub_it(self, :sleep)
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
it "requires a block" do
|
68
68
|
e = rescuing {
|
69
69
|
eventually
|
@@ -86,29 +86,25 @@ describe "eventually" do
|
|
86
86
|
deny { e.nil? }
|
87
87
|
assert { Time.now == original_now + 5}
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
it "calls the block every 0.25 seconds" do
|
91
|
-
original_now = Time.now
|
91
|
+
original_now = Time.now
|
92
92
|
called_at = []
|
93
93
|
rescuing {
|
94
|
-
eventually {
|
94
|
+
eventually {
|
95
95
|
called_at << (Time.now - original_now)
|
96
96
|
false
|
97
97
|
}
|
98
98
|
}
|
99
99
|
assert { called_at.uniq == [
|
100
|
-
0.0, 0.25, 0.5, 0.75,
|
101
|
-
1.0, 1.25, 1.5, 1.75,
|
102
|
-
2.0, 2.25, 2.5, 2.75,
|
103
|
-
3.0, 3.25, 3.5, 3.75,
|
104
|
-
4.0, 4.25, 4.5, 4.75,
|
100
|
+
0.0, 0.25, 0.5, 0.75,
|
101
|
+
1.0, 1.25, 1.5, 1.75,
|
102
|
+
2.0, 2.25, 2.5, 2.75,
|
103
|
+
3.0, 3.25, 3.5, 3.75,
|
104
|
+
4.0, 4.25, 4.5, 4.75,
|
105
105
|
] }
|
106
106
|
end
|
107
|
-
|
108
|
-
it "puts the elapsed time in the exception message"
|
109
|
-
# assert { e.message =~ /\(after 5 sec\)$/}
|
110
|
-
|
111
|
-
|
107
|
+
|
112
108
|
it "returns after the condition is false for a while then true" do
|
113
109
|
original_now = Time.now
|
114
110
|
eventually {
|
@@ -121,19 +117,20 @@ describe "eventually" do
|
|
121
117
|
end
|
122
118
|
|
123
119
|
it "raises a detailed Wrong exception if the result keeps being false" do
|
124
|
-
original_now = Time.now
|
125
120
|
e = rescuing do
|
126
121
|
eventually { false }
|
127
122
|
end
|
128
123
|
assert { e.message == "Expected false" }
|
129
|
-
|
124
|
+
|
130
125
|
x = 1
|
131
126
|
e = rescuing do
|
132
|
-
eventually
|
127
|
+
eventually do
|
128
|
+
x + 2 == 4
|
129
|
+
end
|
133
130
|
end
|
134
131
|
assert { e.message == "Expected ((x + 2) == 4), but\n (x + 2) is 3\n x is 1\n" }
|
135
132
|
end
|
136
|
-
|
133
|
+
|
137
134
|
describe "if the block raises an exception" do
|
138
135
|
it "for 5 seconds, it raises that exception" do
|
139
136
|
original_now = Time.now
|
@@ -160,27 +157,23 @@ describe "eventually" do
|
|
160
157
|
}
|
161
158
|
end
|
162
159
|
end
|
163
|
-
|
164
|
-
describe "passes a context hash to the block" do
|
165
|
-
it "that influences the error message"
|
166
|
-
end
|
167
|
-
|
160
|
+
|
168
161
|
describe "takes an options hash" do
|
169
162
|
it "that can change the timeout" do
|
170
|
-
original_now = Time.now
|
163
|
+
original_now = Time.now
|
171
164
|
rescuing {
|
172
165
|
eventually(:timeout => 2) { false }
|
173
166
|
}
|
174
167
|
assert {
|
175
|
-
Time.now == original_now + 2
|
168
|
+
Time.now == original_now + 2
|
176
169
|
}
|
177
170
|
end
|
178
|
-
|
171
|
+
|
179
172
|
it "that can change the delay" do
|
180
|
-
original_now = Time.now
|
173
|
+
original_now = Time.now
|
181
174
|
called_at = []
|
182
175
|
rescuing {
|
183
|
-
eventually(:delay => 1.5) {
|
176
|
+
eventually(:delay => 1.5) {
|
184
177
|
called_at << (Time.now - original_now)
|
185
178
|
false
|
186
179
|
}
|