minitest-ok 0.3.1 → 0.3.2

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
- SHA1:
3
- metadata.gz: 67c3d366a946d973e09f4c7b444009531c174f3c
4
- data.tar.gz: 926cb6753f06a72825e1d8d9144dcafcedf1bfc1
2
+ SHA256:
3
+ metadata.gz: 40646a1c992adca79a399e48636078e3d6396b6c23240d834b45c74f3301b313
4
+ data.tar.gz: acef8748174df73545018825580e38748e7f5b43afefdf3b6ebdbcd25efde8ec
5
5
  SHA512:
6
- metadata.gz: f4295a3a39519adb857ae9e19a68b2ddf61e744561a1894253b4383782027e1a8417e999559a39dea301bc9bf016fb93d280f6802aa9ef8b522f3f1c595927e2
7
- data.tar.gz: df827fb533a5a239f25c13991e76d805a807bf3b01606acc2a0aeae7d765393c3b1be87a7c225d5699951f70a66114db4da2f64346b83c7b1c0001e924bcf801
6
+ metadata.gz: edde25cb1f5e4e9b8c3be8e30494e552e1a7e4862e8c610a3aaadc58796103e879186067d6dc0439d3b1b6b0883dcc5a55a042a3207e55434c2a3873c4c87fbc
7
+ data.tar.gz: 215f1c821b74a530b662386d9ae18405c6cd1fcd470c9abd5a8532854878a95412767909047db0050fc6a0b201d2fb7f534b7b0ff64ac9b8680c3bb57f5c7e94
data/README.md CHANGED
@@ -138,6 +138,11 @@ $License: MIT License $
138
138
 
139
139
  ## History
140
140
 
141
+ ### 2021-01-17: Release 0.3.2
142
+
143
+ * [bugfix] fix to work on Ruby 3.
144
+
145
+
141
146
  ### 2018-11-13: Release 0.3.1
142
147
 
143
148
  * [bugfix] add change history to README.
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 0.3.1 $
4
+ ### $Release: 0.3.2 $
5
5
  ### $Copyright: copyright(c) 2015-2018 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.3.1 $'.split()[1]
62
+ VERSION = '$Release: 0.3.2 $'.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:
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 0.3.1 $
4
+ ### $Release: 0.3.2 $
5
5
  ### $Copyright: copyright(c) 2015-2018 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
@@ -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
 
@@ -169,9 +171,9 @@ describe Minitest::Ok::AssertionObject do
169
171
  should_not_raise { ok {String}.NOT === 123 }
170
172
  should_not_raise { ok {/\d+/ }.NOT === 'abc' }
171
173
  ex = should_raise { ok {String}.NOT === '123' }
172
- #msg = 'Expected String to not be === "123".'
173
- msg = ('Expected String to not be === # encoding: UTF-8'+"\n"+
174
- '"123".')
174
+ msg = 'Expected String to not be === "123".'
175
+ #msg = ('Expected String to not be === # encoding: UTF-8'+"\n"+
176
+ # '"123".')
175
177
  assert_equal msg, ex.message
176
178
  end
177
179
 
@@ -183,18 +185,18 @@ describe Minitest::Ok::AssertionObject do
183
185
  it "calls assert_match()." do
184
186
  should_not_raise { ok {"hom"} =~ /\w+/ }
185
187
  ex = should_raise { ok {"hom"} =~ /\d+/ }
186
- #msg = 'Expected /\d+/ to match "hom".'
187
- msg = ('Expected /\d+/ to match # encoding: UTF-8'+"\n"+
188
- '"hom".')
188
+ msg = 'Expected /\d+/ to match "hom".'
189
+ #msg = ('Expected /\d+/ to match # encoding: UTF-8'+"\n"+
190
+ # '"hom".')
189
191
  assert_equal msg, ex.message
190
192
  end
191
193
 
192
194
  it "calls refute_match() after NOT() called." do
193
195
  should_not_raise { ok {"hom"}.NOT =~ /\d+/ }
194
196
  ex = should_raise { ok {"hom"}.NOT =~ /\w+/ }
195
- #msg = 'Expected /\w+/ to not match "hom".'
196
- msg = ('Expected /\w+/ to not match # encoding: UTF-8'+"\n"+
197
- '"hom".')
197
+ msg = 'Expected /\w+/ to not match "hom".'
198
+ #msg = ('Expected /\w+/ to not match # encoding: UTF-8'+"\n"+
199
+ # '"hom".')
198
200
  assert_equal msg, ex.message
199
201
  end
200
202
 
@@ -206,18 +208,18 @@ describe Minitest::Ok::AssertionObject do
206
208
  it "calls refute_match()." do
207
209
  should_not_raise { ok {"hom"} !~ /\d+/ }
208
210
  ex = should_raise { ok {"hom"} !~ /\w+/ }
209
- #msg = 'Expected /\w+/ to not match "hom".'
210
- msg = ('Expected /\w+/ to not match # encoding: UTF-8'+"\n"+
211
- '"hom".')
211
+ msg = 'Expected /\w+/ to not match "hom".'
212
+ #msg = ('Expected /\w+/ to not match # encoding: UTF-8'+"\n"+
213
+ # '"hom".')
212
214
  assert_equal msg, ex.message
213
215
  end
214
216
 
215
217
  it "calls assert_match() after NOT() called." do
216
218
  should_not_raise { ok {"hom"}.NOT !~ /\w+/ }
217
219
  ex = should_raise { ok {"hom"}.NOT !~ /\d+/ }
218
- #msg = 'Expected /\d+/ to match "hom".'
219
- msg = ('Expected /\d+/ to match # encoding: UTF-8'+"\n"+
220
- '"hom".')
220
+ msg = 'Expected /\d+/ to match "hom".'
221
+ #msg = ('Expected /\d+/ to match # encoding: UTF-8'+"\n"+
222
+ # '"hom".')
221
223
  assert_equal msg, ex.message
222
224
  end
223
225
 
@@ -229,18 +231,18 @@ describe Minitest::Ok::AssertionObject do
229
231
  it "calls assert_kind_of()." do
230
232
  should_not_raise { ok {"hom"}.is_a?(String) }
231
233
  ex = should_raise { ok {"hom"}.is_a?(Array) }
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.')
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.')
235
237
  assert_equal msg, ex.message
236
238
  end
237
239
 
238
240
  it "calls refute_kind_of() after NOT() called." do
239
241
  should_not_raise { ok {"hom"}.NOT.is_a?(Array) }
240
242
  ex = should_raise { ok {"hom"}.NOT.is_a?(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.')
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.')
244
246
  assert_equal msg, ex.message
245
247
  end
246
248
 
@@ -252,18 +254,18 @@ describe Minitest::Ok::AssertionObject do
252
254
  it "calls assert_kind_of()." do
253
255
  should_not_raise { ok {"hom"}.kind_of?(String) }
254
256
  ex = should_raise { ok {"hom"}.kind_of?(Array) }
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.')
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.')
258
260
  assert_equal msg, ex.message
259
261
  end
260
262
 
261
263
  it "calls refute_kind_of() after NOT() called." do
262
264
  should_not_raise { ok {"hom"}.NOT.kind_of?(Array) }
263
265
  ex = should_raise { ok {"hom"}.NOT.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.')
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.')
267
269
  assert_equal msg, ex.message
268
270
  end
269
271
 
@@ -393,10 +395,12 @@ describe Minitest::Ok::AssertionObject do
393
395
  expected = [
394
396
  '--- expected',
395
397
  '+++ actual',
396
- '@@ -1,2 +1,2 @@',
397
- '-# encoding: UTF-8',
398
+ #'@@ -1,2 +1,2 @@',
399
+ #'-# encoding: UTF-8',
400
+ '@@ -1 +1,3 @@',
398
401
  '-"foobar"',
399
402
  '+# encoding: ASCII-8BIT',
403
+ '+# valid: true',
400
404
  '+"divided by 0"',
401
405
  '',
402
406
  ].join("\n")
@@ -408,6 +412,7 @@ describe Minitest::Ok::AssertionObject do
408
412
  ex = should_raise { ok {proc{1/0}}.raise?(ZeroDivisionError, /by 99/) }
409
413
  #expected = "Expected /by 99/ to match \"divided by 0\"."
410
414
  expected = ('Expected /by 99/ to match # encoding: ASCII-8BIT'+"\n"+
415
+ '# valid: true'+"\n"+
411
416
  '"divided by 0".')
412
417
  assert_equal expected, ex.message
413
418
  end
@@ -514,8 +519,9 @@ describe Minitest::Ok::AssertionObject do
514
519
  'In stderr.',
515
520
  '--- expected',
516
521
  '+++ actual',
517
- '@@ -1,3 +1 @@',
518
- '-# encoding: UTF-8',
522
+ #'@@ -1,3 +1 @@',
523
+ #'-# encoding: UTF-8',
524
+ '@@ -1,2 +1 @@',
519
525
  '-"123',
520
526
  '-"',
521
527
  '+""',
@@ -554,8 +560,9 @@ describe Minitest::Ok::AssertionObject do
554
560
  'In stdout.',
555
561
  '--- expected',
556
562
  '+++ actual',
557
- '@@ -1,2 +1,2 @@',
558
- '-# encoding: UTF-8',
563
+ #'@@ -1,2 +1,2 @@',
564
+ #'-# encoding: UTF-8',
565
+ '@@ -1 +1,2 @@',
559
566
  '-""',
560
567
  '+"123',
561
568
  '+"',
@@ -580,18 +587,18 @@ describe Minitest::Ok::AssertionObject do
580
587
  it "calls assert_predicate()." do
581
588
  should_not_raise { ok {"".freeze}.frozen? }
582
589
  ex = should_raise { ok {"".dup() }.frozen? }
583
- #msg = 'Expected "" to be frozen?.'
584
- msg = ('Expected # encoding: UTF-8'+"\n"+
585
- '"" to be frozen?.')
590
+ msg = 'Expected "" to be frozen?.'
591
+ #msg = ('Expected # encoding: UTF-8'+"\n"+
592
+ # '"" to be frozen?.')
586
593
  assert_equal msg, ex.message
587
594
  end
588
595
 
589
596
  it "calls refute_predicate() after NOT() called." do
590
597
  should_not_raise { ok {"".dup() }.NOT.frozen? }
591
598
  ex = should_raise { ok {"".freeze}.NOT.frozen? }
592
- #msg = 'Expected "" to not be frozen?.'
593
- msg = ('Expected # encoding: UTF-8'+"\n"+
594
- '"" to not be frozen?.')
599
+ msg = 'Expected "" to not be frozen?.'
600
+ #msg = ('Expected # encoding: UTF-8'+"\n"+
601
+ # '"" to not be frozen?.')
595
602
  assert_equal msg, ex.message
596
603
  end
597
604
 
@@ -601,20 +608,16 @@ describe Minitest::Ok::AssertionObject do
601
608
  describe '#tainted?' do
602
609
 
603
610
  it "calls assert_predicate()." do
604
- should_not_raise { ok {"".taint}.tainted? }
605
- ex = should_raise { ok {"".dup()}.tainted? }
606
- #msg = 'Expected "" to be tainted?.'
607
- msg = ('Expected # encoding: UTF-8'+"\n"+
608
- '"" to be tainted?.')
611
+ should_not_raise { ok {[ ]}.empty? }
612
+ ex = should_raise { ok {[1]}.empty? }
613
+ msg = "Expected [1] to be empty."
609
614
  assert_equal msg, ex.message
610
615
  end
611
616
 
612
617
  it "calls refute_predicate() after NOT() called." do
613
- should_not_raise { ok {"".dup()}.NOT.tainted? }
614
- ex = should_raise { ok {"".taint}.NOT.tainted? }
615
- #msg = 'Expected "" to not be tainted?.'
616
- msg = ('Expected # encoding: UTF-8'+"\n"+
617
- '"" 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."
618
621
  assert_equal msg, ex.message
619
622
  end
620
623
 
@@ -656,7 +659,7 @@ describe Minitest::Ok::AssertionObject do
656
659
  (x = ok {nil}).append('bar')
657
660
  end
658
661
  x._mark_as_tested()
659
- msg = /^undefined method `append' for \#<Mini[tT]est::Ok::AssertionObject:\w+>$/
662
+ msg = /^undefined method `append' for \#<Mini[tT]est::Ok::AssertionObject:\w+/
660
663
  assert_match msg, ex.message
661
664
  #
662
665
  ex = assert_raises(NoMethodError) do
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  ###
4
- ### $Release: 0.3.1 $
4
+ ### $Release: 0.3.2 $
5
5
  ### $Copyright: copyright(c) 2015-2018 kuwata-lab.com all rights reserved $
6
6
  ### $License: MIT License $
7
7
  ###
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-ok
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - makoto kuwata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-12 00:00:00.000000000 Z
11
+ date: 2021-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -63,8 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  requirements: []
66
- rubyforge_project:
67
- rubygems_version: 2.5.2.3
66
+ rubygems_version: 3.1.2
68
67
  signing_key:
69
68
  specification_version: 4
70
69
  summary: "'ok {1+1} == 2' instead of 'assert_equal 2, 1+1'"