minitest 5.12.2

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