minitest 1.4.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +2 -2
- data/History.txt +15 -0
- data/lib/minitest/spec.rb +31 -11
- data/lib/minitest/unit.rb +35 -29
- data/test/test_mini_test.rb +33 -0
- metadata +34 -4
- metadata.gz.sig +1 -1
data.tar.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
�b�"0���(o5y{�D�B�l��B�O�8˴�^t���)�)��|Cfw6D{rt��9;��8�{V��;��b#����S�-�)>���C�*8Z����j�Qy����#�c��'w�p[���j�x��!W��KU�y�jO�6�`1b�9;����4���˜p�����/��
|
2
|
+
hR0�4�xR٪@S��PJ��T�{�oh��Ƣ�h�bu��:0~V��l~P���;%��9�>�k��&Ϧ���:"���
|
data/History.txt
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
=== 1.5.0 / 2010-01-06
|
2
|
+
|
3
|
+
* 4 minor enhancements:
|
4
|
+
|
5
|
+
* Added ability to specify what assertions should have their args flipped.
|
6
|
+
* Don't flip arguments on *include and *respond_to assertions.
|
7
|
+
* Refactored Module.infect_an_assertion from Module.infect_with_assertions.
|
8
|
+
* before/after :all now bitches and acts like :each
|
9
|
+
|
10
|
+
* 3 bug fixes:
|
11
|
+
|
12
|
+
* Nested describes now map to nested test classes to avoid namespace collision.
|
13
|
+
* Using undef_method instead of remove_method to clean out inherited specs.
|
14
|
+
* assert_raises was ignoring passed in message.
|
15
|
+
|
1
16
|
=== 1.4.2 / 2009-06-25
|
2
17
|
|
3
18
|
* 1 bug fix:
|
data/lib/minitest/spec.rb
CHANGED
@@ -3,7 +3,23 @@
|
|
3
3
|
require 'minitest/unit'
|
4
4
|
|
5
5
|
class Module
|
6
|
-
def
|
6
|
+
def infect_an_assertion meth, new_name, dont_flip = false
|
7
|
+
# warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
|
8
|
+
self.class_eval <<-EOM
|
9
|
+
def #{new_name} *args, &block
|
10
|
+
return MiniTest::Spec.current.#{meth}(*args, &self) if
|
11
|
+
Proc === self
|
12
|
+
return MiniTest::Spec.current.#{meth}(args.first, self) if
|
13
|
+
args.size == 1 unless #{!!dont_flip}
|
14
|
+
return MiniTest::Spec.current.#{meth}(self, *args)
|
15
|
+
end
|
16
|
+
EOM
|
17
|
+
end
|
18
|
+
|
19
|
+
def infect_with_assertions(pos_prefix, neg_prefix,
|
20
|
+
skip_re,
|
21
|
+
dont_flip_re = /\c0/,
|
22
|
+
map = {})
|
7
23
|
MiniTest::Assertions.public_instance_methods(false).each do |meth|
|
8
24
|
meth = meth.to_s
|
9
25
|
|
@@ -19,14 +35,7 @@ class Module
|
|
19
35
|
regexp, replacement = map.find { |re, _| new_name =~ re }
|
20
36
|
new_name.sub! regexp, replacement if replacement
|
21
37
|
|
22
|
-
|
23
|
-
self.class_eval <<-EOM
|
24
|
-
def #{new_name} *args, &block
|
25
|
-
return MiniTest::Spec.current.#{meth}(*args, &self) if Proc === self
|
26
|
-
return MiniTest::Spec.current.#{meth}(args.first, self) if args.size == 1
|
27
|
-
return MiniTest::Spec.current.#{meth}(self, *args)
|
28
|
-
end
|
29
|
-
EOM
|
38
|
+
infect_an_assertion meth, new_name, new_name =~ dont_flip_re
|
30
39
|
end
|
31
40
|
end
|
32
41
|
end
|
@@ -34,6 +43,7 @@ end
|
|
34
43
|
Object.infect_with_assertions(:must, :wont,
|
35
44
|
/^(must|wont)$|wont_(throw)|
|
36
45
|
must_(block|not?_|nothing|raise$)/x,
|
46
|
+
/(must|wont)_(include|respond_to)/,
|
37
47
|
/(must_throw)s/ => '\1',
|
38
48
|
/(?!not)_same/ => '_be_same_as',
|
39
49
|
/_in_/ => '_be_within_',
|
@@ -51,7 +61,9 @@ module Kernel
|
|
51
61
|
def describe desc, &block
|
52
62
|
stack = MiniTest::Spec.describe_stack
|
53
63
|
name = desc.to_s.split(/\W+/).map { |s| s.capitalize }.join + "Spec"
|
54
|
-
|
64
|
+
prev = stack.last
|
65
|
+
name = "#{prev == MiniTest::Spec ? nil : prev}::#{name}"
|
66
|
+
cls = Object.class_eval "class #{name} < #{prev}; end; #{name}"
|
55
67
|
|
56
68
|
cls.nuke_test_methods!
|
57
69
|
|
@@ -79,7 +91,7 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
79
91
|
|
80
92
|
def self.nuke_test_methods!
|
81
93
|
self.public_instance_methods.grep(/^test_/).each do |name|
|
82
|
-
send :
|
94
|
+
self.send :undef_method, name
|
83
95
|
end
|
84
96
|
end
|
85
97
|
|
@@ -93,11 +105,19 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|
93
105
|
end
|
94
106
|
|
95
107
|
def self.before(type = :each, &block)
|
108
|
+
if type == :all
|
109
|
+
warn "change before :all to before :each"
|
110
|
+
type = :each
|
111
|
+
end
|
96
112
|
raise "unsupported before type: #{type}" unless type == :each
|
97
113
|
define_inheritable_method :setup, &block
|
98
114
|
end
|
99
115
|
|
100
116
|
def self.after(type = :each, &block)
|
117
|
+
if type == :all # REFACTOR
|
118
|
+
warn "change before :all to before :each"
|
119
|
+
type = :each
|
120
|
+
end
|
101
121
|
raise "unsupported after type: #{type}" unless type == :each
|
102
122
|
define_inheritable_method :teardown, &block
|
103
123
|
end
|
data/lib/minitest/unit.rb
CHANGED
@@ -89,25 +89,25 @@ module MiniTest
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def assert_includes collection, obj, msg = nil
|
92
|
-
msg = message(msg) {
|
93
|
-
|
94
|
-
|
92
|
+
msg = message(msg) {
|
93
|
+
"Expected #{mu_pp(collection)} to include #{mu_pp(obj)}"
|
94
|
+
}
|
95
95
|
assert_respond_to collection, :include?
|
96
96
|
assert collection.include?(obj), msg
|
97
97
|
end
|
98
98
|
|
99
99
|
def assert_instance_of cls, obj, msg = nil
|
100
|
-
msg = message(msg) {
|
101
|
-
|
102
|
-
|
100
|
+
msg = message(msg) {
|
101
|
+
"Expected #{mu_pp(obj)} to be an instance of #{cls}, not #{obj.class}"
|
102
|
+
}
|
103
|
+
|
103
104
|
assert obj.instance_of?(cls), msg
|
104
105
|
end
|
105
106
|
|
106
107
|
def assert_kind_of cls, obj, msg = nil # TODO: merge with instance_of
|
107
108
|
msg = message(msg) {
|
108
109
|
"Expected #{mu_pp(obj)} to be a kind of #{cls}, not #{obj.class}" }
|
109
|
-
|
110
|
-
obj, cls = cls, obj if flip
|
110
|
+
|
111
111
|
assert obj.kind_of?(cls), msg
|
112
112
|
end
|
113
113
|
|
@@ -130,28 +130,29 @@ module MiniTest
|
|
130
130
|
|
131
131
|
def assert_raises *exp
|
132
132
|
msg = String === exp.last ? exp.pop : nil
|
133
|
+
msg = msg.to_s + "\n" if msg
|
133
134
|
should_raise = false
|
134
135
|
begin
|
135
136
|
yield
|
136
137
|
should_raise = true
|
137
138
|
rescue Exception => e
|
139
|
+
details = "#{msg}#{mu_pp(exp)} exception expected, not"
|
138
140
|
assert(exp.any? { |ex|
|
139
141
|
ex.instance_of?(Module) ? e.kind_of?(ex) : ex == e.class
|
140
|
-
}, exception_details(e,
|
142
|
+
}, exception_details(e, details))
|
141
143
|
|
142
144
|
return e
|
143
145
|
end
|
144
146
|
|
145
147
|
exp = exp.first if exp.size == 1
|
146
|
-
flunk "#{mu_pp(exp)} expected but nothing was raised." if
|
148
|
+
flunk "#{msg}#{mu_pp(exp)} expected but nothing was raised." if
|
149
|
+
should_raise
|
147
150
|
end
|
148
151
|
|
149
152
|
def assert_respond_to obj, meth, msg = nil
|
150
153
|
msg = message(msg) {
|
151
154
|
"Expected #{mu_pp(obj)} (#{obj.class}) to respond to ##{meth}"
|
152
155
|
}
|
153
|
-
flip = (Symbol === obj) && ! (Symbol === meth) # HACK for specs
|
154
|
-
obj, meth = meth, obj if flip
|
155
156
|
assert obj.respond_to?(meth), msg
|
156
157
|
end
|
157
158
|
|
@@ -241,13 +242,17 @@ module MiniTest
|
|
241
242
|
end
|
242
243
|
|
243
244
|
def refute_equal exp, act, msg = nil
|
244
|
-
msg = message(msg) {
|
245
|
+
msg = message(msg) {
|
246
|
+
"Expected #{mu_pp(act)} to not be equal to #{mu_pp(exp)}"
|
247
|
+
}
|
245
248
|
refute exp == act, msg
|
246
249
|
end
|
247
250
|
|
248
251
|
def refute_in_delta exp, act, delta = 0.001, msg = nil
|
249
252
|
n = (exp - act).abs
|
250
|
-
msg = message(msg) {
|
253
|
+
msg = message(msg) {
|
254
|
+
"Expected #{exp} - #{act} (#{n}) to not be < #{delta}"
|
255
|
+
}
|
251
256
|
refute delta > n, msg
|
252
257
|
end
|
253
258
|
|
@@ -256,24 +261,22 @@ module MiniTest
|
|
256
261
|
end
|
257
262
|
|
258
263
|
def refute_includes collection, obj, msg = nil
|
259
|
-
msg = message(msg) {
|
260
|
-
|
261
|
-
|
264
|
+
msg = message(msg) {
|
265
|
+
"Expected #{mu_pp(collection)} to not include #{mu_pp(obj)}"
|
266
|
+
}
|
262
267
|
assert_respond_to collection, :include?
|
263
268
|
refute collection.include?(obj), msg
|
264
269
|
end
|
265
270
|
|
266
271
|
def refute_instance_of cls, obj, msg = nil
|
267
|
-
msg = message(msg) {
|
268
|
-
|
269
|
-
|
272
|
+
msg = message(msg) {
|
273
|
+
"Expected #{mu_pp(obj)} to not be an instance of #{cls}"
|
274
|
+
}
|
270
275
|
refute obj.instance_of?(cls), msg
|
271
276
|
end
|
272
277
|
|
273
278
|
def refute_kind_of cls, obj, msg = nil # TODO: merge with instance_of
|
274
279
|
msg = message(msg) { "Expected #{mu_pp(obj)} to not be a kind of #{cls}" }
|
275
|
-
flip = (Module === obj) && ! (Module === cls) # HACK for specs
|
276
|
-
obj, cls = cls, obj if flip
|
277
280
|
refute obj.kind_of?(cls), msg
|
278
281
|
end
|
279
282
|
|
@@ -290,19 +293,22 @@ module MiniTest
|
|
290
293
|
end
|
291
294
|
|
292
295
|
def refute_operator o1, op, o2, msg = nil
|
293
|
-
msg = message(msg) {
|
296
|
+
msg = message(msg) {
|
297
|
+
"Expected #{mu_pp(o1)} to not be #{op} #{mu_pp(o2)}"
|
298
|
+
}
|
294
299
|
refute o1.__send__(op, o2), msg
|
295
300
|
end
|
296
301
|
|
297
302
|
def refute_respond_to obj, meth, msg = nil
|
298
303
|
msg = message(msg) { "Expected #{mu_pp(obj)} to not respond to #{meth}" }
|
299
|
-
|
300
|
-
obj, meth = meth, obj if flip
|
304
|
+
|
301
305
|
refute obj.respond_to?(meth), msg
|
302
306
|
end
|
303
307
|
|
304
308
|
def refute_same exp, act, msg = nil
|
305
|
-
msg = message(msg) {
|
309
|
+
msg = message(msg) {
|
310
|
+
"Expected #{mu_pp(act)} to not be the same as #{mu_pp(exp)}"
|
311
|
+
}
|
306
312
|
refute exp.equal?(act), msg
|
307
313
|
end
|
308
314
|
|
@@ -313,7 +319,7 @@ module MiniTest
|
|
313
319
|
end
|
314
320
|
|
315
321
|
class Unit
|
316
|
-
VERSION = "1.
|
322
|
+
VERSION = "1.5.0"
|
317
323
|
|
318
324
|
attr_accessor :report, :failures, :errors, :skips
|
319
325
|
attr_accessor :test_count, :assertion_count
|
@@ -514,8 +520,8 @@ module MiniTest
|
|
514
520
|
|
515
521
|
include MiniTest::Assertions
|
516
522
|
end # class TestCase
|
517
|
-
end # class
|
518
|
-
end # module
|
523
|
+
end # class Unit
|
524
|
+
end # module MiniTest
|
519
525
|
|
520
526
|
if $DEBUG then
|
521
527
|
# this helps me ferret out porting issues
|
data/test/test_mini_test.rb
CHANGED
@@ -610,6 +610,27 @@ FILE:LINE:in `test_assert_raises_triggered_different'
|
|
610
610
|
assert_equal expected, actual
|
611
611
|
end
|
612
612
|
|
613
|
+
def test_assert_raises_triggered_different_msg
|
614
|
+
e = assert_raises MiniTest::Assertion do
|
615
|
+
@tc.assert_raises RuntimeError, "XXX" do
|
616
|
+
raise SyntaxError, "icky"
|
617
|
+
end
|
618
|
+
end
|
619
|
+
|
620
|
+
expected = "XXX
|
621
|
+
[RuntimeError] exception expected, not
|
622
|
+
Class: <SyntaxError>
|
623
|
+
Message: <\"icky\">
|
624
|
+
---Backtrace---
|
625
|
+
FILE:LINE:in `test_assert_raises_triggered_different_msg'
|
626
|
+
---------------"
|
627
|
+
|
628
|
+
actual = e.message.gsub(/^.+:\d+/, 'FILE:LINE')
|
629
|
+
actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION =~ /^1\.9/
|
630
|
+
|
631
|
+
assert_equal expected, actual
|
632
|
+
end
|
633
|
+
|
613
634
|
def test_assert_raises_triggered_none
|
614
635
|
e = assert_raises MiniTest::Assertion do
|
615
636
|
@tc.assert_raises MiniTest::Assertion do
|
@@ -622,6 +643,18 @@ FILE:LINE:in `test_assert_raises_triggered_different'
|
|
622
643
|
assert_equal expected, e.message
|
623
644
|
end
|
624
645
|
|
646
|
+
def test_assert_raises_triggered_none_msg
|
647
|
+
e = assert_raises MiniTest::Assertion do
|
648
|
+
@tc.assert_raises MiniTest::Assertion, "XXX" do
|
649
|
+
# do nothing
|
650
|
+
end
|
651
|
+
end
|
652
|
+
|
653
|
+
expected = "XXX\nMiniTest::Assertion expected but nothing was raised."
|
654
|
+
|
655
|
+
assert_equal expected, e.message
|
656
|
+
end
|
657
|
+
|
625
658
|
def test_assert_raises_triggered_subclass
|
626
659
|
e = assert_raises MiniTest::Assertion do
|
627
660
|
@tc.assert_raises StandardError do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -30,9 +30,39 @@ cert_chain:
|
|
30
30
|
FBHgymkyj/AOSqKRIpXPhjC6
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date:
|
33
|
+
date: 2010-01-06 00:00:00 -08:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rubyforge
|
38
|
+
type: :development
|
39
|
+
version_requirement:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 2.0.3
|
45
|
+
version:
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: gemcutter
|
48
|
+
type: :development
|
49
|
+
version_requirement:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.2.1
|
55
|
+
version:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: minitest
|
58
|
+
type: :development
|
59
|
+
version_requirement:
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 1.4.2
|
65
|
+
version:
|
36
66
|
- !ruby/object:Gem::Dependency
|
37
67
|
name: hoe
|
38
68
|
type: :development
|
@@ -41,7 +71,7 @@ dependencies:
|
|
41
71
|
requirements:
|
42
72
|
- - ">="
|
43
73
|
- !ruby/object:Gem::Version
|
44
|
-
version: 2.
|
74
|
+
version: 2.5.0
|
45
75
|
version:
|
46
76
|
description: |-
|
47
77
|
minitest/unit is a small and fast replacement for ruby's huge and slow
|
@@ -103,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
133
|
requirements: []
|
104
134
|
|
105
135
|
rubyforge_project: bfts
|
106
|
-
rubygems_version: 1.3.
|
136
|
+
rubygems_version: 1.3.5
|
107
137
|
signing_key:
|
108
138
|
specification_version: 3
|
109
139
|
summary: minitest/unit is a small and fast replacement for ruby's huge and slow test/unit
|
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
R�Ú��ٮ/�Ԧ&/�Rz�OI�EI:���?'a�.�� ��ʸ��J�T�Ar���XO���v�3��-�/U :����ib���p��Ʊ�NGH`���B� ��=VK����I�$13"MIQ>������~�������FX���w�@a ft�G�6_�/,V�ć���t���hZ\�Q Gz \��@��2�OO�rEkj=��k�ab�z� ����Ζ�Ho��5���O#n�!$��C��C
|