minitest-ok 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0393c06bdcd679080b979ab6d402b16363b9ac52
4
- data.tar.gz: 6c0f9dbd1af465ca6601b8be8cadad2809e8393f
3
+ metadata.gz: 4aa9f8f89625dcaab1a15d2875489ce3aa9bc5c4
4
+ data.tar.gz: c5d799128def76bdafb54e3e0e7d3509dcbd4e8e
5
5
  SHA512:
6
- metadata.gz: 08609c6a464436a7ab37ff3045bdcf18dd7d1b9360c728609251ef1e0e7ab3f76983de8a2569cca55f68dbd62a768dddbc8d785fbbf40031253d263e70acb918
7
- data.tar.gz: e869d5d3fcb907eb6ae6aae167f1f1313f25220009e5c8e7880f3e36cb4629897c10e440002f7fbc23baaeb307e670bbb2f88ca03d9c4e2fb3181c40c0615ae5
6
+ metadata.gz: 8d5cae13adc0e3119d3b9c8f24c210922f99e63c28851768cd655190a45ca0e4ecfecfb702d6983a807bcf5879bca10a60333661f262d140c7a54b41682a95a0
7
+ data.tar.gz: 230d68777e669036f620757e47d9f25f04783afcdc51e0b69b0736d0cd0b7c50815914c4ae59fbd19f4a52f022cf5d1e3d8652332495527946f768817b039a47
data/lib/minitest/ok.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 0.2.0 $
4
+ ### $Release: 0.3.0 $
5
5
  ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
@@ -59,7 +59,7 @@ module Minitest
59
59
 
60
60
  module Ok
61
61
 
62
- VERSION = '$Release: 0.2.0 $'.split()[1]
62
+ VERSION = '$Release: 0.3.0 $'.split()[1]
63
63
 
64
64
 
65
65
  class Msg < Proc # :nodoc:
@@ -111,9 +111,17 @@ module Minitest
111
111
  ##
112
112
  def ==(expected)
113
113
  _mark_as_tested()
114
- @context.assert_equal expected, @actual unless @not
115
- @context.refute_equal expected, @actual if @not
114
+ if nil == expected
115
+ @context.assert_nil @actual unless @not
116
+ @context.refute_nil @actual if @not
117
+ else
118
+ @context.assert_equal expected, @actual unless @not
119
+ @context.refute_equal expected, @actual if @not
120
+ end
116
121
  self
122
+ rescue Minitest::Assertion => ex
123
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
124
+ raise
117
125
  end
118
126
 
119
127
  ##
@@ -127,6 +135,9 @@ module Minitest
127
135
  @context.refute_equal expected, @actual unless @not
128
136
  @context.assert_equal expected, @actual if @not
129
137
  self
138
+ rescue Minitest::Assertion => ex
139
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
140
+ raise
130
141
  end
131
142
 
132
143
  ##
@@ -141,6 +152,9 @@ module Minitest
141
152
  @context.assert_operator @actual, :'>', expected unless @not
142
153
  @context.refute_operator @actual, :'>', expected if @not
143
154
  self
155
+ rescue Minitest::Assertion => ex
156
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
157
+ raise
144
158
  end
145
159
 
146
160
  ##
@@ -155,6 +169,9 @@ module Minitest
155
169
  @context.assert_operator @actual, :'>=', expected unless @not
156
170
  @context.refute_operator @actual, :'>=', expected if @not
157
171
  self
172
+ rescue Minitest::Assertion => ex
173
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
174
+ raise
158
175
  end
159
176
 
160
177
  ##
@@ -169,6 +186,9 @@ module Minitest
169
186
  @context.assert_operator @actual, :'<', expected unless @not
170
187
  @context.refute_operator @actual, :'<', expected if @not
171
188
  self
189
+ rescue Minitest::Assertion => ex
190
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
191
+ raise
172
192
  end
173
193
 
174
194
  ##
@@ -183,6 +203,9 @@ module Minitest
183
203
  @context.assert_operator @actual, :'<=', expected unless @not
184
204
  @context.refute_operator @actual, :'<=', expected if @not
185
205
  self
206
+ rescue Minitest::Assertion => ex
207
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
208
+ raise
186
209
  end
187
210
 
188
211
  ##
@@ -196,6 +219,9 @@ module Minitest
196
219
  @context.assert_operator @actual, :'===', expected unless @not
197
220
  @context.refute_operator @actual, :'===', expected if @not
198
221
  self
222
+ rescue Minitest::Assertion => ex
223
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
224
+ raise
199
225
  end
200
226
 
201
227
  ##
@@ -209,6 +235,9 @@ module Minitest
209
235
  @context.assert_match expected, @actual unless @not
210
236
  @context.refute_match expected, @actual if @not
211
237
  self
238
+ rescue Minitest::Assertion => ex
239
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
240
+ raise
212
241
  end
213
242
 
214
243
  ##
@@ -222,6 +251,9 @@ module Minitest
222
251
  @context.refute_match expected, @actual unless @not
223
252
  @context.assert_match expected, @actual if @not
224
253
  self
254
+ rescue Minitest::Assertion => ex
255
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
256
+ raise
225
257
  end
226
258
 
227
259
  ##
@@ -236,6 +268,9 @@ module Minitest
236
268
  @context.assert_kind_of expected, @actual unless @not
237
269
  @context.refute_kind_of expected, @actual if @not
238
270
  self
271
+ rescue Minitest::Assertion => ex
272
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
273
+ raise
239
274
  end
240
275
 
241
276
  ##
@@ -258,6 +293,9 @@ module Minitest
258
293
  @context.assert_instance_of expected, @actual unless @not
259
294
  @context.refute_instance_of expected, @actual if @not
260
295
  self
296
+ rescue Minitest::Assertion => ex
297
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
298
+ raise
261
299
  end
262
300
 
263
301
  ##
@@ -273,6 +311,9 @@ module Minitest
273
311
  @context.assert_same expected, @actual unless @not
274
312
  @context.refute_same expected, @actual if @not
275
313
  self
314
+ rescue Minitest::Assertion => ex
315
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
316
+ raise
276
317
  end
277
318
 
278
319
  ##
@@ -288,6 +329,9 @@ module Minitest
288
329
  @context.assert_empty @actual unless @not
289
330
  @context.refute_empty @actual if @not
290
331
  self
332
+ rescue Minitest::Assertion => ex
333
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
334
+ raise
291
335
  end
292
336
 
293
337
  ##
@@ -301,6 +345,9 @@ module Minitest
301
345
  @context.assert_in_delta(expected, @actual, delta) unless @not
302
346
  @context.refute_in_delta(expected, @actual, delta) if @not
303
347
  self
348
+ rescue Minitest::Assertion => ex
349
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
350
+ raise
304
351
  end
305
352
 
306
353
  ##
@@ -314,6 +361,9 @@ module Minitest
314
361
  @context.assert_in_epsilon(expected, @actual, epsilon) unless @not
315
362
  @context.refute_in_epsilon(expected, @actual, epsilon) if @not
316
363
  self
364
+ rescue Minitest::Assertion => ex
365
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
366
+ raise
317
367
  end
318
368
 
319
369
  ##
@@ -348,6 +398,9 @@ module Minitest
348
398
  end
349
399
  end
350
400
  return ex # not self!
401
+ rescue Minitest::Assertion => ex
402
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
403
+ raise
351
404
  end
352
405
 
353
406
  ##
@@ -362,6 +415,9 @@ module Minitest
362
415
  raise "NOT.throw? is unsupported because refute_throws() is not defined in Minitest."
363
416
  @context.assert_throws(sym) { @actual.call }
364
417
  self
418
+ rescue Minitest::Assertion => ex
419
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
420
+ raise
365
421
  end
366
422
 
367
423
  ##
@@ -375,6 +431,9 @@ module Minitest
375
431
  @context.assert_respond_to @actual, expected unless @not
376
432
  @context.refute_respond_to @actual, expected if @not
377
433
  self
434
+ rescue Minitest::Assertion => ex
435
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
436
+ raise
378
437
  end
379
438
 
380
439
  ##
@@ -389,6 +448,9 @@ module Minitest
389
448
  @context.assert_includes @actual, expected unless @not
390
449
  @context.refute_includes @actual, expected if @not
391
450
  self
451
+ rescue Minitest::Assertion => ex
452
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
453
+ raise
392
454
  end
393
455
 
394
456
  ##
@@ -403,6 +465,9 @@ module Minitest
403
465
  @context.assert_includes expected, @actual unless @not
404
466
  @context.refute_includes expected, @actual if @not
405
467
  self
468
+ rescue Minitest::Assertion => ex
469
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
470
+ raise
406
471
  end
407
472
 
408
473
  ##
@@ -417,6 +482,9 @@ module Minitest
417
482
  raise "use ok().silent? instead of ok().NOT.output?."
418
483
  @context.assert_output(stdout, stderr, &@actual)
419
484
  self
485
+ rescue Minitest::Assertion => ex
486
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
487
+ raise
420
488
  end
421
489
 
422
490
  ##
@@ -431,6 +499,9 @@ module Minitest
431
499
  raise "use ok().output? instead of ok().NOT.silent?."
432
500
  @context.assert_silent(&@actual)
433
501
  self
502
+ rescue Minitest::Assertion => ex
503
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
504
+ raise
434
505
  end
435
506
 
436
507
  ## for predicates
@@ -446,6 +517,9 @@ module Minitest
446
517
  @context.assert_predicate @actual, :frozen? unless @not
447
518
  @context.refute_predicate @actual, :frozen? if @not
448
519
  self
520
+ rescue Minitest::Assertion => ex
521
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
522
+ raise
449
523
  end
450
524
 
451
525
  ##
@@ -459,6 +533,9 @@ module Minitest
459
533
  @context.assert_predicate @actual, :tainted? unless @not
460
534
  @context.refute_predicate @actual, :tainted? if @not
461
535
  self
536
+ rescue Minitest::Assertion => ex
537
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
538
+ raise
462
539
  end
463
540
 
464
541
  ##
@@ -478,6 +555,9 @@ module Minitest
478
555
  @context.refute result, "Expected #{@actual.inspect} not to have instance variable #{varname}, but has it."
479
556
  end
480
557
  self
558
+ rescue Minitest::Assertion => ex
559
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
560
+ raise
481
561
  end
482
562
 
483
563
  ##
@@ -512,6 +592,9 @@ module Minitest
512
592
  end
513
593
  end
514
594
  self
595
+ rescue Minitest::Assertion => ex
596
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
597
+ raise
515
598
  end
516
599
 
517
600
  ## other helpers
@@ -534,6 +617,9 @@ module Minitest
534
617
  @context.refute @actual, Msg.new { "Expected (!! #{@actual.inspect}) == false, but not." }
535
618
  end
536
619
  self
620
+ rescue Minitest::Assertion => ex
621
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
622
+ raise
537
623
  end
538
624
 
539
625
  ##
@@ -554,6 +640,9 @@ module Minitest
554
640
  @context.assert @actual, Msg.new { "Expected (!! #{@actual.inspect}) == true, but not." }
555
641
  end
556
642
  self
643
+ rescue Minitest::Assertion => ex
644
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
645
+ raise
557
646
  end
558
647
 
559
648
  ##
@@ -574,6 +663,9 @@ module Minitest
574
663
  @context.assert_equal expected, actual, Msg.new { pr.call('==') } unless @not
575
664
  @context.refute_equal expected, actual, Msg.new { pr.call('!=') } if @not
576
665
  self
666
+ rescue Minitest::Assertion => ex
667
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
668
+ raise
577
669
  end
578
670
 
579
671
  ##
@@ -589,6 +681,9 @@ module Minitest
589
681
  attr(name, expected)
590
682
  end
591
683
  self
684
+ rescue Minitest::Assertion => ex
685
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
686
+ raise
592
687
  end
593
688
 
594
689
  ##
@@ -608,6 +703,9 @@ module Minitest
608
703
  @context.assert_equal expected, actual, Msg.new { pr.call('==') } unless @not
609
704
  @context.refute_equal expected, actual, Msg.new { pr.call('!=') } if @not
610
705
  self
706
+ rescue Minitest::Assertion => ex
707
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
708
+ raise
611
709
  end
612
710
 
613
711
  ##
@@ -622,6 +720,9 @@ module Minitest
622
720
  item(key, expected)
623
721
  end
624
722
  self
723
+ rescue Minitest::Assertion => ex
724
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
725
+ raise
625
726
  end
626
727
 
627
728
  ##
@@ -640,6 +741,9 @@ module Minitest
640
741
  else
641
742
  @context.refute File.exist?(fpath), "File '#{fpath}' exists unexpectedly."
642
743
  end
744
+ rescue Minitest::Assertion => ex
745
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
746
+ raise
643
747
  end
644
748
 
645
749
  ##
@@ -658,6 +762,9 @@ module Minitest
658
762
  else
659
763
  @context.refute File.exist?(fpath), "Directory '#{fpath}' exists unexpectedly."
660
764
  end
765
+ rescue Minitest::Assertion => ex
766
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
767
+ raise
661
768
  end
662
769
 
663
770
  ##
@@ -673,6 +780,9 @@ module Minitest
673
780
  @context.assert ! File.exist?(fpath), "'#{fpath}' exists unexpectedly." unless @not
674
781
  @context.refute ! File.exist?(fpath), "'#{fpath}' doesn't exist." if @not
675
782
  self
783
+ rescue Minitest::Assertion => ex
784
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
785
+ raise
676
786
  end
677
787
 
678
788
  end
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 0.2.0 $
4
+ ### $Release: 0.3.0 $
5
5
  ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
@@ -169,7 +169,9 @@ describe Minitest::Ok::AssertionObject do
169
169
  should_not_raise { ok {String}.NOT === 123 }
170
170
  should_not_raise { ok {/\d+/ }.NOT === 'abc' }
171
171
  ex = should_raise { ok {String}.NOT === '123' }
172
- msg = 'Expected String to not be === "123".'
172
+ #msg = 'Expected String to not be === "123".'
173
+ msg = ('Expected String to not be === # encoding: UTF-8'+"\n"+
174
+ '"123".')
173
175
  assert_equal msg, ex.message
174
176
  end
175
177
 
@@ -181,14 +183,18 @@ describe Minitest::Ok::AssertionObject do
181
183
  it "calls assert_match()." do
182
184
  should_not_raise { ok {"hom"} =~ /\w+/ }
183
185
  ex = should_raise { ok {"hom"} =~ /\d+/ }
184
- msg = 'Expected /\d+/ to match "hom".'
186
+ #msg = 'Expected /\d+/ to match "hom".'
187
+ msg = ('Expected /\d+/ to match # encoding: UTF-8'+"\n"+
188
+ '"hom".')
185
189
  assert_equal msg, ex.message
186
190
  end
187
191
 
188
192
  it "calls refute_match() after NOT() called." do
189
193
  should_not_raise { ok {"hom"}.NOT =~ /\d+/ }
190
194
  ex = should_raise { ok {"hom"}.NOT =~ /\w+/ }
191
- msg = 'Expected /\w+/ to not match "hom".'
195
+ #msg = 'Expected /\w+/ to not match "hom".'
196
+ msg = ('Expected /\w+/ to not match # encoding: UTF-8'+"\n"+
197
+ '"hom".')
192
198
  assert_equal msg, ex.message
193
199
  end
194
200
 
@@ -200,14 +206,18 @@ describe Minitest::Ok::AssertionObject do
200
206
  it "calls refute_match()." do
201
207
  should_not_raise { ok {"hom"} !~ /\d+/ }
202
208
  ex = should_raise { ok {"hom"} !~ /\w+/ }
203
- msg = 'Expected /\w+/ to not match "hom".'
209
+ #msg = 'Expected /\w+/ to not match "hom".'
210
+ msg = ('Expected /\w+/ to not match # encoding: UTF-8'+"\n"+
211
+ '"hom".')
204
212
  assert_equal msg, ex.message
205
213
  end
206
214
 
207
215
  it "calls assert_match() after NOT() called." do
208
216
  should_not_raise { ok {"hom"}.NOT !~ /\w+/ }
209
217
  ex = should_raise { ok {"hom"}.NOT !~ /\d+/ }
210
- msg = 'Expected /\d+/ to match "hom".'
218
+ #msg = 'Expected /\d+/ to match "hom".'
219
+ msg = ('Expected /\d+/ to match # encoding: UTF-8'+"\n"+
220
+ '"hom".')
211
221
  assert_equal msg, ex.message
212
222
  end
213
223
 
@@ -219,14 +229,18 @@ describe Minitest::Ok::AssertionObject do
219
229
  it "calls assert_kind_of()." do
220
230
  should_not_raise { ok {"hom"}.is_a?(String) }
221
231
  ex = should_raise { ok {"hom"}.is_a?(Array) }
222
- msg = 'Expected "hom" to be a kind of Array, not String.'
232
+ #msg = 'Expected "hom" to be a kind of Array, not String.'
233
+ msg = ('Expected # encoding: UTF-8'+"\n"+
234
+ '"hom" to be a kind of Array, not String.')
223
235
  assert_equal msg, ex.message
224
236
  end
225
237
 
226
238
  it "calls refute_kind_of() after NOT() called." do
227
239
  should_not_raise { ok {"hom"}.NOT.is_a?(Array) }
228
240
  ex = should_raise { ok {"hom"}.NOT.is_a?(String) }
229
- msg = 'Expected "hom" to not be a kind of String.'
241
+ #msg = 'Expected "hom" to not be a kind of String.'
242
+ msg = ('Expected # encoding: UTF-8'+"\n"+
243
+ '"hom" to not be a kind of String.')
230
244
  assert_equal msg, ex.message
231
245
  end
232
246
 
@@ -238,14 +252,18 @@ describe Minitest::Ok::AssertionObject do
238
252
  it "calls assert_kind_of()." do
239
253
  should_not_raise { ok {"hom"}.kind_of?(String) }
240
254
  ex = should_raise { ok {"hom"}.kind_of?(Array) }
241
- msg = 'Expected "hom" to be a kind of Array, not String.'
255
+ #msg = 'Expected "hom" to be a kind of Array, not String.'
256
+ msg = ('Expected # encoding: UTF-8'+"\n"+
257
+ '"hom" to be a kind of Array, not String.')
242
258
  assert_equal msg, ex.message
243
259
  end
244
260
 
245
261
  it "calls refute_kind_of() after NOT() called." do
246
262
  should_not_raise { ok {"hom"}.NOT.kind_of?(Array) }
247
263
  ex = should_raise { ok {"hom"}.NOT.kind_of?(String) }
248
- msg = 'Expected "hom" to not be a kind of String.'
264
+ #msg = 'Expected "hom" to not be a kind of String.'
265
+ msg = ('Expected # encoding: UTF-8'+"\n"+
266
+ '"hom" to not be a kind of String.')
249
267
  assert_equal msg, ex.message
250
268
  end
251
269
 
@@ -255,16 +273,16 @@ describe Minitest::Ok::AssertionObject do
255
273
  describe '#instance_of?' do
256
274
 
257
275
  it "calls assert_instance_of()." do
258
- should_not_raise { ok {123}.instance_of?(Fixnum) }
259
- ex = should_raise { ok {123}.instance_of?(Integer) }
260
- msg = 'Expected 123 to be an instance of Integer, not Fixnum.'
276
+ should_not_raise { ok {1.23}.instance_of?(Float) }
277
+ ex = should_raise { ok {1.23}.instance_of?(Integer) }
278
+ msg = 'Expected 1.23 to be an instance of Integer, not Float.'
261
279
  assert_equal msg, ex.message
262
280
  end
263
281
 
264
282
  it "calls refute_instance_of() after NOT() called." do
265
- should_not_raise { ok {123}.NOT.instance_of?(Integer) }
266
- ex = should_raise { ok {123}.NOT.instance_of?(Fixnum) }
267
- msg = 'Expected 123 to not be an instance of Fixnum.'
283
+ should_not_raise { ok {1.23}.NOT.instance_of?(Integer) }
284
+ ex = should_raise { ok {1.23}.NOT.instance_of?(Float) }
285
+ msg = 'Expected 1.23 to not be an instance of Float.'
268
286
  assert_equal msg, ex.message
269
287
  end
270
288
 
@@ -371,14 +389,26 @@ describe Minitest::Ok::AssertionObject do
371
389
  it "can take error message string in addition to exception class." do
372
390
  should_not_raise { ok {proc{1/0}}.raise?(ZeroDivisionError, "divided by 0") }
373
391
  ex = should_raise { ok {proc{1/0}}.raise?(ZeroDivisionError, "foobar") }
374
- expected = "Expected: \"foobar\"\n Actual: \"divided by 0\""
392
+ #expected = "Expected: \"foobar\"\n Actual: \"divided by 0\""
393
+ expected = [
394
+ '--- expected',
395
+ '+++ actual',
396
+ '@@ -1,2 +1,2 @@',
397
+ '-# encoding: UTF-8',
398
+ '-"foobar"',
399
+ '+# encoding: ASCII-8BIT',
400
+ '+"divided by 0"',
401
+ '',
402
+ ].join("\n")
375
403
  assert_equal expected, ex.message
376
404
  end
377
405
 
378
406
  it "can take error message regexp instead of string." do
379
407
  should_not_raise { ok {proc{1/0}}.raise?(ZeroDivisionError, /by [0]/) }
380
408
  ex = should_raise { ok {proc{1/0}}.raise?(ZeroDivisionError, /by 99/) }
381
- expected = "Expected /by 99/ to match \"divided by 0\"."
409
+ #expected = "Expected /by 99/ to match \"divided by 0\"."
410
+ expected = ('Expected /by 99/ to match # encoding: ASCII-8BIT'+"\n"+
411
+ '"divided by 0".')
382
412
  assert_equal expected, ex.message
383
413
  end
384
414
 
@@ -413,14 +443,14 @@ describe Minitest::Ok::AssertionObject do
413
443
  it "calls assert_respond_to()." do
414
444
  should_not_raise { ok {[1]}.respond_to?(:each) }
415
445
  ex = should_raise { ok {123}.respond_to?(:each) }
416
- msg = "Expected 123 (Fixnum) to respond to #each."
446
+ msg = "Expected 123 (#{1.class}) to respond to #each."
417
447
  assert_equal msg, ex.message
418
448
  end
419
449
 
420
450
  it "calls refute_respond_to() after NOT() called." do
421
451
  should_not_raise { ok {[1]}.respond_to?(:each) }
422
452
  ex = should_raise { ok {123}.respond_to?(:each) }
423
- msg = "Expected 123 (Fixnum) to respond to #each."
453
+ msg = "Expected 123 (#{1.class}) to respond to #each."
424
454
  assert_equal msg, ex.message
425
455
  end
426
456
 
@@ -470,11 +500,22 @@ describe Minitest::Ok::AssertionObject do
470
500
  it "calls assert_output()." do
471
501
  should_not_raise { ok {proc {puts 123}}.output?("123\n", "") }
472
502
  ex = should_raise { ok {proc {puts 123}}.output?("", "123\n") }
503
+ #msg = [
504
+ # 'In stderr.',
505
+ # '--- expected',
506
+ # '+++ actual',
507
+ # '@@ -1,2 +1 @@',
508
+ # '-"123',
509
+ # '-"',
510
+ # '+""',
511
+ # '',
512
+ #].join("\n")
473
513
  msg = [
474
514
  'In stderr.',
475
515
  '--- expected',
476
516
  '+++ actual',
477
- '@@ -1,2 +1 @@',
517
+ '@@ -1,3 +1 @@',
518
+ '-# encoding: UTF-8',
478
519
  '-"123',
479
520
  '-"',
480
521
  '+""',
@@ -499,11 +540,22 @@ describe Minitest::Ok::AssertionObject do
499
540
  it "calls assert_silent()." do
500
541
  should_not_raise { ok {proc {nil}}.silent? }
501
542
  ex = should_raise { ok {proc {puts 123}}.silent? }
543
+ #msg = [
544
+ # 'In stdout.',
545
+ # '--- expected',
546
+ # '+++ actual',
547
+ # '@@ -1 +1,2 @@',
548
+ # '-""',
549
+ # '+"123',
550
+ # '+"',
551
+ # '',
552
+ #].join("\n")
502
553
  msg = [
503
554
  'In stdout.',
504
555
  '--- expected',
505
556
  '+++ actual',
506
- '@@ -1 +1,2 @@',
557
+ '@@ -1,2 +1,2 @@',
558
+ '-# encoding: UTF-8',
507
559
  '-""',
508
560
  '+"123',
509
561
  '+"',
@@ -528,14 +580,18 @@ describe Minitest::Ok::AssertionObject do
528
580
  it "calls assert_predicate()." do
529
581
  should_not_raise { ok {"".freeze}.frozen? }
530
582
  ex = should_raise { ok {"".dup() }.frozen? }
531
- msg = 'Expected "" to be frozen?.'
583
+ #msg = 'Expected "" to be frozen?.'
584
+ msg = ('Expected # encoding: UTF-8'+"\n"+
585
+ '"" to be frozen?.')
532
586
  assert_equal msg, ex.message
533
587
  end
534
588
 
535
589
  it "calls refute_predicate() after NOT() called." do
536
590
  should_not_raise { ok {"".dup() }.NOT.frozen? }
537
591
  ex = should_raise { ok {"".freeze}.NOT.frozen? }
538
- msg = 'Expected "" to not be frozen?.'
592
+ #msg = 'Expected "" to not be frozen?.'
593
+ msg = ('Expected # encoding: UTF-8'+"\n"+
594
+ '"" to not be frozen?.')
539
595
  assert_equal msg, ex.message
540
596
  end
541
597
 
@@ -547,14 +603,18 @@ describe Minitest::Ok::AssertionObject do
547
603
  it "calls assert_predicate()." do
548
604
  should_not_raise { ok {"".taint}.tainted? }
549
605
  ex = should_raise { ok {"".dup()}.tainted? }
550
- msg = 'Expected "" to be tainted?.'
606
+ #msg = 'Expected "" to be tainted?.'
607
+ msg = ('Expected # encoding: UTF-8'+"\n"+
608
+ '"" to be tainted?.')
551
609
  assert_equal msg, ex.message
552
610
  end
553
611
 
554
612
  it "calls refute_predicate() after NOT() called." do
555
613
  should_not_raise { ok {"".dup()}.NOT.tainted? }
556
614
  ex = should_raise { ok {"".taint}.NOT.tainted? }
557
- msg = 'Expected "" to not be tainted?.'
615
+ #msg = 'Expected "" to not be tainted?.'
616
+ msg = ('Expected # encoding: UTF-8'+"\n"+
617
+ '"" to not be tainted?.')
558
618
  assert_equal msg, ex.message
559
619
  end
560
620
 
@@ -694,7 +754,7 @@ describe Minitest::Ok::AssertionObject do
694
754
 
695
755
  describe '#attr' do
696
756
 
697
- class User
757
+ class User1
698
758
  def initialize(name, age)
699
759
  @name, @age = name, age
700
760
  end
@@ -702,24 +762,24 @@ describe Minitest::Ok::AssertionObject do
702
762
  end
703
763
 
704
764
  it "calles assert_equal()." do
705
- user = User.new('Haruhi', 16)
765
+ user = User1.new('Haruhi', 16)
706
766
  should_not_raise { ok {user}.attr(:name, 'Haruhi').attr(:age, 16) }
707
767
  ex = should_raise { ok {user}.attr(:name, 'Haruhi').attr(:age, 12) }
708
768
  msg = ("Expected <object>.age == <exected>, but failed.\n" +
709
- " (object: #<User:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
769
+ " (object: #<User1:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
710
770
  "Expected: 12\n" +
711
771
  " Actual: 16")
712
- assert_equal msg, ex.message.gsub(/<User:0x\w+/, '<User:0xXXXXXX')
772
+ assert_equal msg, ex.message.gsub(/<User1:0x\w+/, '<User1:0xXXXXXX')
713
773
  end
714
774
 
715
775
  it "calles refute_equal() after NOT() called." do
716
- user = User.new('Haruhi', 16)
776
+ user = User1.new('Haruhi', 16)
717
777
  should_not_raise { ok {user}.NOT.attr(:name, 'Suzumiya').attr(:age, 12) }
718
778
  ex = should_raise { ok {user}.NOT.attr(:name, 'Suzumiya').attr(:age, 16) }
719
779
  msg = ("Expected <object>.age != <exected>, but failed.\n" +
720
- " (object: #<User:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
780
+ " (object: #<User1:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
721
781
  "Expected 16 to not be equal to 16.")
722
- assert_equal msg, ex.message.gsub(/<User:0x\w+/, '<User:0xXXXXXX')
782
+ assert_equal msg, ex.message.gsub(/<User1:0x\w+/, '<User1:0xXXXXXX')
723
783
  end
724
784
 
725
785
  end
@@ -727,7 +787,7 @@ describe Minitest::Ok::AssertionObject do
727
787
 
728
788
  describe '#attrs' do
729
789
 
730
- class User
790
+ class User2
731
791
  def initialize(name, age)
732
792
  @name, @age = name, age
733
793
  end
@@ -735,24 +795,24 @@ describe Minitest::Ok::AssertionObject do
735
795
  end
736
796
 
737
797
  it "calles assert_equal()." do
738
- user = User.new('Haruhi', 16)
798
+ user = User2.new('Haruhi', 16)
739
799
  should_not_raise { ok {user}.attrs(name: 'Haruhi', age: 16) }
740
800
  ex = should_raise { ok {user}.attrs(name: 'Haruhi', age: 12) }
741
801
  msg = ("Expected <object>.age == <exected>, but failed.\n" +
742
- " (object: #<User:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
802
+ " (object: #<User2:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
743
803
  "Expected: 12\n" +
744
804
  " Actual: 16")
745
- assert_equal msg, ex.message.gsub(/<User:0x\w+/, '<User:0xXXXXXX')
805
+ assert_equal msg, ex.message.gsub(/<User2:0x\w+/, '<User2:0xXXXXXX')
746
806
  end
747
807
 
748
808
  it "calles refute_equal() after NOT() called." do
749
- user = User.new('Haruhi', 16)
809
+ user = User2.new('Haruhi', 16)
750
810
  should_not_raise { ok {user}.NOT.attrs(name: 'Suzumiya', age: 12) }
751
811
  ex = should_raise { ok {user}.NOT.attrs(name: 'Suzumiya', age: 16) }
752
812
  msg = ("Expected <object>.age != <exected>, but failed.\n" +
753
- " (object: #<User:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
813
+ " (object: #<User2:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
754
814
  "Expected 16 to not be equal to 16.")
755
- assert_equal msg, ex.message.gsub(/<User:0x\w+/, '<User:0xXXXXXX')
815
+ assert_equal msg, ex.message.gsub(/<User2:0x\w+/, '<User2:0xXXXXXX')
756
816
  end
757
817
 
758
818
  end
data/test/test_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 0.2.0 $
4
+ ### $Release: 0.3.0 $
5
5
  ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-ok
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - makoto kuwata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-06 00:00:00.000000000 Z
11
+ date: 2018-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description: |
@@ -38,12 +38,12 @@ executables: []
38
38
  extensions: []
39
39
  extra_rdoc_files: []
40
40
  files:
41
- - README.md
42
41
  - MIT-LICENSE
42
+ - README.md
43
43
  - Rakefile
44
44
  - lib/minitest/ok.rb
45
- - test/test_helper.rb
46
45
  - test/minitest/ok_test.rb
46
+ - test/test_helper.rb
47
47
  homepage: https://github.com/kwatch/minitest-ok
48
48
  licenses:
49
49
  - MIT-License
@@ -54,18 +54,18 @@ require_paths:
54
54
  - lib
55
55
  required_ruby_version: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - '>='
57
+ - - ">="
58
58
  - !ruby/object:Gem::Version
59
59
  version: '1.9'
60
60
  required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - '>='
62
+ - - ">="
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  requirements: []
66
66
  rubyforge_project:
67
- rubygems_version: 2.0.14.1
67
+ rubygems_version: 2.5.2.3
68
68
  signing_key:
69
69
  specification_version: 4
70
- summary: '''ok {1+1} == 2'' instead of ''assert_equal 2, 1+1'''
70
+ summary: "'ok {1+1} == 2' instead of 'assert_equal 2, 1+1'"
71
71
  test_files: []