minitest-ok 0.1.0 → 0.2.0
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 +4 -4
- data/README.md +6 -0
- data/lib/minitest/ok.rb +28 -20
- data/test/minitest/ok_test.rb +11 -2
- data/test/test_helper.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0393c06bdcd679080b979ab6d402b16363b9ac52
|
4
|
+
data.tar.gz: 6c0f9dbd1af465ca6601b8be8cadad2809e8393f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08609c6a464436a7ab37ff3045bdcf18dd7d1b9360c728609251ef1e0e7ab3f76983de8a2569cca55f68dbd62a768dddbc8d785fbbf40031253d263e70acb918
|
7
|
+
data.tar.gz: e869d5d3fcb907eb6ae6aae167f1f1313f25220009e5c8e7880f3e36cb4629897c10e440002f7fbc23baaeb307e670bbb2f88ca03d9c4e2fb3181c40c0615ae5
|
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.
|
4
|
+
### $Release: 0.2.0 $
|
5
5
|
### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
@@ -59,7 +59,12 @@ module Minitest
|
|
59
59
|
|
60
60
|
module Ok
|
61
61
|
|
62
|
-
VERSION = '$Release: 0.
|
62
|
+
VERSION = '$Release: 0.2.0 $'.split()[1]
|
63
|
+
|
64
|
+
|
65
|
+
class Msg < Proc # :nodoc:
|
66
|
+
alias to_s call
|
67
|
+
end
|
63
68
|
|
64
69
|
|
65
70
|
class AssertionObject
|
@@ -83,6 +88,10 @@ module Minitest
|
|
83
88
|
self
|
84
89
|
end
|
85
90
|
|
91
|
+
def _msg(&block)
|
92
|
+
Msg.new(block)
|
93
|
+
end
|
94
|
+
|
86
95
|
##
|
87
96
|
## Make logical condition reversed.
|
88
97
|
##
|
@@ -322,6 +331,13 @@ module Minitest
|
|
322
331
|
ex = nil
|
323
332
|
unless @not
|
324
333
|
ex = @context.assert_raises(exception_class) { @actual.call }
|
334
|
+
unless message.nil?
|
335
|
+
if message.is_a?(Regexp)
|
336
|
+
@context.assert_match message, ex.message
|
337
|
+
else
|
338
|
+
@context.assert_equal message, ex.message
|
339
|
+
end
|
340
|
+
end
|
325
341
|
else
|
326
342
|
begin
|
327
343
|
@actual.call
|
@@ -483,8 +499,7 @@ module Minitest
|
|
483
499
|
@context.__send__("assert_#{symbol.to_s[0..-2]}", @actual, *args, &block)
|
484
500
|
rescue NoMethodError
|
485
501
|
result = @actual.__send__(symbol, *args, &block)
|
486
|
-
|
487
|
-
@context.assert result, msg
|
502
|
+
@context.assert result, Msg.new { "Expected #{@actual.inspect}.#{symbol}(#{args.inspect[1..-2]}) but failed." }
|
488
503
|
end
|
489
504
|
else
|
490
505
|
## Try refute_xxxx() at first.
|
@@ -493,8 +508,7 @@ module Minitest
|
|
493
508
|
@context.__send__("refute_#{symbol.to_s[0..-2]}", @actual, *args, &block)
|
494
509
|
rescue NoMethodError
|
495
510
|
result = @actual.__send__(symbol, *args, &block)
|
496
|
-
|
497
|
-
@context.refute result, msg
|
511
|
+
@context.refute result, Msg.new { "Expected #{@actual.inspect}.#{symbol}(#{args.inspect[1..-2]}) to fail but succeeded." }
|
498
512
|
end
|
499
513
|
end
|
500
514
|
self
|
@@ -515,11 +529,9 @@ module Minitest
|
|
515
529
|
def truthy?
|
516
530
|
_mark_as_tested()
|
517
531
|
unless @not
|
518
|
-
|
519
|
-
@context.assert @actual, msg
|
532
|
+
@context.assert @actual, Msg.new { "Expected (!! #{@actual.inspect}) == true, but not." }
|
520
533
|
else
|
521
|
-
|
522
|
-
@context.refute @actual, msg
|
534
|
+
@context.refute @actual, Msg.new { "Expected (!! #{@actual.inspect}) == false, but not." }
|
523
535
|
end
|
524
536
|
self
|
525
537
|
end
|
@@ -537,11 +549,9 @@ module Minitest
|
|
537
549
|
def falthy?
|
538
550
|
_mark_as_tested()
|
539
551
|
unless @not
|
540
|
-
|
541
|
-
@context.refute @actual, msg
|
552
|
+
@context.refute @actual, Msg.new { "Expected (!! #{@actual.inspect}) == false, but not." }
|
542
553
|
else
|
543
|
-
|
544
|
-
@context.assert @actual, msg
|
554
|
+
@context.assert @actual, Msg.new { "Expected (!! #{@actual.inspect}) == true, but not." }
|
545
555
|
end
|
546
556
|
self
|
547
557
|
end
|
@@ -561,9 +571,8 @@ module Minitest
|
|
561
571
|
"Expected <object>.#{name} #{op} <exected>, but failed.\n" +
|
562
572
|
" (object: #{object.inspect})"
|
563
573
|
}
|
564
|
-
|
565
|
-
@context.
|
566
|
-
@context.refute_equal expected, actual, (result ? pr.call('!=') : nil) if @not
|
574
|
+
@context.assert_equal expected, actual, Msg.new { pr.call('==') } unless @not
|
575
|
+
@context.refute_equal expected, actual, Msg.new { pr.call('!=') } if @not
|
567
576
|
self
|
568
577
|
end
|
569
578
|
|
@@ -596,9 +605,8 @@ module Minitest
|
|
596
605
|
"Expected <object>[#{key.inspect}] #{op} <exected>, but failed.\n" +
|
597
606
|
" (object: #{object.inspect})"
|
598
607
|
}
|
599
|
-
|
600
|
-
@context.
|
601
|
-
@context.refute_equal expected, actual, (result ? pr.call('!=') : nil) if @not
|
608
|
+
@context.assert_equal expected, actual, Msg.new { pr.call('==') } unless @not
|
609
|
+
@context.refute_equal expected, actual, Msg.new { pr.call('!=') } if @not
|
602
610
|
self
|
603
611
|
end
|
604
612
|
|
data/test/minitest/ok_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
###
|
4
|
-
### $Release: 0.
|
4
|
+
### $Release: 0.2.0 $
|
5
5
|
### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
|
6
6
|
### $License: MIT License $
|
7
7
|
###
|
@@ -368,9 +368,18 @@ describe Minitest::Ok::AssertionObject do
|
|
368
368
|
end
|
369
369
|
end
|
370
370
|
|
371
|
-
it "can take error message in addition to exception class." do
|
371
|
+
it "can take error message string in addition to exception class." do
|
372
372
|
should_not_raise { ok {proc{1/0}}.raise?(ZeroDivisionError, "divided by 0") }
|
373
|
+
ex = should_raise { ok {proc{1/0}}.raise?(ZeroDivisionError, "foobar") }
|
374
|
+
expected = "Expected: \"foobar\"\n Actual: \"divided by 0\""
|
375
|
+
assert_equal expected, ex.message
|
376
|
+
end
|
377
|
+
|
378
|
+
it "can take error message regexp instead of string." do
|
373
379
|
should_not_raise { ok {proc{1/0}}.raise?(ZeroDivisionError, /by [0]/) }
|
380
|
+
ex = should_raise { ok {proc{1/0}}.raise?(ZeroDivisionError, /by 99/) }
|
381
|
+
expected = "Expected /by 99/ to match \"divided by 0\"."
|
382
|
+
assert_equal expected, ex.message
|
374
383
|
end
|
375
384
|
|
376
385
|
end
|
data/test/test_helper.rb
CHANGED
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.
|
4
|
+
version: 0.2.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:
|
11
|
+
date: 2016-09-06 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
|
-
- MIT-LICENSE
|
42
41
|
- README.md
|
42
|
+
- MIT-LICENSE
|
43
43
|
- Rakefile
|
44
44
|
- lib/minitest/ok.rb
|
45
|
-
- test/minitest/ok_test.rb
|
46
45
|
- test/test_helper.rb
|
46
|
+
- test/minitest/ok_test.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.
|
67
|
+
rubygems_version: 2.0.14.1
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
|
-
summary:
|
70
|
+
summary: '''ok {1+1} == 2'' instead of ''assert_equal 2, 1+1'''
|
71
71
|
test_files: []
|