minitest-ok 0.2.0 → 0.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0393c06bdcd679080b979ab6d402b16363b9ac52
4
- data.tar.gz: 6c0f9dbd1af465ca6601b8be8cadad2809e8393f
2
+ SHA256:
3
+ metadata.gz: 24fede07b5dfd3ba6329ea3f9eec222be7bbd7448cec333211193f249d182acf
4
+ data.tar.gz: d6fce3aa578e6ca8abbb828216c52c2316f9b2259693930ccd1af93bbe93e701
5
5
  SHA512:
6
- metadata.gz: 08609c6a464436a7ab37ff3045bdcf18dd7d1b9360c728609251ef1e0e7ab3f76983de8a2569cca55f68dbd62a768dddbc8d785fbbf40031253d263e70acb918
7
- data.tar.gz: e869d5d3fcb907eb6ae6aae167f1f1313f25220009e5c8e7880f3e36cb4629897c10e440002f7fbc23baaeb307e670bbb2f88ca03d9c4e2fb3181c40c0615ae5
6
+ metadata.gz: 1654cdcdc41ab3a0e8c5947e7566ca2906ef23604c823791d053c669071ff62a03b5c9c6016d88908a0d41035bc783f53b62a2c83f6a8ae57b247c1f50e3936b
7
+ data.tar.gz: 36b1f25a7fad593a38978931d3dd76e96c1e5279f1262dc508a0f087496ab09ecca848a45769d7585a22731262b55bb98b39224daa269e9c763f5812fe71496a
data/README.md CHANGED
@@ -85,8 +85,8 @@ describe 'Minitest::Ok' do
85
85
  ok {123}.truthy? # similar to assert 123
86
86
  ok {0}.truthy? # similar to assert 0
87
87
  ok {""}.truthy? # similar to assert ""
88
- ok {false}.falthy? # similar to refute false
89
- ok {nil}.falthy? # similar to refute nil
88
+ ok {false}.falsy? # similar to refute false
89
+ ok {nil}.falsy? # similar to refute nil
90
90
 
91
91
  ## predicates
92
92
  ok {""}.empty? # same as assert_empty? ""
@@ -138,6 +138,28 @@ $License: MIT License $
138
138
 
139
139
  ## History
140
140
 
141
+ ### 2021-08-02: Release 0.3.3
142
+
143
+ * [bugfix] rename 'ok {}.falthy?' to 'ok {}.falsy?'.
144
+
145
+
146
+ ### 2021-01-17: Release 0.3.2
147
+
148
+ * [bugfix] fix to work on Ruby 3.
149
+
150
+
151
+ ### 2018-11-13: Release 0.3.1
152
+
153
+ * [bugfix] add change history to README.
154
+ * [bugfix] update copyright year.
155
+
156
+
157
+ ### 2018-11-12: Release 0.3.0
158
+
159
+ * [bugfix] `ok {}` shows filename and lineno correctly error happened.
160
+ * [change] `ok {} == nil` calls `assert_nil()` instead of `assert_equal()`.
161
+ * [bugfix] update test script to run successfully on recent ruby.
162
+
141
163
 
142
164
  ### 2016-09-07: Release 0.2.0
143
165
 
data/Rakefile CHANGED
@@ -39,18 +39,21 @@ desc "edit files (for release preparation)"
39
39
  task :edit do
40
40
  rel = ENV['rel'] or
41
41
  raise "ERROR: 'rel' environment variable expected."
42
+ copyright = "copyright(c) 2015-2018 kuwata-lab.com all rights reserved"
42
43
  filenames = Dir[*%w[lib/**/*.rb test/**/*_test.rb test/test_helper.rb *.gemspec]]
43
44
  filenames.each do |fname|
44
45
  File.open(fname, 'r+', encoding: 'utf-8') do |f|
45
46
  content = f.read()
46
- x = content.gsub!(/\$Release:.*?\$/, "$Release: #{rel} $")
47
- if x.nil?
47
+ x = content
48
+ x = x.gsub(/\$Release:.*?\$/, "$Release: #{rel} $")
49
+ x = x.gsub(/\$Copyright:.*?\$/, "$Copyright: #{copyright} $")
50
+ if x == content
48
51
  puts "[_] #{fname}"
49
52
  else
50
53
  puts "[C] #{fname}"
51
54
  f.rewind()
52
55
  f.truncate(0)
53
- f.write(content)
56
+ f.write(x)
54
57
  end
55
58
  end
56
59
  end
data/lib/minitest/ok.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 0.2.0 $
5
- ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 0.3.3 $
5
+ ### $Copyright: copyright(c) 2015-2018 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -34,7 +34,7 @@ module Minitest
34
34
  ## ok {1..9}.include?(5) # same as assert_includes 5, 1..9
35
35
  ## ok {1..9}.NOT.include?(0) # same as refute_includes 0, 1..9
36
36
  ## ok {""}.truthy? # same as assert true, !!""
37
- ## ok {nil}.falthy? # same as assert false, !!""
37
+ ## ok {nil}.falsy? # same as assert false, !!""
38
38
  ##
39
39
  ## ex = ok { proc { 1 / 0 } }.raise?(ZeroDivisionError, "divided by 0")
40
40
  ## p ex #=> #<ZeroDivisionError: divided by 0>
@@ -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.3 $'.split()[1]
63
63
 
64
64
 
65
65
  class Msg < Proc # :nodoc:
@@ -75,12 +75,16 @@ module Minitest
75
75
  @context = context
76
76
  @not = false
77
77
  @tested = tested = [false]
78
- ObjectSpace.define_finalizer(self, proc {
78
+ ObjectSpace.define_finalizer(self, self.class._finalizer_callback(tested, location))
79
+ end
80
+
81
+ def self._finalizer_callback(tested, location) # :nodoc:
82
+ return proc do
79
83
  unless tested[0]
80
84
  loc = location.to_s.split(/:in /).first
81
85
  $stderr.puts "** WARNING: ok() called but no assertion invoked (#{loc})"
82
86
  end
83
- })
87
+ end
84
88
  end
85
89
 
86
90
  def _mark_as_tested # :nodoc:
@@ -111,9 +115,17 @@ module Minitest
111
115
  ##
112
116
  def ==(expected)
113
117
  _mark_as_tested()
114
- @context.assert_equal expected, @actual unless @not
115
- @context.refute_equal expected, @actual if @not
118
+ if nil == expected
119
+ @context.assert_nil @actual unless @not
120
+ @context.refute_nil @actual if @not
121
+ else
122
+ @context.assert_equal expected, @actual unless @not
123
+ @context.refute_equal expected, @actual if @not
124
+ end
116
125
  self
126
+ rescue Minitest::Assertion => ex
127
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
128
+ raise
117
129
  end
118
130
 
119
131
  ##
@@ -127,6 +139,9 @@ module Minitest
127
139
  @context.refute_equal expected, @actual unless @not
128
140
  @context.assert_equal expected, @actual if @not
129
141
  self
142
+ rescue Minitest::Assertion => ex
143
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
144
+ raise
130
145
  end
131
146
 
132
147
  ##
@@ -141,6 +156,9 @@ module Minitest
141
156
  @context.assert_operator @actual, :'>', expected unless @not
142
157
  @context.refute_operator @actual, :'>', expected if @not
143
158
  self
159
+ rescue Minitest::Assertion => ex
160
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
161
+ raise
144
162
  end
145
163
 
146
164
  ##
@@ -155,6 +173,9 @@ module Minitest
155
173
  @context.assert_operator @actual, :'>=', expected unless @not
156
174
  @context.refute_operator @actual, :'>=', expected if @not
157
175
  self
176
+ rescue Minitest::Assertion => ex
177
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
178
+ raise
158
179
  end
159
180
 
160
181
  ##
@@ -169,6 +190,9 @@ module Minitest
169
190
  @context.assert_operator @actual, :'<', expected unless @not
170
191
  @context.refute_operator @actual, :'<', expected if @not
171
192
  self
193
+ rescue Minitest::Assertion => ex
194
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
195
+ raise
172
196
  end
173
197
 
174
198
  ##
@@ -183,6 +207,9 @@ module Minitest
183
207
  @context.assert_operator @actual, :'<=', expected unless @not
184
208
  @context.refute_operator @actual, :'<=', expected if @not
185
209
  self
210
+ rescue Minitest::Assertion => ex
211
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
212
+ raise
186
213
  end
187
214
 
188
215
  ##
@@ -196,6 +223,9 @@ module Minitest
196
223
  @context.assert_operator @actual, :'===', expected unless @not
197
224
  @context.refute_operator @actual, :'===', expected if @not
198
225
  self
226
+ rescue Minitest::Assertion => ex
227
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
228
+ raise
199
229
  end
200
230
 
201
231
  ##
@@ -209,6 +239,9 @@ module Minitest
209
239
  @context.assert_match expected, @actual unless @not
210
240
  @context.refute_match expected, @actual if @not
211
241
  self
242
+ rescue Minitest::Assertion => ex
243
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
244
+ raise
212
245
  end
213
246
 
214
247
  ##
@@ -222,6 +255,9 @@ module Minitest
222
255
  @context.refute_match expected, @actual unless @not
223
256
  @context.assert_match expected, @actual if @not
224
257
  self
258
+ rescue Minitest::Assertion => ex
259
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
260
+ raise
225
261
  end
226
262
 
227
263
  ##
@@ -236,6 +272,9 @@ module Minitest
236
272
  @context.assert_kind_of expected, @actual unless @not
237
273
  @context.refute_kind_of expected, @actual if @not
238
274
  self
275
+ rescue Minitest::Assertion => ex
276
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
277
+ raise
239
278
  end
240
279
 
241
280
  ##
@@ -258,6 +297,9 @@ module Minitest
258
297
  @context.assert_instance_of expected, @actual unless @not
259
298
  @context.refute_instance_of expected, @actual if @not
260
299
  self
300
+ rescue Minitest::Assertion => ex
301
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
302
+ raise
261
303
  end
262
304
 
263
305
  ##
@@ -273,6 +315,9 @@ module Minitest
273
315
  @context.assert_same expected, @actual unless @not
274
316
  @context.refute_same expected, @actual if @not
275
317
  self
318
+ rescue Minitest::Assertion => ex
319
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
320
+ raise
276
321
  end
277
322
 
278
323
  ##
@@ -288,6 +333,9 @@ module Minitest
288
333
  @context.assert_empty @actual unless @not
289
334
  @context.refute_empty @actual if @not
290
335
  self
336
+ rescue Minitest::Assertion => ex
337
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
338
+ raise
291
339
  end
292
340
 
293
341
  ##
@@ -301,6 +349,9 @@ module Minitest
301
349
  @context.assert_in_delta(expected, @actual, delta) unless @not
302
350
  @context.refute_in_delta(expected, @actual, delta) if @not
303
351
  self
352
+ rescue Minitest::Assertion => ex
353
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
354
+ raise
304
355
  end
305
356
 
306
357
  ##
@@ -314,6 +365,9 @@ module Minitest
314
365
  @context.assert_in_epsilon(expected, @actual, epsilon) unless @not
315
366
  @context.refute_in_epsilon(expected, @actual, epsilon) if @not
316
367
  self
368
+ rescue Minitest::Assertion => ex
369
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
370
+ raise
317
371
  end
318
372
 
319
373
  ##
@@ -348,6 +402,9 @@ module Minitest
348
402
  end
349
403
  end
350
404
  return ex # not self!
405
+ rescue Minitest::Assertion => ex
406
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
407
+ raise
351
408
  end
352
409
 
353
410
  ##
@@ -362,6 +419,9 @@ module Minitest
362
419
  raise "NOT.throw? is unsupported because refute_throws() is not defined in Minitest."
363
420
  @context.assert_throws(sym) { @actual.call }
364
421
  self
422
+ rescue Minitest::Assertion => ex
423
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
424
+ raise
365
425
  end
366
426
 
367
427
  ##
@@ -375,6 +435,9 @@ module Minitest
375
435
  @context.assert_respond_to @actual, expected unless @not
376
436
  @context.refute_respond_to @actual, expected if @not
377
437
  self
438
+ rescue Minitest::Assertion => ex
439
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
440
+ raise
378
441
  end
379
442
 
380
443
  ##
@@ -389,6 +452,9 @@ module Minitest
389
452
  @context.assert_includes @actual, expected unless @not
390
453
  @context.refute_includes @actual, expected if @not
391
454
  self
455
+ rescue Minitest::Assertion => ex
456
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
457
+ raise
392
458
  end
393
459
 
394
460
  ##
@@ -403,6 +469,9 @@ module Minitest
403
469
  @context.assert_includes expected, @actual unless @not
404
470
  @context.refute_includes expected, @actual if @not
405
471
  self
472
+ rescue Minitest::Assertion => ex
473
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
474
+ raise
406
475
  end
407
476
 
408
477
  ##
@@ -417,6 +486,9 @@ module Minitest
417
486
  raise "use ok().silent? instead of ok().NOT.output?."
418
487
  @context.assert_output(stdout, stderr, &@actual)
419
488
  self
489
+ rescue Minitest::Assertion => ex
490
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
491
+ raise
420
492
  end
421
493
 
422
494
  ##
@@ -431,6 +503,9 @@ module Minitest
431
503
  raise "use ok().output? instead of ok().NOT.silent?."
432
504
  @context.assert_silent(&@actual)
433
505
  self
506
+ rescue Minitest::Assertion => ex
507
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
508
+ raise
434
509
  end
435
510
 
436
511
  ## for predicates
@@ -446,6 +521,9 @@ module Minitest
446
521
  @context.assert_predicate @actual, :frozen? unless @not
447
522
  @context.refute_predicate @actual, :frozen? if @not
448
523
  self
524
+ rescue Minitest::Assertion => ex
525
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
526
+ raise
449
527
  end
450
528
 
451
529
  ##
@@ -459,6 +537,9 @@ module Minitest
459
537
  @context.assert_predicate @actual, :tainted? unless @not
460
538
  @context.refute_predicate @actual, :tainted? if @not
461
539
  self
540
+ rescue Minitest::Assertion => ex
541
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
542
+ raise
462
543
  end
463
544
 
464
545
  ##
@@ -478,6 +559,9 @@ module Minitest
478
559
  @context.refute result, "Expected #{@actual.inspect} not to have instance variable #{varname}, but has it."
479
560
  end
480
561
  self
562
+ rescue Minitest::Assertion => ex
563
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
564
+ raise
481
565
  end
482
566
 
483
567
  ##
@@ -512,6 +596,9 @@ module Minitest
512
596
  end
513
597
  end
514
598
  self
599
+ rescue Minitest::Assertion => ex
600
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
601
+ raise
515
602
  end
516
603
 
517
604
  ## other helpers
@@ -534,19 +621,22 @@ module Minitest
534
621
  @context.refute @actual, Msg.new { "Expected (!! #{@actual.inspect}) == false, but not." }
535
622
  end
536
623
  self
624
+ rescue Minitest::Assertion => ex
625
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
626
+ raise
537
627
  end
538
628
 
539
629
  ##
540
630
  ## Tests whether actual is false or nil.
541
631
  ##
542
- ## ok {nil}.falthy? # Pass
543
- ## ok {false}.falthy? # Pass
544
- ## ok {true}.falthy? # Fail
545
- ## ok {0}.falthy? # Fail
546
- ## ok {""}.falthy? # Fail
547
- ## ok {[]}.falthy? # Fail
632
+ ## ok {nil}.falsy? # Pass
633
+ ## ok {false}.falsy? # Pass
634
+ ## ok {true}.falsy? # Fail
635
+ ## ok {0}.falsy? # Fail
636
+ ## ok {""}.falsy? # Fail
637
+ ## ok {[]}.falsy? # Fail
548
638
  ##
549
- def falthy?
639
+ def falsy?
550
640
  _mark_as_tested()
551
641
  unless @not
552
642
  @context.refute @actual, Msg.new { "Expected (!! #{@actual.inspect}) == false, but not." }
@@ -554,7 +644,11 @@ module Minitest
554
644
  @context.assert @actual, Msg.new { "Expected (!! #{@actual.inspect}) == true, but not." }
555
645
  end
556
646
  self
647
+ rescue Minitest::Assertion => ex
648
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
649
+ raise
557
650
  end
651
+ alias falthy? falsy?
558
652
 
559
653
  ##
560
654
  ## Tests attribute value.
@@ -574,6 +668,9 @@ module Minitest
574
668
  @context.assert_equal expected, actual, Msg.new { pr.call('==') } unless @not
575
669
  @context.refute_equal expected, actual, Msg.new { pr.call('!=') } if @not
576
670
  self
671
+ rescue Minitest::Assertion => ex
672
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
673
+ raise
577
674
  end
578
675
 
579
676
  ##
@@ -589,6 +686,9 @@ module Minitest
589
686
  attr(name, expected)
590
687
  end
591
688
  self
689
+ rescue Minitest::Assertion => ex
690
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
691
+ raise
592
692
  end
593
693
 
594
694
  ##
@@ -608,6 +708,9 @@ module Minitest
608
708
  @context.assert_equal expected, actual, Msg.new { pr.call('==') } unless @not
609
709
  @context.refute_equal expected, actual, Msg.new { pr.call('!=') } if @not
610
710
  self
711
+ rescue Minitest::Assertion => ex
712
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
713
+ raise
611
714
  end
612
715
 
613
716
  ##
@@ -622,6 +725,9 @@ module Minitest
622
725
  item(key, expected)
623
726
  end
624
727
  self
728
+ rescue Minitest::Assertion => ex
729
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
730
+ raise
625
731
  end
626
732
 
627
733
  ##
@@ -640,6 +746,9 @@ module Minitest
640
746
  else
641
747
  @context.refute File.exist?(fpath), "File '#{fpath}' exists unexpectedly."
642
748
  end
749
+ rescue Minitest::Assertion => ex
750
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
751
+ raise
643
752
  end
644
753
 
645
754
  ##
@@ -658,6 +767,9 @@ module Minitest
658
767
  else
659
768
  @context.refute File.exist?(fpath), "Directory '#{fpath}' exists unexpectedly."
660
769
  end
770
+ rescue Minitest::Assertion => ex
771
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
772
+ raise
661
773
  end
662
774
 
663
775
  ##
@@ -673,6 +785,9 @@ module Minitest
673
785
  @context.assert ! File.exist?(fpath), "'#{fpath}' exists unexpectedly." unless @not
674
786
  @context.refute ! File.exist?(fpath), "'#{fpath}' doesn't exist." if @not
675
787
  self
788
+ rescue Minitest::Assertion => ex
789
+ ex.backtrace.delete_if {|bt| bt.start_with?(__FILE__) }
790
+ raise
676
791
  end
677
792
 
678
793
  end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 0.2.0 $
5
- ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 0.3.3 $
5
+ ### $Copyright: copyright(c) 2015-2018 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
@@ -16,7 +16,8 @@ describe Minitest::Ok::AssertionObject do
16
16
  begin
17
17
  yield
18
18
  rescue Exception => ex
19
- assert false, "Nothing should not be raised, but #{ex.class} raised.\n[Message] #{ex}"
19
+ _called = caller(1).grep(/ok_test\.rb/).map {|x| " - #{x}" }.join("\n")
20
+ assert false, "Nothing should not be raised, but #{ex.class} raised.\n#{_called}\n[Message] #{ex}"
20
21
  end
21
22
  end
22
23
 
@@ -26,7 +27,8 @@ describe Minitest::Ok::AssertionObject do
26
27
  rescue Minitest::Assertion => ex
27
28
  return ex
28
29
  else
29
- assert false, "Assertion should be raised, but nothing raised."
30
+ _called = caller(1).grep(/ok_test\.rb/).map {|x| " - #{x}" }.join("\n")
31
+ assert false, "Assertion should be raised, but nothing raised.\n#{_called}"
30
32
  end
31
33
  end
32
34
 
@@ -170,6 +172,8 @@ describe Minitest::Ok::AssertionObject do
170
172
  should_not_raise { ok {/\d+/ }.NOT === 'abc' }
171
173
  ex = should_raise { ok {String}.NOT === '123' }
172
174
  msg = 'Expected String to not be === "123".'
175
+ #msg = ('Expected String to not be === # encoding: UTF-8'+"\n"+
176
+ # '"123".')
173
177
  assert_equal msg, ex.message
174
178
  end
175
179
 
@@ -182,6 +186,8 @@ describe Minitest::Ok::AssertionObject do
182
186
  should_not_raise { ok {"hom"} =~ /\w+/ }
183
187
  ex = should_raise { ok {"hom"} =~ /\d+/ }
184
188
  msg = 'Expected /\d+/ to match "hom".'
189
+ #msg = ('Expected /\d+/ to match # encoding: UTF-8'+"\n"+
190
+ # '"hom".')
185
191
  assert_equal msg, ex.message
186
192
  end
187
193
 
@@ -189,6 +195,8 @@ describe Minitest::Ok::AssertionObject do
189
195
  should_not_raise { ok {"hom"}.NOT =~ /\d+/ }
190
196
  ex = should_raise { ok {"hom"}.NOT =~ /\w+/ }
191
197
  msg = 'Expected /\w+/ to not match "hom".'
198
+ #msg = ('Expected /\w+/ to not match # encoding: UTF-8'+"\n"+
199
+ # '"hom".')
192
200
  assert_equal msg, ex.message
193
201
  end
194
202
 
@@ -201,6 +209,8 @@ describe Minitest::Ok::AssertionObject do
201
209
  should_not_raise { ok {"hom"} !~ /\d+/ }
202
210
  ex = should_raise { ok {"hom"} !~ /\w+/ }
203
211
  msg = 'Expected /\w+/ to not match "hom".'
212
+ #msg = ('Expected /\w+/ to not match # encoding: UTF-8'+"\n"+
213
+ # '"hom".')
204
214
  assert_equal msg, ex.message
205
215
  end
206
216
 
@@ -208,6 +218,8 @@ describe Minitest::Ok::AssertionObject do
208
218
  should_not_raise { ok {"hom"}.NOT !~ /\w+/ }
209
219
  ex = should_raise { ok {"hom"}.NOT !~ /\d+/ }
210
220
  msg = 'Expected /\d+/ to match "hom".'
221
+ #msg = ('Expected /\d+/ to match # encoding: UTF-8'+"\n"+
222
+ # '"hom".')
211
223
  assert_equal msg, ex.message
212
224
  end
213
225
 
@@ -220,6 +232,8 @@ describe Minitest::Ok::AssertionObject do
220
232
  should_not_raise { ok {"hom"}.is_a?(String) }
221
233
  ex = should_raise { ok {"hom"}.is_a?(Array) }
222
234
  msg = 'Expected "hom" to be a kind of Array, not String.'
235
+ #msg = ('Expected # encoding: UTF-8'+"\n"+
236
+ # '"hom" to be a kind of Array, not String.')
223
237
  assert_equal msg, ex.message
224
238
  end
225
239
 
@@ -227,6 +241,8 @@ describe Minitest::Ok::AssertionObject do
227
241
  should_not_raise { ok {"hom"}.NOT.is_a?(Array) }
228
242
  ex = should_raise { ok {"hom"}.NOT.is_a?(String) }
229
243
  msg = 'Expected "hom" to not be a kind of String.'
244
+ #msg = ('Expected # encoding: UTF-8'+"\n"+
245
+ # '"hom" to not be a kind of String.')
230
246
  assert_equal msg, ex.message
231
247
  end
232
248
 
@@ -239,6 +255,8 @@ describe Minitest::Ok::AssertionObject do
239
255
  should_not_raise { ok {"hom"}.kind_of?(String) }
240
256
  ex = should_raise { ok {"hom"}.kind_of?(Array) }
241
257
  msg = 'Expected "hom" to be a kind of Array, not String.'
258
+ #msg = ('Expected # encoding: UTF-8'+"\n"+
259
+ # '"hom" to be a kind of Array, not String.')
242
260
  assert_equal msg, ex.message
243
261
  end
244
262
 
@@ -246,6 +264,8 @@ describe Minitest::Ok::AssertionObject do
246
264
  should_not_raise { ok {"hom"}.NOT.kind_of?(Array) }
247
265
  ex = should_raise { ok {"hom"}.NOT.kind_of?(String) }
248
266
  msg = 'Expected "hom" to not be a kind of String.'
267
+ #msg = ('Expected # encoding: UTF-8'+"\n"+
268
+ # '"hom" to not be a kind of String.')
249
269
  assert_equal msg, ex.message
250
270
  end
251
271
 
@@ -255,16 +275,16 @@ describe Minitest::Ok::AssertionObject do
255
275
  describe '#instance_of?' do
256
276
 
257
277
  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.'
278
+ should_not_raise { ok {1.23}.instance_of?(Float) }
279
+ ex = should_raise { ok {1.23}.instance_of?(Integer) }
280
+ msg = 'Expected 1.23 to be an instance of Integer, not Float.'
261
281
  assert_equal msg, ex.message
262
282
  end
263
283
 
264
284
  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.'
285
+ should_not_raise { ok {1.23}.NOT.instance_of?(Integer) }
286
+ ex = should_raise { ok {1.23}.NOT.instance_of?(Float) }
287
+ msg = 'Expected 1.23 to not be an instance of Float.'
268
288
  assert_equal msg, ex.message
269
289
  end
270
290
 
@@ -371,14 +391,29 @@ describe Minitest::Ok::AssertionObject do
371
391
  it "can take error message string in addition to exception class." do
372
392
  should_not_raise { ok {proc{1/0}}.raise?(ZeroDivisionError, "divided by 0") }
373
393
  ex = should_raise { ok {proc{1/0}}.raise?(ZeroDivisionError, "foobar") }
374
- expected = "Expected: \"foobar\"\n Actual: \"divided by 0\""
394
+ #expected = "Expected: \"foobar\"\n Actual: \"divided by 0\""
395
+ expected = [
396
+ '--- expected',
397
+ '+++ actual',
398
+ #'@@ -1,2 +1,2 @@',
399
+ #'-# encoding: UTF-8',
400
+ '@@ -1 +1,3 @@',
401
+ '-"foobar"',
402
+ '+# encoding: ASCII-8BIT',
403
+ '+# valid: true',
404
+ '+"divided by 0"',
405
+ '',
406
+ ].join("\n")
375
407
  assert_equal expected, ex.message
376
408
  end
377
409
 
378
410
  it "can take error message regexp instead of string." do
379
411
  should_not_raise { ok {proc{1/0}}.raise?(ZeroDivisionError, /by [0]/) }
380
412
  ex = should_raise { ok {proc{1/0}}.raise?(ZeroDivisionError, /by 99/) }
381
- expected = "Expected /by 99/ to match \"divided by 0\"."
413
+ #expected = "Expected /by 99/ to match \"divided by 0\"."
414
+ expected = ('Expected /by 99/ to match # encoding: ASCII-8BIT'+"\n"+
415
+ '# valid: true'+"\n"+
416
+ '"divided by 0".')
382
417
  assert_equal expected, ex.message
383
418
  end
384
419
 
@@ -413,14 +448,14 @@ describe Minitest::Ok::AssertionObject do
413
448
  it "calls assert_respond_to()." do
414
449
  should_not_raise { ok {[1]}.respond_to?(:each) }
415
450
  ex = should_raise { ok {123}.respond_to?(:each) }
416
- msg = "Expected 123 (Fixnum) to respond to #each."
451
+ msg = "Expected 123 (#{1.class}) to respond to #each."
417
452
  assert_equal msg, ex.message
418
453
  end
419
454
 
420
455
  it "calls refute_respond_to() after NOT() called." do
421
456
  should_not_raise { ok {[1]}.respond_to?(:each) }
422
457
  ex = should_raise { ok {123}.respond_to?(:each) }
423
- msg = "Expected 123 (Fixnum) to respond to #each."
458
+ msg = "Expected 123 (#{1.class}) to respond to #each."
424
459
  assert_equal msg, ex.message
425
460
  end
426
461
 
@@ -470,10 +505,22 @@ describe Minitest::Ok::AssertionObject do
470
505
  it "calls assert_output()." do
471
506
  should_not_raise { ok {proc {puts 123}}.output?("123\n", "") }
472
507
  ex = should_raise { ok {proc {puts 123}}.output?("", "123\n") }
508
+ #msg = [
509
+ # 'In stderr.',
510
+ # '--- expected',
511
+ # '+++ actual',
512
+ # '@@ -1,2 +1 @@',
513
+ # '-"123',
514
+ # '-"',
515
+ # '+""',
516
+ # '',
517
+ #].join("\n")
473
518
  msg = [
474
519
  'In stderr.',
475
520
  '--- expected',
476
521
  '+++ actual',
522
+ #'@@ -1,3 +1 @@',
523
+ #'-# encoding: UTF-8',
477
524
  '@@ -1,2 +1 @@',
478
525
  '-"123',
479
526
  '-"',
@@ -499,10 +546,22 @@ describe Minitest::Ok::AssertionObject do
499
546
  it "calls assert_silent()." do
500
547
  should_not_raise { ok {proc {nil}}.silent? }
501
548
  ex = should_raise { ok {proc {puts 123}}.silent? }
549
+ #msg = [
550
+ # 'In stdout.',
551
+ # '--- expected',
552
+ # '+++ actual',
553
+ # '@@ -1 +1,2 @@',
554
+ # '-""',
555
+ # '+"123',
556
+ # '+"',
557
+ # '',
558
+ #].join("\n")
502
559
  msg = [
503
560
  'In stdout.',
504
561
  '--- expected',
505
562
  '+++ actual',
563
+ #'@@ -1,2 +1,2 @@',
564
+ #'-# encoding: UTF-8',
506
565
  '@@ -1 +1,2 @@',
507
566
  '-""',
508
567
  '+"123',
@@ -529,6 +588,8 @@ describe Minitest::Ok::AssertionObject do
529
588
  should_not_raise { ok {"".freeze}.frozen? }
530
589
  ex = should_raise { ok {"".dup() }.frozen? }
531
590
  msg = 'Expected "" to be frozen?.'
591
+ #msg = ('Expected # encoding: UTF-8'+"\n"+
592
+ # '"" to be frozen?.')
532
593
  assert_equal msg, ex.message
533
594
  end
534
595
 
@@ -536,6 +597,8 @@ describe Minitest::Ok::AssertionObject do
536
597
  should_not_raise { ok {"".dup() }.NOT.frozen? }
537
598
  ex = should_raise { ok {"".freeze}.NOT.frozen? }
538
599
  msg = 'Expected "" to not be frozen?.'
600
+ #msg = ('Expected # encoding: UTF-8'+"\n"+
601
+ # '"" to not be frozen?.')
539
602
  assert_equal msg, ex.message
540
603
  end
541
604
 
@@ -545,16 +608,16 @@ describe Minitest::Ok::AssertionObject do
545
608
  describe '#tainted?' do
546
609
 
547
610
  it "calls assert_predicate()." do
548
- should_not_raise { ok {"".taint}.tainted? }
549
- ex = should_raise { ok {"".dup()}.tainted? }
550
- msg = 'Expected "" to be tainted?.'
611
+ should_not_raise { ok {[ ]}.empty? }
612
+ ex = should_raise { ok {[1]}.empty? }
613
+ msg = "Expected [1] to be empty."
551
614
  assert_equal msg, ex.message
552
615
  end
553
616
 
554
617
  it "calls refute_predicate() after NOT() called." do
555
- should_not_raise { ok {"".dup()}.NOT.tainted? }
556
- ex = should_raise { ok {"".taint}.NOT.tainted? }
557
- msg = 'Expected "" to not be tainted?.'
618
+ should_not_raise { ok {[1]}.NOT.empty? }
619
+ ex = should_raise { ok {[ ]}.NOT.empty? }
620
+ msg = "Expected [] to not be empty."
558
621
  assert_equal msg, ex.message
559
622
  end
560
623
 
@@ -596,7 +659,7 @@ describe Minitest::Ok::AssertionObject do
596
659
  (x = ok {nil}).append('bar')
597
660
  end
598
661
  x._mark_as_tested()
599
- msg = /^undefined method `append' for \#<Mini[tT]est::Ok::AssertionObject:\w+>$/
662
+ msg = /^undefined method `append' for \#<Mini[tT]est::Ok::AssertionObject:\w+/
600
663
  assert_match msg, ex.message
601
664
  #
602
665
  ex = assert_raises(NoMethodError) do
@@ -673,18 +736,18 @@ describe Minitest::Ok::AssertionObject do
673
736
  end
674
737
 
675
738
 
676
- describe '#falthy?' do
739
+ describe '#falsy?' do
677
740
 
678
741
  it "calles refute()." do
679
- should_not_raise { ok {nil}.falthy? }
680
- ex = should_raise { ok {123}.falthy? }
742
+ should_not_raise { ok {nil}.falsy? }
743
+ ex = should_raise { ok {123}.falsy? }
681
744
  msg = 'Expected (!! 123) == false, but not.'
682
745
  assert_equal msg, ex.message
683
746
  end
684
747
 
685
748
  it "calles assert() after NOT() called." do
686
- should_not_raise { ok {123}.NOT.falthy? }
687
- ex = should_raise { ok {nil}.NOT.falthy? }
749
+ should_not_raise { ok {123}.NOT.falsy? }
750
+ ex = should_raise { ok {nil}.NOT.falsy? }
688
751
  msg = 'Expected (!! nil) == true, but not.'
689
752
  assert_equal msg, ex.message
690
753
  end
@@ -694,7 +757,7 @@ describe Minitest::Ok::AssertionObject do
694
757
 
695
758
  describe '#attr' do
696
759
 
697
- class User
760
+ class User1
698
761
  def initialize(name, age)
699
762
  @name, @age = name, age
700
763
  end
@@ -702,24 +765,24 @@ describe Minitest::Ok::AssertionObject do
702
765
  end
703
766
 
704
767
  it "calles assert_equal()." do
705
- user = User.new('Haruhi', 16)
768
+ user = User1.new('Haruhi', 16)
706
769
  should_not_raise { ok {user}.attr(:name, 'Haruhi').attr(:age, 16) }
707
770
  ex = should_raise { ok {user}.attr(:name, 'Haruhi').attr(:age, 12) }
708
771
  msg = ("Expected <object>.age == <exected>, but failed.\n" +
709
- " (object: #<User:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
772
+ " (object: #<User1:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
710
773
  "Expected: 12\n" +
711
774
  " Actual: 16")
712
- assert_equal msg, ex.message.gsub(/<User:0x\w+/, '<User:0xXXXXXX')
775
+ assert_equal msg, ex.message.gsub(/<User1:0x\w+/, '<User1:0xXXXXXX')
713
776
  end
714
777
 
715
778
  it "calles refute_equal() after NOT() called." do
716
- user = User.new('Haruhi', 16)
779
+ user = User1.new('Haruhi', 16)
717
780
  should_not_raise { ok {user}.NOT.attr(:name, 'Suzumiya').attr(:age, 12) }
718
781
  ex = should_raise { ok {user}.NOT.attr(:name, 'Suzumiya').attr(:age, 16) }
719
782
  msg = ("Expected <object>.age != <exected>, but failed.\n" +
720
- " (object: #<User:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
783
+ " (object: #<User1:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
721
784
  "Expected 16 to not be equal to 16.")
722
- assert_equal msg, ex.message.gsub(/<User:0x\w+/, '<User:0xXXXXXX')
785
+ assert_equal msg, ex.message.gsub(/<User1:0x\w+/, '<User1:0xXXXXXX')
723
786
  end
724
787
 
725
788
  end
@@ -727,7 +790,7 @@ describe Minitest::Ok::AssertionObject do
727
790
 
728
791
  describe '#attrs' do
729
792
 
730
- class User
793
+ class User2
731
794
  def initialize(name, age)
732
795
  @name, @age = name, age
733
796
  end
@@ -735,24 +798,24 @@ describe Minitest::Ok::AssertionObject do
735
798
  end
736
799
 
737
800
  it "calles assert_equal()." do
738
- user = User.new('Haruhi', 16)
801
+ user = User2.new('Haruhi', 16)
739
802
  should_not_raise { ok {user}.attrs(name: 'Haruhi', age: 16) }
740
803
  ex = should_raise { ok {user}.attrs(name: 'Haruhi', age: 12) }
741
804
  msg = ("Expected <object>.age == <exected>, but failed.\n" +
742
- " (object: #<User:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
805
+ " (object: #<User2:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
743
806
  "Expected: 12\n" +
744
807
  " Actual: 16")
745
- assert_equal msg, ex.message.gsub(/<User:0x\w+/, '<User:0xXXXXXX')
808
+ assert_equal msg, ex.message.gsub(/<User2:0x\w+/, '<User2:0xXXXXXX')
746
809
  end
747
810
 
748
811
  it "calles refute_equal() after NOT() called." do
749
- user = User.new('Haruhi', 16)
812
+ user = User2.new('Haruhi', 16)
750
813
  should_not_raise { ok {user}.NOT.attrs(name: 'Suzumiya', age: 12) }
751
814
  ex = should_raise { ok {user}.NOT.attrs(name: 'Suzumiya', age: 16) }
752
815
  msg = ("Expected <object>.age != <exected>, but failed.\n" +
753
- " (object: #<User:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
816
+ " (object: #<User2:0xXXXXXX @name=\"Haruhi\", @age=16>).\n" +
754
817
  "Expected 16 to not be equal to 16.")
755
- assert_equal msg, ex.message.gsub(/<User:0x\w+/, '<User:0xXXXXXX')
818
+ assert_equal msg, ex.message.gsub(/<User2:0x\w+/, '<User2:0xXXXXXX')
756
819
  end
757
820
 
758
821
  end
data/test/test_helper.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 0.2.0 $
5
- ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
4
+ ### $Release: 0.3.3 $
5
+ ### $Copyright: copyright(c) 2015-2018 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
8
8
 
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.3
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: 2021-08-01 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,17 @@ 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
- rubyforge_project:
67
- rubygems_version: 2.0.14.1
66
+ rubygems_version: 3.1.2
68
67
  signing_key:
69
68
  specification_version: 4
70
- summary: '''ok {1+1} == 2'' instead of ''assert_equal 2, 1+1'''
69
+ summary: "'ok {1+1} == 2' instead of 'assert_equal 2, 1+1'"
71
70
  test_files: []