spec 5.0.14

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.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.autotest +34 -0
  3. data/.gitignore +3 -0
  4. data/History.txt +911 -0
  5. data/Manifest.txt +26 -0
  6. data/README.txt +497 -0
  7. data/Rakefile +214 -0
  8. data/design_rationale.rb +52 -0
  9. data/lib/hoe/minitest.rb +26 -0
  10. data/lib/minitest/assertions.rb +649 -0
  11. data/lib/minitest/autorun.rb +12 -0
  12. data/lib/minitest/benchmark.rb +423 -0
  13. data/lib/minitest/expectations.rb +268 -0
  14. data/lib/minitest/hell.rb +11 -0
  15. data/lib/minitest/mock.rb +220 -0
  16. data/lib/minitest/parallel_each.rb +120 -0
  17. data/lib/minitest/pride.rb +4 -0
  18. data/lib/minitest/pride_plugin.rb +143 -0
  19. data/lib/minitest/spec.rb +292 -0
  20. data/lib/minitest/test.rb +272 -0
  21. data/lib/minitest/unit.rb +45 -0
  22. data/lib/minitest.rb +839 -0
  23. data/lib/spec.rb +3 -0
  24. data/readme.md +7 -0
  25. data/release_notes.md +49 -0
  26. data/spec.gemspec +36 -0
  27. data/test/manual/appium.rb +14 -0
  28. data/test/manual/appium_after_last.rb +24 -0
  29. data/test/manual/appium_before_first.rb +23 -0
  30. data/test/manual/assert.rb +61 -0
  31. data/test/manual/before_first_0.rb +27 -0
  32. data/test/manual/before_first_1.rb +29 -0
  33. data/test/manual/debug.rb +37 -0
  34. data/test/manual/do_end.rb +31 -0
  35. data/test/manual/raise.rb +61 -0
  36. data/test/manual/run2.rb +74 -0
  37. data/test/manual/run3.rb +91 -0
  38. data/test/manual/setup.rb +13 -0
  39. data/test/manual/simple.rb +19 -0
  40. data/test/manual/simple2.rb +20 -0
  41. data/test/manual/t.rb +11 -0
  42. data/test/manual/trace.rb +19 -0
  43. data/test/manual/trace2.rb +15 -0
  44. data/test/minitest/metametameta.rb +78 -0
  45. data/test/minitest/test_helper.rb +20 -0
  46. data/test/minitest/test_minitest_benchmark.rb +131 -0
  47. data/test/minitest/test_minitest_mock.rb +490 -0
  48. data/test/minitest/test_minitest_reporter.rb +270 -0
  49. data/test/minitest/test_minitest_spec.rb +794 -0
  50. data/test/minitest/test_minitest_unit.rb +1846 -0
  51. metadata +147 -0
@@ -0,0 +1,649 @@
1
+ require "rbconfig"
2
+
3
+ module Minitest
4
+ ##
5
+ # Minitest Assertions. All assertion methods accept a +msg+ which is
6
+ # printed if the assertion fails.
7
+ #
8
+ # Protocol: Nearly everything here boils up to +assert+, which
9
+ # expects to be able to increment an instance variable named
10
+ # +assertions+. This is not provided by Assertions and must be
11
+ # provided by the thing including Assertions. See Minitest::Runnable
12
+ # for an example.
13
+
14
+ module Assertions
15
+ UNDEFINED = Object.new # :nodoc:
16
+
17
+ def UNDEFINED.inspect # :nodoc:
18
+ "UNDEFINED" # again with the rdoc bugs... :(
19
+ end
20
+
21
+ ##
22
+ # Returns the diff command to use in #diff. Tries to intelligently
23
+ # figure out what diff to use.
24
+
25
+ def self.diff
26
+ @diff = if (RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ &&
27
+ system("diff.exe", __FILE__, __FILE__)) then
28
+ "diff.exe -u"
29
+ elsif Minitest::Test.maglev? then
30
+ "diff -u"
31
+ elsif system("gdiff", __FILE__, __FILE__)
32
+ "gdiff -u" # solaris and kin suck
33
+ elsif system("diff", __FILE__, __FILE__)
34
+ "diff -u"
35
+ else
36
+ nil
37
+ end unless defined? @diff
38
+
39
+ @diff
40
+ end
41
+
42
+ ##
43
+ # Set the diff command to use in #diff.
44
+
45
+ def self.diff= o
46
+ @diff = o
47
+ end
48
+
49
+ ##
50
+ # Returns a diff between +exp+ and +act+. If there is no known
51
+ # diff command or if it doesn't make sense to diff the output
52
+ # (single line, short output), then it simply returns a basic
53
+ # comparison between the two.
54
+
55
+ def diff exp, act
56
+ require "tempfile"
57
+
58
+ expect = mu_pp_for_diff exp
59
+ butwas = mu_pp_for_diff act
60
+ result = nil
61
+
62
+ need_to_diff =
63
+ Minitest::Assertions.diff &&
64
+ (expect.include?("\n") ||
65
+ butwas.include?("\n") ||
66
+ expect.size > 30 ||
67
+ butwas.size > 30 ||
68
+ expect == butwas)
69
+
70
+ return "Expected: #{mu_pp exp}\n Actual: #{mu_pp act}" unless
71
+ need_to_diff
72
+
73
+ Tempfile.open("expect") do |a|
74
+ a.puts expect
75
+ a.flush
76
+
77
+ Tempfile.open("butwas") do |b|
78
+ b.puts butwas
79
+ b.flush
80
+
81
+ result = `#{Minitest::Assertions.diff} #{a.path} #{b.path}`
82
+ result.sub!(/^\-\-\- .+/, "--- expected")
83
+ result.sub!(/^\+\+\+ .+/, "+++ actual")
84
+
85
+ if result.empty? then
86
+ klass = exp.class
87
+ result = [
88
+ "No visible difference in the #{klass}#inspect output.\n",
89
+ "You should look at the implementation of #== on ",
90
+ "#{klass} or its members.\n",
91
+ expect,
92
+ ].join
93
+ end
94
+ end
95
+ end
96
+
97
+ result
98
+ end
99
+
100
+ ##
101
+ # This returns a human-readable version of +obj+. By default
102
+ # #inspect is called. You can override this to use #pretty_print
103
+ # if you want.
104
+
105
+ def mu_pp obj
106
+ s = obj.inspect
107
+ s = s.encode Encoding.default_external if defined? Encoding
108
+ s
109
+ end
110
+
111
+ ##
112
+ # This returns a diff-able human-readable version of +obj+. This
113
+ # differs from the regular mu_pp because it expands escaped
114
+ # newlines and makes hex-values generic (like object_ids). This
115
+ # uses mu_pp to do the first pass and then cleans it up.
116
+
117
+ def mu_pp_for_diff obj
118
+ mu_pp(obj).gsub(/\\n/, "\n").gsub(/:0x[a-fA-F0-9]{4,}/m, ':0xXXXXXX')
119
+ end
120
+
121
+ ##
122
+ # Fails unless +test+ is truthy.
123
+
124
+ def assert test, msg = nil
125
+ msg ||= "Failed assertion, no message given."
126
+ self.assertions += 1
127
+ unless test then
128
+ msg = msg.call if Proc === msg
129
+ raise Minitest::Assertion, msg
130
+ end
131
+ true
132
+ end
133
+
134
+ ##
135
+ # Fails unless +obj+ is empty.
136
+
137
+ def assert_empty obj, msg = nil
138
+ msg = message(msg) { "Expected #{mu_pp(obj)} to be empty" }
139
+ assert_respond_to obj, :empty?
140
+ assert obj.empty?, msg
141
+ end
142
+
143
+ ##
144
+ # Fails unless <tt>exp == act</tt> printing the difference between
145
+ # the two, if possible.
146
+ #
147
+ # If there is no visible difference but the assertion fails, you
148
+ # should suspect that your #== is buggy, or your inspect output is
149
+ # missing crucial details.
150
+ #
151
+ # For floats use assert_in_delta.
152
+ #
153
+ # See also: Minitest::Assertions.diff
154
+
155
+ def assert_equal exp, act, msg = nil
156
+ msg = message(msg, "") { diff exp, act }
157
+ assert exp == act, msg
158
+ end
159
+
160
+ ##
161
+ # For comparing Floats. Fails unless +exp+ and +act+ are within +delta+
162
+ # of each other.
163
+ #
164
+ # assert_in_delta Math::PI, (22.0 / 7.0), 0.01
165
+
166
+ def assert_in_delta exp, act, delta = 0.001, msg = nil
167
+ n = (exp - act).abs
168
+ msg = message(msg) {
169
+ "Expected |#{exp} - #{act}| (#{n}) to be <= #{delta}"
170
+ }
171
+ assert delta >= n, msg
172
+ end
173
+
174
+ ##
175
+ # For comparing Floats. Fails unless +exp+ and +act+ have a relative
176
+ # error less than +epsilon+.
177
+
178
+ def assert_in_epsilon a, b, epsilon = 0.001, msg = nil
179
+ assert_in_delta a, b, [a.abs, b.abs].min * epsilon, msg
180
+ end
181
+
182
+ ##
183
+ # Fails unless +collection+ includes +obj+.
184
+
185
+ def assert_includes collection, obj, msg = nil
186
+ msg = message(msg) {
187
+ "Expected #{mu_pp(collection)} to include #{mu_pp(obj)}"
188
+ }
189
+ assert_respond_to collection, :include?
190
+ assert collection.include?(obj), msg
191
+ end
192
+
193
+ ##
194
+ # Fails unless +obj+ is an instance of +cls+.
195
+
196
+ def assert_instance_of cls, obj, msg = nil
197
+ msg = message(msg) {
198
+ "Expected #{mu_pp(obj)} to be an instance of #{cls}, not #{obj.class}"
199
+ }
200
+
201
+ assert obj.instance_of?(cls), msg
202
+ end
203
+
204
+ ##
205
+ # Fails unless +obj+ is a kind of +cls+.
206
+
207
+ def assert_kind_of cls, obj, msg = nil
208
+ msg = message(msg) {
209
+ "Expected #{mu_pp(obj)} to be a kind of #{cls}, not #{obj.class}" }
210
+
211
+ assert obj.kind_of?(cls), msg
212
+ end
213
+
214
+ ##
215
+ # Fails unless +matcher+ <tt>=~</tt> +obj+.
216
+
217
+ def assert_match matcher, obj, msg = nil
218
+ msg = message(msg) { "Expected #{mu_pp matcher} to match #{mu_pp obj}" }
219
+ assert_respond_to matcher, :"=~"
220
+ matcher = Regexp.new Regexp.escape matcher if String === matcher
221
+ assert matcher =~ obj, msg
222
+ end
223
+
224
+ ##
225
+ # Fails unless +obj+ is nil
226
+
227
+ def assert_nil obj, msg = nil
228
+ msg = message(msg) { "Expected #{mu_pp(obj)} to be nil" }
229
+ assert obj.nil?, msg
230
+ end
231
+
232
+ ##
233
+ # For testing with binary operators. Eg:
234
+ #
235
+ # assert_operator 5, :<=, 4
236
+
237
+ def assert_operator o1, op, o2 = UNDEFINED, msg = nil
238
+ return assert_predicate o1, op, msg if UNDEFINED == o2
239
+ msg = message(msg) { "Expected #{mu_pp(o1)} to be #{op} #{mu_pp(o2)}" }
240
+ assert o1.__send__(op, o2), msg
241
+ end
242
+
243
+ ##
244
+ # Fails if stdout or stderr do not output the expected results.
245
+ # Pass in nil if you don't care about that streams output. Pass in
246
+ # "" if you require it to be silent. Pass in a regexp if you want
247
+ # to pattern match.
248
+ #
249
+ # NOTE: this uses #capture_io, not #capture_subprocess_io.
250
+ #
251
+ # See also: #assert_silent
252
+
253
+ def assert_output stdout = nil, stderr = nil
254
+ out, err = capture_io do
255
+ yield
256
+ end
257
+
258
+ err_msg = Regexp === stderr ? :assert_match : :assert_equal if stderr
259
+ out_msg = Regexp === stdout ? :assert_match : :assert_equal if stdout
260
+
261
+ y = send err_msg, stderr, err, "In stderr" if err_msg
262
+ x = send out_msg, stdout, out, "In stdout" if out_msg
263
+
264
+ (!stdout || x) && (!stderr || y)
265
+ end
266
+
267
+ ##
268
+ # For testing with predicates. Eg:
269
+ #
270
+ # assert_predicate str, :empty?
271
+ #
272
+ # This is really meant for specs and is front-ended by assert_operator:
273
+ #
274
+ # str.must_be :empty?
275
+
276
+ def assert_predicate o1, op, msg = nil
277
+ msg = message(msg) { "Expected #{mu_pp(o1)} to be #{op}" }
278
+ assert o1.__send__(op), msg
279
+ end
280
+
281
+ ##
282
+ # Fails unless the block raises one of +exp+. Returns the
283
+ # exception matched so you can check the message, attributes, etc.
284
+
285
+ def assert_raises *exp
286
+ msg = "#{exp.pop}.\n" if String === exp.last
287
+
288
+ begin
289
+ yield
290
+ rescue Minitest::Skip => e
291
+ return e if exp.include? Minitest::Skip
292
+ raise e
293
+ rescue Exception => e
294
+ expected = exp.any? { |ex|
295
+ if ex.instance_of? Module then
296
+ e.kind_of? ex
297
+ else
298
+ e.instance_of? ex
299
+ end
300
+ }
301
+
302
+ assert expected, proc {
303
+ exception_details(e, "#{msg}#{mu_pp(exp)} exception expected, not")
304
+ }
305
+
306
+ return e
307
+ end
308
+
309
+ exp = exp.first if exp.size == 1
310
+
311
+ flunk "#{msg}#{mu_pp(exp)} expected but nothing was raised."
312
+ end
313
+
314
+ ##
315
+ # Fails unless +obj+ responds to +meth+.
316
+
317
+ def assert_respond_to obj, meth, msg = nil
318
+ msg = message(msg) {
319
+ "Expected #{mu_pp(obj)} (#{obj.class}) to respond to ##{meth}"
320
+ }
321
+ assert obj.respond_to?(meth), msg
322
+ end
323
+
324
+ ##
325
+ # Fails unless +exp+ and +act+ are #equal?
326
+
327
+ def assert_same exp, act, msg = nil
328
+ msg = message(msg) {
329
+ data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
330
+ "Expected %s (oid=%d) to be the same as %s (oid=%d)" % data
331
+ }
332
+ assert exp.equal?(act), msg
333
+ end
334
+
335
+ ##
336
+ # +send_ary+ is a receiver, message and arguments.
337
+ #
338
+ # Fails unless the call returns a true value
339
+
340
+ def assert_send send_ary, m = nil
341
+ recv, msg, *args = send_ary
342
+ m = message(m) {
343
+ "Expected #{mu_pp(recv)}.#{msg}(*#{mu_pp(args)}) to return true" }
344
+ assert recv.__send__(msg, *args), m
345
+ end
346
+
347
+ ##
348
+ # Fails if the block outputs anything to stderr or stdout.
349
+ #
350
+ # See also: #assert_output
351
+
352
+ def assert_silent
353
+ assert_output "", "" do
354
+ yield
355
+ end
356
+ end
357
+
358
+ ##
359
+ # Fails unless the block throws +sym+
360
+
361
+ def assert_throws sym, msg = nil
362
+ default = "Expected #{mu_pp(sym)} to have been thrown"
363
+ caught = true
364
+ catch(sym) do
365
+ begin
366
+ yield
367
+ rescue ThreadError => e # wtf?!? 1.8 + threads == suck
368
+ default += ", not \:#{e.message[/uncaught throw \`(\w+?)\'/, 1]}"
369
+ rescue ArgumentError => e # 1.9 exception
370
+ default += ", not #{e.message.split(/ /).last}"
371
+ rescue NameError => e # 1.8 exception
372
+ default += ", not #{e.name.inspect}"
373
+ end
374
+ caught = false
375
+ end
376
+
377
+ assert caught, message(msg) { default }
378
+ end
379
+
380
+ ##
381
+ # Captures $stdout and $stderr into strings:
382
+ #
383
+ # out, err = capture_io do
384
+ # puts "Some info"
385
+ # warn "You did a bad thing"
386
+ # end
387
+ #
388
+ # assert_match %r%info%, out
389
+ # assert_match %r%bad%, err
390
+ #
391
+ # NOTE: For efficiency, this method uses StringIO and does not
392
+ # capture IO for subprocesses. Use #capture_subprocess_io for
393
+ # that.
394
+
395
+ def capture_io
396
+ require 'stringio'
397
+
398
+ captured_stdout, captured_stderr = StringIO.new, StringIO.new
399
+
400
+ orig_stdout, orig_stderr = $stdout, $stderr
401
+ $stdout, $stderr = captured_stdout, captured_stderr
402
+
403
+ yield
404
+
405
+ return captured_stdout.string, captured_stderr.string
406
+ ensure
407
+ $stdout = orig_stdout
408
+ $stderr = orig_stderr
409
+ end
410
+
411
+ ##
412
+ # Captures $stdout and $stderr into strings, using Tempfile to
413
+ # ensure that subprocess IO is captured as well.
414
+ #
415
+ # out, err = capture_subprocess_io do
416
+ # system "echo Some info"
417
+ # system "echo You did a bad thing 1>&2"
418
+ # end
419
+ #
420
+ # assert_match %r%info%, out
421
+ # assert_match %r%bad%, err
422
+ #
423
+ # NOTE: This method is approximately 10x slower than #capture_io so
424
+ # only use it when you need to test the output of a subprocess.
425
+
426
+ def capture_subprocess_io
427
+ require 'tempfile'
428
+
429
+ captured_stdout, captured_stderr = Tempfile.new("out"), Tempfile.new("err")
430
+
431
+ orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
432
+ $stdout.reopen captured_stdout
433
+ $stderr.reopen captured_stderr
434
+
435
+ yield
436
+
437
+ $stdout.rewind
438
+ $stderr.rewind
439
+
440
+ return captured_stdout.read, captured_stderr.read
441
+ ensure
442
+ captured_stdout.unlink
443
+ captured_stderr.unlink
444
+ $stdout.reopen orig_stdout
445
+ $stderr.reopen orig_stderr
446
+ end
447
+
448
+ ##
449
+ # Returns details for exception +e+
450
+
451
+ def exception_details e, msg
452
+ [
453
+ "#{msg}",
454
+ "Class: <#{e.class}>",
455
+ "Message: <#{e.message.inspect}>",
456
+ "---Backtrace---",
457
+ "#{Minitest::filter_backtrace(e.backtrace).join("\n")}",
458
+ "---------------",
459
+ ].join "\n"
460
+ end
461
+
462
+ ##
463
+ # Fails with +msg+
464
+
465
+ def flunk msg = nil
466
+ msg ||= "Epic Fail!"
467
+ assert false, msg
468
+ end
469
+
470
+ ##
471
+ # Returns a proc that will output +msg+ along with the default message.
472
+
473
+ def message msg = nil, ending = ".", &default
474
+ proc {
475
+ msg = msg.call.chomp(".") if Proc === msg
476
+ custom_message = "#{msg}.\n" unless msg.nil? or msg.to_s.empty?
477
+ "#{custom_message}#{default.call}#{ending}"
478
+ }
479
+ end
480
+
481
+ ##
482
+ # used for counting assertions
483
+
484
+ def pass msg = nil
485
+ assert true
486
+ end
487
+
488
+ ##
489
+ # Fails if +test+ is truthy.
490
+
491
+ def refute test, msg = nil
492
+ msg ||= "Failed refutation, no message given"
493
+ not assert(! test, msg)
494
+ end
495
+
496
+ ##
497
+ # Fails if +obj+ is empty.
498
+
499
+ def refute_empty obj, msg = nil
500
+ msg = message(msg) { "Expected #{mu_pp(obj)} to not be empty" }
501
+ assert_respond_to obj, :empty?
502
+ refute obj.empty?, msg
503
+ end
504
+
505
+ ##
506
+ # Fails if <tt>exp == act</tt>.
507
+ #
508
+ # For floats use refute_in_delta.
509
+
510
+ def refute_equal exp, act, msg = nil
511
+ msg = message(msg) {
512
+ "Expected #{mu_pp(act)} to not be equal to #{mu_pp(exp)}"
513
+ }
514
+ refute exp == act, msg
515
+ end
516
+
517
+ ##
518
+ # For comparing Floats. Fails if +exp+ is within +delta+ of +act+.
519
+ #
520
+ # refute_in_delta Math::PI, (22.0 / 7.0)
521
+
522
+ def refute_in_delta exp, act, delta = 0.001, msg = nil
523
+ n = (exp - act).abs
524
+ msg = message(msg) {
525
+ "Expected |#{exp} - #{act}| (#{n}) to not be <= #{delta}"
526
+ }
527
+ refute delta >= n, msg
528
+ end
529
+
530
+ ##
531
+ # For comparing Floats. Fails if +exp+ and +act+ have a relative error
532
+ # less than +epsilon+.
533
+
534
+ def refute_in_epsilon a, b, epsilon = 0.001, msg = nil
535
+ refute_in_delta a, b, a * epsilon, msg
536
+ end
537
+
538
+ ##
539
+ # Fails if +collection+ includes +obj+.
540
+
541
+ def refute_includes collection, obj, msg = nil
542
+ msg = message(msg) {
543
+ "Expected #{mu_pp(collection)} to not include #{mu_pp(obj)}"
544
+ }
545
+ assert_respond_to collection, :include?
546
+ refute collection.include?(obj), msg
547
+ end
548
+
549
+ ##
550
+ # Fails if +obj+ is an instance of +cls+.
551
+
552
+ def refute_instance_of cls, obj, msg = nil
553
+ msg = message(msg) {
554
+ "Expected #{mu_pp(obj)} to not be an instance of #{cls}"
555
+ }
556
+ refute obj.instance_of?(cls), msg
557
+ end
558
+
559
+ ##
560
+ # Fails if +obj+ is a kind of +cls+.
561
+
562
+ def refute_kind_of cls, obj, msg = nil
563
+ msg = message(msg) { "Expected #{mu_pp(obj)} to not be a kind of #{cls}" }
564
+ refute obj.kind_of?(cls), msg
565
+ end
566
+
567
+ ##
568
+ # Fails if +matcher+ <tt>=~</tt> +obj+.
569
+
570
+ def refute_match matcher, obj, msg = nil
571
+ msg = message(msg) {"Expected #{mu_pp matcher} to not match #{mu_pp obj}"}
572
+ assert_respond_to matcher, :"=~"
573
+ matcher = Regexp.new Regexp.escape matcher if String === matcher
574
+ refute matcher =~ obj, msg
575
+ end
576
+
577
+ ##
578
+ # Fails if +obj+ is nil.
579
+
580
+ def refute_nil obj, msg = nil
581
+ msg = message(msg) { "Expected #{mu_pp(obj)} to not be nil" }
582
+ refute obj.nil?, msg
583
+ end
584
+
585
+ ##
586
+ # Fails if +o1+ is not +op+ +o2+. Eg:
587
+ #
588
+ # refute_operator 1, :>, 2 #=> pass
589
+ # refute_operator 1, :<, 2 #=> fail
590
+
591
+ def refute_operator o1, op, o2 = UNDEFINED, msg = nil
592
+ return refute_predicate o1, op, msg if UNDEFINED == o2
593
+ msg = message(msg) { "Expected #{mu_pp(o1)} to not be #{op} #{mu_pp(o2)}"}
594
+ refute o1.__send__(op, o2), msg
595
+ end
596
+
597
+ ##
598
+ # For testing with predicates.
599
+ #
600
+ # refute_predicate str, :empty?
601
+ #
602
+ # This is really meant for specs and is front-ended by refute_operator:
603
+ #
604
+ # str.wont_be :empty?
605
+
606
+ def refute_predicate o1, op, msg = nil
607
+ msg = message(msg) { "Expected #{mu_pp(o1)} to not be #{op}" }
608
+ refute o1.__send__(op), msg
609
+ end
610
+
611
+ ##
612
+ # Fails if +obj+ responds to the message +meth+.
613
+
614
+ def refute_respond_to obj, meth, msg = nil
615
+ msg = message(msg) { "Expected #{mu_pp(obj)} to not respond to #{meth}" }
616
+
617
+ refute obj.respond_to?(meth), msg
618
+ end
619
+
620
+ ##
621
+ # Fails if +exp+ is the same (by object identity) as +act+.
622
+
623
+ def refute_same exp, act, msg = nil
624
+ msg = message(msg) {
625
+ data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
626
+ "Expected %s (oid=%d) to not be the same as %s (oid=%d)" % data
627
+ }
628
+ refute exp.equal?(act), msg
629
+ end
630
+
631
+ ##
632
+ # Skips the current run. If run in verbose-mode, the skipped run
633
+ # gets listed at the end of the run but doesn't cause a failure
634
+ # exit code.
635
+
636
+ def skip msg = nil, bt = caller
637
+ msg ||= "Skipped, no message given"
638
+ @skip = true
639
+ raise Minitest::Skip, msg, bt
640
+ end
641
+
642
+ ##
643
+ # Was this testcase skipped? Meant for #teardown.
644
+
645
+ def skipped?
646
+ defined?(@skip) and @skip
647
+ end
648
+ end
649
+ end
@@ -0,0 +1,12 @@
1
+ begin
2
+ require "rubygems"
3
+ gem "minitest"
4
+ rescue Gem::LoadError
5
+ # do nothing
6
+ end
7
+
8
+ require "minitest"
9
+ require "minitest/spec"
10
+ require "minitest/mock"
11
+
12
+ Minitest.autorun