minitest 5.6.1 → 5.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +19 -0
- data/README.rdoc +5 -0
- data/lib/minitest.rb +2 -2
- data/lib/minitest/assertions.rb +6 -7
- data/lib/minitest/expectations.rb +4 -4
- data/lib/minitest/mock.rb +6 -7
- data/lib/minitest/spec.rb +5 -2
- data/test/minitest/test_minitest_mock.rb +2 -2
- data/test/minitest/test_minitest_spec.rb +34 -4
- data/test/minitest/test_minitest_unit.rb +43 -8
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0caf7dee527cd6e2c8723c758f8f8b77200394e
|
4
|
+
data.tar.gz: 733ef8e073ffc22f3fde80f0943e211d44f1682e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a439887e2b4866360f82a8f69d4e6987e04ddcaa46a4657c7197a67f7421236b40a90489d3b6d8dbb1a29aa9964e52764b3e168e37a8934889984a959748d857
|
7
|
+
data.tar.gz: 4b0d8456d19c64ec581fa5bbb5636c185653d817b93045903f7b0a05f38b28d113ecfae7f2911722b5f3e9deb96c26ac401e0afbe6b5430a69683acf0940e4cf
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
=== 5.7.0 / 2015-05-27
|
2
|
+
|
3
|
+
* 1 major enhancement:
|
4
|
+
|
5
|
+
* assert_raises now matches subclasses of the expected exception types. (jeremyevans)
|
6
|
+
|
7
|
+
* 3 minor enhancements:
|
8
|
+
|
9
|
+
* Added :block type for minitest/spec's #infect_an_assertion. (jeremyevans)
|
10
|
+
* Inline verification error messages in minitest/mock for GC performance. (zamith)
|
11
|
+
* assert_raises defaults to RuntimeError if not specified. (jeremyevans)
|
12
|
+
|
13
|
+
* 4 bug fixes:
|
14
|
+
|
15
|
+
* Added 'class' to minitest/mock's overridden_methods list. (zamith)
|
16
|
+
* Added file/line to infect_an_assertion's class_eval call. (jeremyevans)
|
17
|
+
* Cleared UnexpectedError's mesg w/ generic string.
|
18
|
+
* Fixed non-proc-oriented expectations when used on proc target. (jeremyevans)
|
19
|
+
|
1
20
|
=== 5.6.1 / 2015-04-27
|
2
21
|
|
3
22
|
* 2 bug fixes:
|
data/README.rdoc
CHANGED
@@ -479,6 +479,7 @@ minitest-english :: Semantically symmetric aliases for assertions and
|
|
479
479
|
expectations.
|
480
480
|
minitest-excludes :: Clean API for excluding certain tests you
|
481
481
|
don't want to run under certain conditions.
|
482
|
+
minitest-fail-fast :: Reimplements RSpec's "fail fast" feature
|
482
483
|
minitest-filecontent :: Support unit tests with expectation results in files.
|
483
484
|
Differing results will be stored again in files.
|
484
485
|
minitest-filesystem :: Adds assertion and expectation to help testing
|
@@ -491,6 +492,7 @@ minitest-great_expectations :: Generally useful additions to minitest's
|
|
491
492
|
assertions and expectations.
|
492
493
|
minitest-growl :: Test notifier for minitest via growl.
|
493
494
|
minitest-happy :: GLOBALLY ACTIVATE MINITEST PRIDE! RAWR!
|
495
|
+
minitest-hooks :: Around and before_all/after_all/around_all hooks
|
494
496
|
minitest-implicit-subject :: Implicit declaration of the test subject.
|
495
497
|
minitest-instrument :: Instrument ActiveSupport::Notifications when
|
496
498
|
test method is executed.
|
@@ -512,6 +514,7 @@ minitest-mongoid :: Mongoid assertion matchers for Minitest.
|
|
512
514
|
minitest-must_not :: Provides must_not as an alias for wont in
|
513
515
|
Minitest.
|
514
516
|
minitest-osx :: Reporter for the Mac OS X notification center.
|
517
|
+
minitest-parallel_fork :: Fork-based parallelization
|
515
518
|
minitest-parallel-db :: Run tests in parallel with a single database.
|
516
519
|
minitest-power_assert :: PowerAssert for Minitest.
|
517
520
|
minitest-predicates :: Adds support for .predicate? methods.
|
@@ -524,6 +527,8 @@ minitest-rspec_mocks :: Use RSpec Mocks with Minitest.
|
|
524
527
|
minitest-server :: minitest-server provides a client/server setup
|
525
528
|
with your minitest process, allowing your test
|
526
529
|
run to send its results directly to a handler.
|
530
|
+
minitest-shared_description :: Support for shared specs and shared spec
|
531
|
+
subclasses
|
527
532
|
minitest-should_syntax :: RSpec-style +x.should == y+ assertions for
|
528
533
|
Minitest.
|
529
534
|
minitest-shouldify :: Adding all manner of shoulds to Minitest (bad
|
data/lib/minitest.rb
CHANGED
@@ -7,7 +7,7 @@ require "minitest/parallel"
|
|
7
7
|
# :include: README.rdoc
|
8
8
|
|
9
9
|
module Minitest
|
10
|
-
VERSION = "5.
|
10
|
+
VERSION = "5.7.0" # :nodoc:
|
11
11
|
ENCS = "".respond_to? :encoding # :nodoc:
|
12
12
|
|
13
13
|
@@installed_at_exit ||= false
|
@@ -684,7 +684,7 @@ module Minitest
|
|
684
684
|
attr_accessor :exception # :nodoc:
|
685
685
|
|
686
686
|
def initialize exception # :nodoc:
|
687
|
-
super
|
687
|
+
super "Unexpected exception"
|
688
688
|
self.exception = exception
|
689
689
|
end
|
690
690
|
|
data/lib/minitest/assertions.rb
CHANGED
@@ -287,9 +287,14 @@ module Minitest
|
|
287
287
|
##
|
288
288
|
# Fails unless the block raises one of +exp+. Returns the
|
289
289
|
# exception matched so you can check the message, attributes, etc.
|
290
|
+
#
|
291
|
+
# +exp+ takes an optional message on the end to help explain
|
292
|
+
# failures and defaults to StandardError if no exception class is
|
293
|
+
# passed.
|
290
294
|
|
291
295
|
def assert_raises *exp
|
292
296
|
msg = "#{exp.pop}.\n" if String === exp.last
|
297
|
+
exp << StandardError if exp.empty?
|
293
298
|
|
294
299
|
begin
|
295
300
|
yield
|
@@ -297,13 +302,7 @@ module Minitest
|
|
297
302
|
return e if exp.include? Minitest::Skip
|
298
303
|
raise e
|
299
304
|
rescue Exception => e
|
300
|
-
expected = exp.any? { |ex|
|
301
|
-
if ex.instance_of? Module then
|
302
|
-
e.kind_of? ex
|
303
|
-
else
|
304
|
-
e.instance_of? ex
|
305
|
-
end
|
306
|
-
}
|
305
|
+
expected = exp.any? { |ex| e.kind_of? ex }
|
307
306
|
|
308
307
|
assert expected, proc {
|
309
308
|
exception_details(e, "#{msg}#{mu_pp(exp)} exception expected, not")
|
@@ -121,7 +121,7 @@ module Minitest::Expectations
|
|
121
121
|
#
|
122
122
|
# :method: must_output
|
123
123
|
|
124
|
-
infect_an_assertion :assert_output, :must_output
|
124
|
+
infect_an_assertion :assert_output, :must_output, :block
|
125
125
|
|
126
126
|
##
|
127
127
|
# See Minitest::Assertions#assert_raises
|
@@ -130,7 +130,7 @@ module Minitest::Expectations
|
|
130
130
|
#
|
131
131
|
# :method: must_raise
|
132
132
|
|
133
|
-
infect_an_assertion :assert_raises, :must_raise
|
133
|
+
infect_an_assertion :assert_raises, :must_raise, :block
|
134
134
|
|
135
135
|
##
|
136
136
|
# See Minitest::Assertions#assert_respond_to
|
@@ -157,7 +157,7 @@ module Minitest::Expectations
|
|
157
157
|
#
|
158
158
|
# :method: must_be_silent
|
159
159
|
|
160
|
-
infect_an_assertion :assert_silent, :must_be_silent
|
160
|
+
infect_an_assertion :assert_silent, :must_be_silent, :block
|
161
161
|
|
162
162
|
##
|
163
163
|
# See Minitest::Assertions#assert_throws
|
@@ -166,7 +166,7 @@ module Minitest::Expectations
|
|
166
166
|
#
|
167
167
|
# :method: must_throw
|
168
168
|
|
169
|
-
infect_an_assertion :assert_throws, :must_throw
|
169
|
+
infect_an_assertion :assert_throws, :must_throw, :block
|
170
170
|
|
171
171
|
##
|
172
172
|
# See Minitest::Assertions#refute_empty
|
data/lib/minitest/mock.rb
CHANGED
@@ -12,6 +12,7 @@ module Minitest # :nodoc:
|
|
12
12
|
|
13
13
|
overridden_methods = %w[
|
14
14
|
===
|
15
|
+
class
|
15
16
|
inspect
|
16
17
|
instance_eval
|
17
18
|
instance_variables
|
@@ -96,14 +97,11 @@ module Minitest # :nodoc:
|
|
96
97
|
def verify
|
97
98
|
@expected_calls.each do |name, calls|
|
98
99
|
calls.each do |expected|
|
99
|
-
|
100
|
-
msg2 = "#{msg1}, got [#{__call name, @actual_calls[name]}]"
|
101
|
-
|
102
|
-
raise MockExpectationError, msg2 if
|
100
|
+
raise MockExpectationError, "expected #{__call name, expected}, got [#{__call name, @actual_calls[name]}]" if
|
103
101
|
@actual_calls.key?(name) and
|
104
102
|
not @actual_calls[name].include?(expected)
|
105
103
|
|
106
|
-
raise MockExpectationError,
|
104
|
+
raise MockExpectationError, "expected #{__call name, expected}" unless
|
107
105
|
@actual_calls.key?(name) and
|
108
106
|
@actual_calls[name].include?(expected)
|
109
107
|
end
|
@@ -143,7 +141,8 @@ module Minitest # :nodoc:
|
|
143
141
|
[sym, expected_args.size, args.size]
|
144
142
|
end
|
145
143
|
|
146
|
-
|
144
|
+
zipped_args = expected_args.zip(args)
|
145
|
+
fully_matched = zipped_args.all? { |mod, a|
|
147
146
|
mod === a or mod == a
|
148
147
|
}
|
149
148
|
|
@@ -154,7 +153,7 @@ module Minitest # :nodoc:
|
|
154
153
|
|
155
154
|
@actual_calls[sym] << {
|
156
155
|
:retval => retval,
|
157
|
-
:args =>
|
156
|
+
:args => zipped_args.map! { |mod, a| mod === a ? mod : a },
|
158
157
|
}
|
159
158
|
|
160
159
|
retval
|
data/lib/minitest/spec.rb
CHANGED
@@ -2,8 +2,11 @@ require "minitest/test"
|
|
2
2
|
|
3
3
|
class Module # :nodoc:
|
4
4
|
def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
|
5
|
+
block = dont_flip == :block
|
6
|
+
dont_flip = false if block
|
7
|
+
|
5
8
|
# warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
|
6
|
-
self.class_eval <<-EOM
|
9
|
+
self.class_eval <<-EOM, __FILE__, __LINE__ + 1
|
7
10
|
def #{new_name} *args
|
8
11
|
Minitest::Expectation.new(self, Minitest::Spec.current).#{new_name}(*args)
|
9
12
|
end
|
@@ -14,7 +17,7 @@ class Module # :nodoc:
|
|
14
17
|
case
|
15
18
|
when #{!!dont_flip} then
|
16
19
|
ctx.#{meth}(target, *args)
|
17
|
-
when Proc === target then
|
20
|
+
when #{block} && Proc === target then
|
18
21
|
ctx.#{meth}(*args, &target)
|
19
22
|
else
|
20
23
|
ctx.#{meth}(args.first, target, *args[1..-1])
|
@@ -19,7 +19,7 @@ class TestMinitestMock < Minitest::Test
|
|
19
19
|
def test_blow_up_if_not_called
|
20
20
|
@mock.foo
|
21
21
|
|
22
|
-
util_verify_bad "expected meaning_of_life() => 42
|
22
|
+
util_verify_bad "expected meaning_of_life() => 42"
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_not_blow_up_if_everything_called
|
@@ -39,7 +39,7 @@ class TestMinitestMock < Minitest::Test
|
|
39
39
|
@mock.meaning_of_life
|
40
40
|
@mock.expect(:bar, true)
|
41
41
|
|
42
|
-
util_verify_bad "expected bar() => true
|
42
|
+
util_verify_bad "expected bar() => true"
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_blow_up_on_wrong_number_of_arguments
|
@@ -15,7 +15,7 @@ describe Minitest::Spec do
|
|
15
15
|
# do not parallelize this suite... it just can"t handle it.
|
16
16
|
|
17
17
|
def assert_triggered expected = "blah", klass = Minitest::Assertion
|
18
|
-
@assertion_count +=
|
18
|
+
@assertion_count += 1
|
19
19
|
|
20
20
|
e = assert_raises(klass) do
|
21
21
|
yield
|
@@ -23,8 +23,22 @@ describe Minitest::Spec do
|
|
23
23
|
|
24
24
|
msg = e.message.sub(/(---Backtrace---).*/m, '\1')
|
25
25
|
msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
|
26
|
-
|
27
|
-
|
26
|
+
msg.gsub!(/@.+>/, "@PATH>")
|
27
|
+
msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
|
28
|
+
msg.gsub!(/:0x[a-fA-F0-9]{4,}/m, ":0xXXXXXX")
|
29
|
+
|
30
|
+
if expected
|
31
|
+
@assertion_count += 1
|
32
|
+
case expected
|
33
|
+
when String then
|
34
|
+
assert_equal expected, msg
|
35
|
+
when Regexp then
|
36
|
+
@assertion_count += 1
|
37
|
+
assert_match expected, msg
|
38
|
+
else
|
39
|
+
flunk "Unknown: #{expected.inspect}"
|
40
|
+
end
|
41
|
+
end
|
28
42
|
end
|
29
43
|
|
30
44
|
before do
|
@@ -182,6 +196,8 @@ describe Minitest::Spec do
|
|
182
196
|
end
|
183
197
|
|
184
198
|
it "needs to verify equality" do
|
199
|
+
@assertion_count += 1
|
200
|
+
|
185
201
|
(6 * 7).must_equal(42).must_equal true
|
186
202
|
|
187
203
|
assert_triggered "Expected: 42\n Actual: 54" do
|
@@ -191,6 +207,10 @@ describe Minitest::Spec do
|
|
191
207
|
assert_triggered "msg.\nExpected: 42\n Actual: 54" do
|
192
208
|
(6 * 9).must_equal 42, "msg"
|
193
209
|
end
|
210
|
+
|
211
|
+
assert_triggered(/^-42\n\+#<Proc:0xXXXXXX@PATH>\n/) do
|
212
|
+
proc { 42 }.must_equal 42 # proc isn't called, so expectation fails
|
213
|
+
end
|
194
214
|
end
|
195
215
|
|
196
216
|
it "needs to verify floats outside a delta" do
|
@@ -282,7 +302,9 @@ describe Minitest::Spec do
|
|
282
302
|
end
|
283
303
|
|
284
304
|
it "needs to verify inequality" do
|
305
|
+
@assertion_count += 2
|
285
306
|
42.wont_equal(6 * 9).must_equal false
|
307
|
+
proc{}.wont_equal(42).must_equal false
|
286
308
|
|
287
309
|
assert_triggered "Expected 1 to not be equal to 1." do
|
288
310
|
1.wont_equal 1
|
@@ -306,7 +328,10 @@ describe Minitest::Spec do
|
|
306
328
|
end
|
307
329
|
|
308
330
|
it "needs to verify kinds of a class" do
|
331
|
+
@assertion_count += 2
|
332
|
+
|
309
333
|
42.wont_be_kind_of(String).must_equal false
|
334
|
+
proc{}.wont_be_kind_of(String).must_equal false
|
310
335
|
|
311
336
|
assert_triggered "Expected 42 to not be a kind of Integer." do
|
312
337
|
42.wont_be_kind_of Integer
|
@@ -318,7 +343,7 @@ describe Minitest::Spec do
|
|
318
343
|
end
|
319
344
|
|
320
345
|
it "needs to verify kinds of objects" do
|
321
|
-
@assertion_count +=
|
346
|
+
@assertion_count += 3 # extra test
|
322
347
|
|
323
348
|
(6 * 7).must_be_kind_of(Fixnum).must_equal true
|
324
349
|
(6 * 7).must_be_kind_of(Numeric).must_equal true
|
@@ -330,6 +355,11 @@ describe Minitest::Spec do
|
|
330
355
|
assert_triggered "msg.\nExpected 42 to be a kind of String, not Fixnum." do
|
331
356
|
(6 * 7).must_be_kind_of String, "msg"
|
332
357
|
end
|
358
|
+
|
359
|
+
exp = "Expected #<Proc:0xXXXXXX@PATH> to be a kind of String, not Proc."
|
360
|
+
assert_triggered exp do
|
361
|
+
proc{}.must_be_kind_of String
|
362
|
+
end
|
333
363
|
end
|
334
364
|
|
335
365
|
it "needs to verify mismatch" do
|
@@ -4,6 +4,7 @@ require "minitest/metametameta"
|
|
4
4
|
module MyModule; end
|
5
5
|
class AnError < StandardError; include MyModule; end
|
6
6
|
class ImmutableString < String; def inspect; super.freeze; end; end
|
7
|
+
SomeError = Class.new Exception
|
7
8
|
|
8
9
|
class TestMinitestUnit < MetaMetaMetaTestCase
|
9
10
|
parallelize_me!
|
@@ -1141,6 +1142,34 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1141
1142
|
end
|
1142
1143
|
end
|
1143
1144
|
|
1145
|
+
def test_assert_raises_default
|
1146
|
+
@tc.assert_raises do
|
1147
|
+
raise StandardError, "blah"
|
1148
|
+
end
|
1149
|
+
end
|
1150
|
+
|
1151
|
+
def test_assert_raises_default_triggered
|
1152
|
+
e = assert_raises Minitest::Assertion do
|
1153
|
+
@tc.assert_raises do
|
1154
|
+
raise SomeError, "blah"
|
1155
|
+
end
|
1156
|
+
end
|
1157
|
+
|
1158
|
+
expected = clean <<-EOM.chomp
|
1159
|
+
[StandardError] exception expected, not
|
1160
|
+
Class: <SomeError>
|
1161
|
+
Message: <\"blah\">
|
1162
|
+
---Backtrace---
|
1163
|
+
FILE:LINE:in \`test_assert_raises_default_triggered\'
|
1164
|
+
---------------
|
1165
|
+
EOM
|
1166
|
+
|
1167
|
+
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
1168
|
+
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
|
1169
|
+
|
1170
|
+
assert_equal expected, actual
|
1171
|
+
end
|
1172
|
+
|
1144
1173
|
def test_assert_raises_module
|
1145
1174
|
@tc.assert_raises MyModule do
|
1146
1175
|
raise AnError
|
@@ -1236,26 +1265,32 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1236
1265
|
assert_equal expected, e.message
|
1237
1266
|
end
|
1238
1267
|
|
1239
|
-
def
|
1268
|
+
def test_assert_raises_subclass
|
1269
|
+
@tc.assert_raises StandardError do
|
1270
|
+
raise AnError
|
1271
|
+
end
|
1272
|
+
end
|
1273
|
+
|
1274
|
+
def test_assert_raises_subclass_triggered
|
1240
1275
|
e = assert_raises Minitest::Assertion do
|
1241
|
-
@tc.assert_raises
|
1242
|
-
raise AnError
|
1276
|
+
@tc.assert_raises SomeError do
|
1277
|
+
raise AnError, "some message"
|
1243
1278
|
end
|
1244
1279
|
end
|
1245
1280
|
|
1246
|
-
expected = clean <<-EOM
|
1247
|
-
[
|
1281
|
+
expected = clean <<-EOM
|
1282
|
+
[SomeError] exception expected, not
|
1248
1283
|
Class: <AnError>
|
1249
|
-
Message: <\"
|
1284
|
+
Message: <\"some message\">
|
1250
1285
|
---Backtrace---
|
1251
|
-
FILE:LINE:in \`
|
1286
|
+
FILE:LINE:in \`test_assert_raises_subclass_triggered\'
|
1252
1287
|
---------------
|
1253
1288
|
EOM
|
1254
1289
|
|
1255
1290
|
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
1256
1291
|
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
|
1257
1292
|
|
1258
|
-
assert_equal expected, actual
|
1293
|
+
assert_equal expected.chomp, actual
|
1259
1294
|
end
|
1260
1295
|
|
1261
1296
|
def test_assert_respond_to
|
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: 5.
|
4
|
+
version: 5.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
xJcC6UN6NHMOVMyAXsr2HR0gRRx4ofN1LoP2KhXzSr8UMvQYlwPmE0N5GQv1b5AO
|
30
30
|
VpzF30vNaJK6ZT7xlIsIlwmH
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2015-
|
32
|
+
date: 2015-05-27 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rdoc
|
metadata.gz.sig
CHANGED
Binary file
|