minitest-ok 0.3.1 → 0.3.2
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 +5 -5
- data/README.md +5 -0
- data/lib/minitest/ok.rb +8 -4
- data/test/minitest/ok_test.rb +56 -53
- data/test/test_helper.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 40646a1c992adca79a399e48636078e3d6396b6c23240d834b45c74f3301b313
|
4
|
+
data.tar.gz: acef8748174df73545018825580e38748e7f5b43afefdf3b6ebdbcd25efde8ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edde25cb1f5e4e9b8c3be8e30494e552e1a7e4862e8c610a3aaadc58796103e879186067d6dc0439d3b1b6b0883dcc5a55a042a3207e55434c2a3873c4c87fbc
|
7
|
+
data.tar.gz: 215f1c821b74a530b662386d9ae18405c6cd1fcd470c9abd5a8532854878a95412767909047db0050fc6a0b201d2fb7f534b7b0ff64ac9b8680c3bb57f5c7e94
|
data/README.md
CHANGED
data/lib/minitest/ok.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 0.3.
|
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.
|
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,
|
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:
|
data/test/minitest/ok_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 0.3.
|
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
|
-
|
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
|
-
|
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
|
-
|
173
|
-
msg = ('Expected String to not be === # encoding: UTF-8'+"\n"+
|
174
|
-
|
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
|
-
|
187
|
-
msg = ('Expected /\d+/ to match # encoding: UTF-8'+"\n"+
|
188
|
-
|
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
|
-
|
196
|
-
msg = ('Expected /\w+/ to not match # encoding: UTF-8'+"\n"+
|
197
|
-
|
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
|
-
|
210
|
-
msg = ('Expected /\w+/ to not match # encoding: UTF-8'+"\n"+
|
211
|
-
|
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
|
-
|
219
|
-
msg = ('Expected /\d+/ to match # encoding: UTF-8'+"\n"+
|
220
|
-
|
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
|
-
|
233
|
-
msg = ('Expected # encoding: UTF-8'+"\n"+
|
234
|
-
|
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
|
-
|
242
|
-
msg = ('Expected # encoding: UTF-8'+"\n"+
|
243
|
-
|
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
|
-
|
256
|
-
msg = ('Expected # encoding: UTF-8'+"\n"+
|
257
|
-
|
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
|
-
|
265
|
-
msg = ('Expected # encoding: UTF-8'+"\n"+
|
266
|
-
|
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
|
-
|
397
|
-
|
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
|
-
|
518
|
-
|
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
|
-
|
558
|
-
|
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
|
-
|
584
|
-
msg = ('Expected # encoding: UTF-8'+"\n"+
|
585
|
-
|
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
|
-
|
593
|
-
msg = ('Expected # encoding: UTF-8'+"\n"+
|
594
|
-
|
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 {
|
605
|
-
ex = should_raise { ok {
|
606
|
-
|
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 {
|
614
|
-
ex = should_raise { ok {
|
615
|
-
|
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
|
data/test/test_helper.rb
CHANGED
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.
|
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:
|
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
|
-
|
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'"
|