minitest 2.1.0 → 2.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.
- data.tar.gz.sig +0 -0
- data/History.txt +11 -0
- data/Manifest.txt +1 -0
- data/lib/hoe/minitest.rb +15 -0
- data/lib/minitest/unit.rb +103 -6
- data/test/test_minitest_unit.rb +155 -7
- metadata +11 -12
- metadata.gz.sig +4 -2
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
=== 2.2.0 / 2011-05-29
|
2
|
+
|
3
|
+
* 6 minor enhancements:
|
4
|
+
|
5
|
+
* assert_equal (and must_equal) now tries to diff output where it makes sense.
|
6
|
+
* Added Assertions#diff(exp, act) to be used by assert_equal.
|
7
|
+
* Added Assertions#mu_pp_for_diff
|
8
|
+
* Added Assertions.diff and diff=
|
9
|
+
* Moved minitest hoe-plugin from hoe-seattlerb. (erikh)
|
10
|
+
* Skipped tests only output details in verbose mode. (tenderlove+zenspider=xoxo)
|
11
|
+
|
1
12
|
=== 2.1.0 / 2011-04-11
|
2
13
|
|
3
14
|
* 5 minor enhancements:
|
data/Manifest.txt
CHANGED
data/lib/hoe/minitest.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Hoe::Minitest
|
2
|
+
def initialize_minitest
|
3
|
+
require 'minitest/unit'
|
4
|
+
version = MiniTest::Unit::VERSION
|
5
|
+
|
6
|
+
extra_dev_deps << ['minitest', ">= #{version}"]
|
7
|
+
end
|
8
|
+
|
9
|
+
def define_minitest_tasks
|
10
|
+
self.testlib = :minitest
|
11
|
+
|
12
|
+
# make sure we use the gemmed minitest on 1.9
|
13
|
+
self.test_prelude = 'gem "minitest"'
|
14
|
+
end
|
15
|
+
end
|
data/lib/minitest/unit.rb
CHANGED
@@ -59,9 +59,88 @@ module MiniTest
|
|
59
59
|
|
60
60
|
module Assertions
|
61
61
|
|
62
|
+
WINDOZE = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
63
|
+
|
64
|
+
##
|
65
|
+
# Returns the diff command to use in #diff. Tries to intelligently
|
66
|
+
# figure out what diff to use.
|
67
|
+
|
68
|
+
def self.diff
|
69
|
+
@diff = if WINDOZE
|
70
|
+
"diff.exe -u"
|
71
|
+
else
|
72
|
+
if system("gdiff", __FILE__, __FILE__)
|
73
|
+
"gdiff -u" # solaris and kin suck
|
74
|
+
elsif system("diff", __FILE__, __FILE__)
|
75
|
+
"diff -u"
|
76
|
+
else
|
77
|
+
nil
|
78
|
+
end
|
79
|
+
end unless defined? @diff
|
80
|
+
|
81
|
+
@diff
|
82
|
+
end
|
83
|
+
|
62
84
|
##
|
63
|
-
#
|
64
|
-
|
85
|
+
# Set the diff command to use in #diff.
|
86
|
+
|
87
|
+
def self.diff= o
|
88
|
+
@diff = o
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# Returns a diff between +exp+ and +act+. If there is no known
|
93
|
+
# diff command or if it doesn't make sense to diff the output
|
94
|
+
# (single line, short output), then it simply returns a basic
|
95
|
+
# comparison between the two.
|
96
|
+
|
97
|
+
def diff exp, act
|
98
|
+
require "tempfile"
|
99
|
+
|
100
|
+
expect = mu_pp_for_diff exp
|
101
|
+
butwas = mu_pp_for_diff act
|
102
|
+
result = nil
|
103
|
+
|
104
|
+
need_to_diff =
|
105
|
+
MiniTest::Assertions.diff &&
|
106
|
+
(expect.include?("\n") ||
|
107
|
+
butwas.include?("\n") ||
|
108
|
+
expect.size > 30 ||
|
109
|
+
butwas.size > 30 ||
|
110
|
+
expect == butwas)
|
111
|
+
|
112
|
+
return "Expected: #{mu_pp exp}\n Actual: #{mu_pp act}" unless
|
113
|
+
need_to_diff
|
114
|
+
|
115
|
+
Tempfile.open("expect") do |a|
|
116
|
+
a.puts expect
|
117
|
+
a.rewind
|
118
|
+
Tempfile.open("butwas") do |b|
|
119
|
+
b.puts butwas
|
120
|
+
b.rewind
|
121
|
+
|
122
|
+
result = `#{MiniTest::Assertions.diff} #{a.path} #{b.path}`
|
123
|
+
result.sub!(/^\-\-\- .+/, "--- expected")
|
124
|
+
result.sub!(/^\+\+\+ .+/, "+++ actual")
|
125
|
+
|
126
|
+
if result.empty? then
|
127
|
+
klass = exp.class
|
128
|
+
result = [
|
129
|
+
"No visible difference.",
|
130
|
+
"You should look at your implementation of #{klass}#==.",
|
131
|
+
expect
|
132
|
+
].join "\n"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
result
|
138
|
+
end
|
139
|
+
|
140
|
+
##
|
141
|
+
# This returns a human-readable version of +obj+. By default
|
142
|
+
# #inspect is called. You can override this to use #pretty_print
|
143
|
+
# if you want.
|
65
144
|
|
66
145
|
def mu_pp obj
|
67
146
|
s = obj.inspect
|
@@ -69,6 +148,16 @@ module MiniTest
|
|
69
148
|
s
|
70
149
|
end
|
71
150
|
|
151
|
+
##
|
152
|
+
# This returns a diff-able human-readable version of +obj+. This
|
153
|
+
# differs from the regular mu_pp because it expands escaped
|
154
|
+
# newlines and makes hex-values generic (like object_ids). This
|
155
|
+
# uses mu_pp to do the first pass and then cleans it up.
|
156
|
+
|
157
|
+
def mu_pp_for_diff obj # TODO: possibly rename
|
158
|
+
mu_pp(obj).gsub(/\\n/, "\n").gsub(/0x[a-f0-9]+/m, '0xXXXXXX')
|
159
|
+
end
|
160
|
+
|
72
161
|
def _assertions= n # :nodoc:
|
73
162
|
@_assertions = n
|
74
163
|
end
|
@@ -108,12 +197,19 @@ module MiniTest
|
|
108
197
|
end
|
109
198
|
|
110
199
|
##
|
111
|
-
# Fails unless <tt>exp == act</tt
|
200
|
+
# Fails unless <tt>exp == act</tt> printing the difference between
|
201
|
+
# the two, if possible.
|
202
|
+
#
|
203
|
+
# If there is no visible difference but the assertion fails, you
|
204
|
+
# should suspect that your #== is buggy, or your inspect output is
|
205
|
+
# missing crucial details.
|
206
|
+
#
|
207
|
+
# For floats use assert_in_delta.
|
112
208
|
#
|
113
|
-
#
|
209
|
+
# See also: MiniTest::Assertions.diff
|
114
210
|
|
115
211
|
def assert_equal exp, act, msg = nil
|
116
|
-
msg = message(msg) {
|
212
|
+
msg = message(msg) { diff exp, act }
|
117
213
|
assert(exp == act, msg)
|
118
214
|
end
|
119
215
|
|
@@ -516,7 +612,7 @@ module MiniTest
|
|
516
612
|
end
|
517
613
|
|
518
614
|
class Unit
|
519
|
-
VERSION = "2.
|
615
|
+
VERSION = "2.2.0" # :nodoc:
|
520
616
|
|
521
617
|
attr_accessor :report, :failures, :errors, :skips # :nodoc:
|
522
618
|
attr_accessor :test_count, :assertion_count # :nodoc:
|
@@ -710,6 +806,7 @@ module MiniTest
|
|
710
806
|
e = case e
|
711
807
|
when MiniTest::Skip then
|
712
808
|
@skips += 1
|
809
|
+
return "S" unless @verbose
|
713
810
|
"Skipped:\n#{meth}(#{klass}) [#{location e}]:\n#{e.message}\n"
|
714
811
|
when MiniTest::Assertion then
|
715
812
|
@failures += 1
|
data/test/test_minitest_unit.rb
CHANGED
@@ -344,6 +344,36 @@ Finished tests in 0.00
|
|
344
344
|
|
345
345
|
S.
|
346
346
|
|
347
|
+
Finished tests in 0.00
|
348
|
+
|
349
|
+
2 tests, 1 assertions, 0 failures, 0 errors, 1 skips
|
350
|
+
"
|
351
|
+
assert_report expected
|
352
|
+
end
|
353
|
+
|
354
|
+
def test_run_skip_verbose
|
355
|
+
tc = Class.new(MiniTest::Unit::TestCase) do
|
356
|
+
def test_something
|
357
|
+
assert true
|
358
|
+
end
|
359
|
+
|
360
|
+
def test_skip
|
361
|
+
skip "not yet"
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
Object.const_set(:ATestCase, tc)
|
366
|
+
|
367
|
+
@tu.run %w[--seed 42 --verbose]
|
368
|
+
|
369
|
+
expected = "Run options: --seed 42 --verbose
|
370
|
+
|
371
|
+
# Running tests:
|
372
|
+
|
373
|
+
ATestCase#test_skip = 0.00 s = S
|
374
|
+
ATestCase#test_something = 0.00 s = .
|
375
|
+
|
376
|
+
|
347
377
|
Finished tests in 0.00
|
348
378
|
|
349
379
|
1) Skipped:
|
@@ -480,12 +510,115 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|
480
510
|
@tc.assert_equal 1, 1
|
481
511
|
end
|
482
512
|
|
483
|
-
def
|
484
|
-
|
513
|
+
def test_assert_equal_different_diff_deactivated
|
514
|
+
without_diff do
|
515
|
+
util_assert_triggered util_msg("haha" * 10, "blah" * 10) do
|
516
|
+
o1 = "haha" * 10
|
517
|
+
o2 = "blah" * 10
|
518
|
+
|
519
|
+
@tc.assert_equal o1, o2
|
520
|
+
end
|
521
|
+
end
|
522
|
+
end
|
523
|
+
|
524
|
+
def test_assert_equal_different_hex
|
525
|
+
c = Class.new do
|
526
|
+
def initialize s; @name = s; end
|
527
|
+
end
|
528
|
+
|
529
|
+
o1 = c.new "a"
|
530
|
+
o2 = c.new "b"
|
531
|
+
msg = "--- expected
|
532
|
+
+++ actual
|
533
|
+
@@ -1 +1 @@
|
534
|
+
-#<#<Class:0xXXXXXX>:0xXXXXXX @name=\"a\">
|
535
|
+
+#<#<Class:0xXXXXXX>:0xXXXXXX @name=\"b\">
|
536
|
+
.".gsub(/^ +/, "")
|
537
|
+
|
538
|
+
util_assert_triggered msg do
|
539
|
+
@tc.assert_equal o1, o2
|
540
|
+
end
|
541
|
+
end
|
542
|
+
|
543
|
+
def test_assert_equal_different_hex_invisible
|
544
|
+
o1 = Object.new
|
545
|
+
o2 = Object.new
|
546
|
+
|
547
|
+
msg = "No visible difference.
|
548
|
+
You should look at your implementation of Object#==.
|
549
|
+
#<Object:0xXXXXXX>.".gsub(/^ +/, "")
|
550
|
+
|
551
|
+
util_assert_triggered msg do
|
552
|
+
@tc.assert_equal o1, o2
|
553
|
+
end
|
554
|
+
end
|
555
|
+
|
556
|
+
def test_assert_equal_different_long
|
557
|
+
msg = "--- expected
|
558
|
+
+++ actual
|
559
|
+
@@ -1 +1 @@
|
560
|
+
-\"hahahahahahahahahahahahahahahahahahahaha\"
|
561
|
+
+\"blahblahblahblahblahblahblahblahblahblah\"
|
562
|
+
.".gsub(/^ +/, "")
|
563
|
+
|
564
|
+
util_assert_triggered msg do
|
565
|
+
o1 = "haha" * 10
|
566
|
+
o2 = "blah" * 10
|
567
|
+
|
568
|
+
@tc.assert_equal o1, o2
|
569
|
+
end
|
570
|
+
end
|
571
|
+
|
572
|
+
def test_assert_equal_different_long_invisible
|
573
|
+
msg = "No visible difference.
|
574
|
+
You should look at your implementation of String#==.
|
575
|
+
\"blahblahblahblahblahblahblahblahblahblah\".".gsub(/^ +/, "")
|
576
|
+
|
577
|
+
util_assert_triggered msg do
|
578
|
+
o1 = "blah" * 10
|
579
|
+
o2 = "blah" * 10
|
580
|
+
def o1.== o
|
581
|
+
false
|
582
|
+
end
|
583
|
+
@tc.assert_equal o1, o2
|
584
|
+
end
|
585
|
+
end
|
586
|
+
|
587
|
+
def test_assert_equal_different_long_msg
|
588
|
+
msg = "message.
|
589
|
+
--- expected
|
590
|
+
+++ actual
|
591
|
+
@@ -1 +1 @@
|
592
|
+
-\"hahahahahahahahahahahahahahahahahahahaha\"
|
593
|
+
+\"blahblahblahblahblahblahblahblahblahblah\"
|
594
|
+
.".gsub(/^ +/, "")
|
595
|
+
|
596
|
+
util_assert_triggered msg do
|
597
|
+
o1 = "haha" * 10
|
598
|
+
o2 = "blah" * 10
|
599
|
+
@tc.assert_equal o1, o2, "message"
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
603
|
+
def test_assert_equal_different_short
|
604
|
+
util_assert_triggered util_msg(1, 2) do
|
485
605
|
@tc.assert_equal 1, 2
|
486
606
|
end
|
487
607
|
end
|
488
608
|
|
609
|
+
def test_assert_equal_different_short_msg
|
610
|
+
util_assert_triggered util_msg(1, 2, "message") do
|
611
|
+
@tc.assert_equal 1, 2, "message"
|
612
|
+
end
|
613
|
+
end
|
614
|
+
|
615
|
+
def test_assert_equal_different_short_multiline
|
616
|
+
msg = "--- expected\n+++ actual\n@@ -1,2 +1,2 @@\n \"a\n-b\"\n+c\"\n."
|
617
|
+
util_assert_triggered msg do
|
618
|
+
@tc.assert_equal "a\nb", "a\nc"
|
619
|
+
end
|
620
|
+
end
|
621
|
+
|
489
622
|
def test_assert_in_delta
|
490
623
|
@tc.assert_in_delta 0.0, 1.0 / 1000, 0.1
|
491
624
|
end
|
@@ -636,7 +769,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|
636
769
|
end
|
637
770
|
|
638
771
|
def test_assert_output_triggered_both
|
639
|
-
util_assert_triggered "
|
772
|
+
util_assert_triggered util_msg("yay", "boo", "In stdout") do
|
640
773
|
@tc.assert_output "yay", "blah" do
|
641
774
|
print "boo"
|
642
775
|
$stderr.print "blah blah"
|
@@ -645,7 +778,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|
645
778
|
end
|
646
779
|
|
647
780
|
def test_assert_output_triggered_err
|
648
|
-
util_assert_triggered "
|
781
|
+
util_assert_triggered util_msg("blah", "blah blah", "In stderr") do
|
649
782
|
@tc.assert_output nil, "blah" do
|
650
783
|
$stderr.print "blah blah"
|
651
784
|
end
|
@@ -653,7 +786,7 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|
653
786
|
end
|
654
787
|
|
655
788
|
def test_assert_output_triggered_out
|
656
|
-
util_assert_triggered "
|
789
|
+
util_assert_triggered util_msg("blah", "blah blah", "In stdout") do
|
657
790
|
@tc.assert_output "blah" do
|
658
791
|
print "blah blah"
|
659
792
|
end
|
@@ -832,7 +965,7 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
832
965
|
def test_assert_silent_triggered_err
|
833
966
|
@assertion_count = 2
|
834
967
|
|
835
|
-
util_assert_triggered "
|
968
|
+
util_assert_triggered util_msg("", "blah blah", "In stderr") do
|
836
969
|
@tc.assert_silent do
|
837
970
|
$stderr.print "blah blah"
|
838
971
|
end
|
@@ -840,7 +973,7 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
840
973
|
end
|
841
974
|
|
842
975
|
def test_assert_silent_triggered_out
|
843
|
-
util_assert_triggered "
|
976
|
+
util_assert_triggered util_msg("", "blah blah", "In stdout") do
|
844
977
|
@tc.assert_silent do
|
845
978
|
print "blah blah"
|
846
979
|
end
|
@@ -1148,4 +1281,19 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
1148
1281
|
|
1149
1282
|
assert_equal expected, msg
|
1150
1283
|
end
|
1284
|
+
|
1285
|
+
def util_msg exp, act, msg = nil
|
1286
|
+
s = "Expected: #{exp.inspect}\n Actual: #{act.inspect}."
|
1287
|
+
s = "#{msg}.\n#{s}" if msg
|
1288
|
+
s
|
1289
|
+
end
|
1290
|
+
|
1291
|
+
def without_diff
|
1292
|
+
old_diff = MiniTest::Assertions.diff
|
1293
|
+
MiniTest::Assertions.diff = nil
|
1294
|
+
|
1295
|
+
yield
|
1296
|
+
ensure
|
1297
|
+
MiniTest::Assertions.diff = old_diff
|
1298
|
+
end
|
1151
1299
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 2.
|
10
|
+
version: 2.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Davis
|
@@ -36,8 +36,7 @@ cert_chain:
|
|
36
36
|
FBHgymkyj/AOSqKRIpXPhjC6
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2011-
|
40
|
-
default_executable:
|
39
|
+
date: 2011-06-01 00:00:00 Z
|
41
40
|
dependencies:
|
42
41
|
- !ruby/object:Gem::Dependency
|
43
42
|
name: minitest
|
@@ -50,9 +49,9 @@ dependencies:
|
|
50
49
|
hash: 11
|
51
50
|
segments:
|
52
51
|
- 2
|
52
|
+
- 1
|
53
53
|
- 0
|
54
|
-
|
55
|
-
version: 2.0.2
|
54
|
+
version: 2.1.0
|
56
55
|
type: :development
|
57
56
|
version_requirements: *id001
|
58
57
|
- !ruby/object:Gem::Dependency
|
@@ -63,12 +62,12 @@ dependencies:
|
|
63
62
|
requirements:
|
64
63
|
- - ">="
|
65
64
|
- !ruby/object:Gem::Version
|
66
|
-
hash:
|
65
|
+
hash: 35
|
67
66
|
segments:
|
68
67
|
- 2
|
69
68
|
- 9
|
70
|
-
-
|
71
|
-
version: 2.9.
|
69
|
+
- 4
|
70
|
+
version: 2.9.4
|
72
71
|
type: :development
|
73
72
|
version_requirements: *id002
|
74
73
|
description: |-
|
@@ -115,6 +114,7 @@ files:
|
|
115
114
|
- README.txt
|
116
115
|
- Rakefile
|
117
116
|
- design_rationale.rb
|
117
|
+
- lib/hoe/minitest.rb
|
118
118
|
- lib/minitest/autorun.rb
|
119
119
|
- lib/minitest/benchmark.rb
|
120
120
|
- lib/minitest/mock.rb
|
@@ -126,7 +126,6 @@ files:
|
|
126
126
|
- test/test_minitest_spec.rb
|
127
127
|
- test/test_minitest_unit.rb
|
128
128
|
- .gemtest
|
129
|
-
has_rdoc: true
|
130
129
|
homepage: http://rubyforge.org/projects/bfts
|
131
130
|
licenses: []
|
132
131
|
|
@@ -157,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
156
|
requirements: []
|
158
157
|
|
159
158
|
rubyforge_project: bfts
|
160
|
-
rubygems_version: 1.
|
159
|
+
rubygems_version: 1.8.2
|
161
160
|
signing_key:
|
162
161
|
specification_version: 3
|
163
162
|
summary: minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,4 @@
|
|
1
|
-
�
|
2
|
-
|
1
|
+
V[�f�r :���KI
|
2
|
+
��-P�cI4H���PK�xd[�����G��:�xѱ2Qh�+3�r���9�u�[JKPv%�
|
3
|
+
�q^S^y�p���|҂E�Pu��X+@��_�@#vK�_�<�t-~�B*��s075e���6Y�ƲC��z1��P��%g*��9�x"T�_B<
|
4
|
+
̬A�EUJ����
|