minitest 5.8.5 → 5.9.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 +14 -4
- data/Manifest.txt +1 -1
- data/README.rdoc +29 -26
- data/lib/hoe/minitest.rb +4 -10
- data/lib/minitest.rb +23 -2
- data/lib/minitest/assertions.rb +17 -4
- data/lib/minitest/autorun.rb +1 -0
- data/lib/minitest/benchmark.rb +1 -2
- data/lib/minitest/hell.rb +6 -0
- data/lib/minitest/mock.rb +9 -0
- data/lib/minitest/test.rb +2 -3
- data/lib/minitest/unit.rb +1 -1
- data/test/minitest/test_minitest_mock.rb +14 -14
- data/test/minitest/{test_minitest_unit.rb → test_minitest_test.rb} +150 -65
- metadata +16 -17
- metadata.gz.sig +2 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7222450b56e3f834bababb2da8a48bb3d86221b9
|
4
|
+
data.tar.gz: fc32acc2e59ef4f4213d1fb04b05233618428a7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 543abb19775adc233fedb6a4970a8d9064e38d19aad6ba881f4464d6f800aefd3ccd7cc42ca24b2f0bd7ff4bf44310d4e6e379b6779cdf08496c1dbdb72db321
|
7
|
+
data.tar.gz: c780aa0cb535f5754e7b30f5d7450825ecdf9e1452819d4c8de53809f243c94463fb2b75c994295b637160976c454e18f5f18a3fac258037c271bed29ba97389
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
-
=== 5.
|
1
|
+
=== 5.9.0 / 2016-05-16
|
2
2
|
|
3
|
-
*
|
3
|
+
* 8 minor enhancements:
|
4
|
+
|
5
|
+
* Added Minitest.info_signal accessors to customize signal for test run info. (nate)
|
6
|
+
* Added assert_mock to make it more clear that you're testing w/ them.
|
7
|
+
* Added negative filter by test name. (utilum)
|
8
|
+
* Added warning to README that 1.8 and 1.9 support will be dropped in minitest 6.
|
9
|
+
* Automatically activate minitest/hell if $MT_HELL is defined.
|
10
|
+
* Improved default error messages for assert and refute. (bhenderson)
|
11
|
+
* minitest/hell now tries to require minitest/proveit
|
12
|
+
* mu_pp for strings prints out non-standard encodings to improve assert_equal diffs.
|
13
|
+
|
14
|
+
* 1 bug fix:
|
4
15
|
|
5
|
-
*
|
6
|
-
* Fixed hoe/minitest to not augment load path if we're actually testing minitest.
|
16
|
+
* Removed Interrupt from PASSTHROUGH_EXCEPTIONS (already handled). (waldyr)
|
7
17
|
|
8
18
|
=== 5.8.4 / 2016-01-21
|
9
19
|
|
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= minitest/{
|
1
|
+
= minitest/{test,spec,mock,benchmark}
|
2
2
|
|
3
3
|
home :: https://github.com/seattlerb/minitest
|
4
4
|
bugs :: https://github.com/seattlerb/minitest/issues
|
@@ -22,12 +22,12 @@ TDD, BDD, mocking, and benchmarking.
|
|
22
22
|
|
23
23
|
-- Wayne E. Seguin
|
24
24
|
|
25
|
-
minitest/
|
25
|
+
minitest/test is a small and incredibly fast unit testing framework.
|
26
26
|
It provides a rich set of assertions to make your tests clean and
|
27
27
|
readable.
|
28
28
|
|
29
29
|
minitest/spec is a functionally complete spec engine. It hooks onto
|
30
|
-
minitest/
|
30
|
+
minitest/test and seamlessly bridges test assertions over to spec
|
31
31
|
expectations.
|
32
32
|
|
33
33
|
minitest/benchmark is an awesome way to assert the performance of your
|
@@ -41,7 +41,7 @@ object framework.
|
|
41
41
|
minitest/pride shows pride in testing and adds coloring to your test
|
42
42
|
output. I guess it is an example of how to write IO pipes too. :P
|
43
43
|
|
44
|
-
minitest/
|
44
|
+
minitest/test is meant to have a clean implementation for language
|
45
45
|
implementors that need a minimal set of methods to bootstrap a working
|
46
46
|
test suite. For example, there is no magic involved for test-case
|
47
47
|
discovery.
|
@@ -65,12 +65,13 @@ extract-method refactorings still apply.
|
|
65
65
|
== FEATURES/PROBLEMS:
|
66
66
|
|
67
67
|
* minitest/autorun - the easy and explicit way to run all your tests.
|
68
|
-
* minitest/
|
68
|
+
* minitest/test - a very fast, simple, and clean test system.
|
69
69
|
* minitest/spec - a very fast, simple, and clean spec system.
|
70
70
|
* minitest/mock - a simple and clean mock/stub system.
|
71
71
|
* minitest/benchmark - an awesome way to assert your algorithm's performance.
|
72
72
|
* minitest/pride - show your pride in testing!
|
73
73
|
* Incredibly small and fast runner, but no bells and whistles.
|
74
|
+
* Written by squishy human beings. Software can never be perfect. We will all eventually die.
|
74
75
|
|
75
76
|
== RATIONALE:
|
76
77
|
|
@@ -92,7 +93,7 @@ Given that you'd like to test the following class:
|
|
92
93
|
|
93
94
|
=== Unit tests
|
94
95
|
|
95
|
-
Define your tests as methods beginning with
|
96
|
+
Define your tests as methods beginning with +test_+.
|
96
97
|
|
97
98
|
require "minitest/autorun"
|
98
99
|
|
@@ -160,7 +161,7 @@ Add benchmarks to your tests.
|
|
160
161
|
Or add them to your specs. If you make benchmarks optional, you'll
|
161
162
|
need to wrap your benchmarks in a conditional since the methods won't
|
162
163
|
be defined. In minitest 5, the describe name needs to match
|
163
|
-
|
164
|
+
<tt>/Bench(mark)?$/</tt>.
|
164
165
|
|
165
166
|
describe "Meme Benchmark" do
|
166
167
|
if ENV["BENCH"] then
|
@@ -267,7 +268,7 @@ Ideally, you'll use a rake task to run your tests, either piecemeal or
|
|
267
268
|
all at once. Both rake and rails ship with rake tasks for running your
|
268
269
|
tests. BUT! You don't have to:
|
269
270
|
|
270
|
-
% ruby -Ilib:test test/minitest/
|
271
|
+
% ruby -Ilib:test test/minitest/test_minitest_test.rb
|
271
272
|
Run options: --seed 37685
|
272
273
|
|
273
274
|
# Running:
|
@@ -279,14 +280,15 @@ tests. BUT! You don't have to:
|
|
279
280
|
155 runs, 317 assertions, 0 failures, 0 errors, 0 skips
|
280
281
|
|
281
282
|
There are runtime options available, both from minitest itself, and also
|
282
|
-
provided via plugins. To see them, simply run with
|
283
|
+
provided via plugins. To see them, simply run with +--help+:
|
283
284
|
|
284
|
-
% ruby -Ilib:test test/minitest/
|
285
|
+
% ruby -Ilib:test test/minitest/test_minitest_test.rb --help
|
285
286
|
minitest options:
|
286
287
|
-h, --help Display this help.
|
287
288
|
-s, --seed SEED Sets random seed
|
288
289
|
-v, --verbose Verbose. Show progress processing files.
|
289
290
|
-n, --name PATTERN Filter run on /pattern/ or string.
|
291
|
+
-e, --exclude PATTERN Exclude /regexp/ or string from run.
|
290
292
|
|
291
293
|
Known extensions: pride, autotest
|
292
294
|
-p, --pride Pride. Show your testing pride!
|
@@ -297,8 +299,8 @@ provided via plugins. To see them, simply run with `--help`:
|
|
297
299
|
To define a plugin, add a file named minitest/XXX_plugin.rb to your
|
298
300
|
project/gem. That file must be discoverable via ruby's LOAD_PATH (via
|
299
301
|
rubygems or otherwise). Minitest will find and require that file using
|
300
|
-
Gem.find_files. It will then try to call plugin_XXX_init during
|
301
|
-
startup. The option processor will also try to call plugin_XXX_options
|
302
|
+
Gem.find_files. It will then try to call +plugin_XXX_init+ during
|
303
|
+
startup. The option processor will also try to call +plugin_XXX_options+
|
302
304
|
passing the OptionParser instance and the current options hash. This
|
303
305
|
lets you register your own command-line options. Here's a totally
|
304
306
|
bogus example:
|
@@ -324,7 +326,7 @@ bogus example:
|
|
324
326
|
Minitest uses composite reporter to output test results using multiple
|
325
327
|
reporter instances. You can add new reporters to the composite during
|
326
328
|
the init_plugins phase. As we saw in +plugin_bonus_init+ above, you
|
327
|
-
simply add your reporter instance to the composite via
|
329
|
+
simply add your reporter instance to the composite via <tt><<</tt>.
|
328
330
|
|
329
331
|
+AbstractReporter+ defines the API for reporters. You may subclass it
|
330
332
|
and override any method you want to achieve your desired behavior.
|
@@ -389,12 +391,12 @@ outputs a failure:
|
|
389
391
|
|
390
392
|
Worker is a SimpleDelegate which in 1.9+ is a subclass of BasicObject.
|
391
393
|
Expectations are put on Object (one level down) so the Worker
|
392
|
-
(SimpleDelegate) hits
|
393
|
-
|
394
|
+
(SimpleDelegate) hits +method_missing+ and delegates down to the
|
395
|
+
+Object.new+ instance. That object doesn't respond to work so the test
|
394
396
|
fails.
|
395
397
|
|
396
|
-
You can bypass
|
397
|
-
with
|
398
|
+
You can bypass <tt>SimpleDelegate#method_missing</tt> by extending the worker
|
399
|
+
with <tt>Minitest::Expectations</tt>. You can either do that in your setup at
|
398
400
|
the instance level, like:
|
399
401
|
|
400
402
|
before do
|
@@ -426,17 +428,17 @@ Use a module. That's exactly what they're for:
|
|
426
428
|
end
|
427
429
|
end
|
428
430
|
|
429
|
-
Remember,
|
431
|
+
Remember, +describe+ simply creates test classes. It's just ruby at
|
430
432
|
the end of the day and all your normal Good Ruby Rules (tm) apply. If
|
431
433
|
you want to extend your test using setup/teardown via a module, just
|
432
434
|
make sure you ALWAYS call super. before/after automatically call super
|
433
435
|
for you, so make sure you don't do it twice.
|
434
436
|
|
435
|
-
=== Why am I seeing
|
437
|
+
=== Why am I seeing <tt>uninitialized constant MiniTest::Test (NameError)</tt>?
|
436
438
|
|
437
|
-
Are you running the test with Bundler (e.g. via
|
438
|
-
in order to require minitest, you must first add the
|
439
|
-
to your Gemfile and run
|
439
|
+
Are you running the test with Bundler (e.g. via <tt>bundle exec</tt> )? If so,
|
440
|
+
in order to require minitest, you must first add the <tt>gem 'minitest'</tt>
|
441
|
+
to your Gemfile and run +bundle+. Once it's installed, you should be
|
440
442
|
able to require minitest and run your tests.
|
441
443
|
|
442
444
|
== Prominent Projects using Minitest:
|
@@ -454,12 +456,12 @@ able to require minitest and run your tests.
|
|
454
456
|
|
455
457
|
capybara_minitest_spec :: Bridge between Capybara RSpec matchers and
|
456
458
|
Minitest::Spec expectations (e.g.
|
457
|
-
page.must_have_content("Title")).
|
459
|
+
<tt>page.must_have_content("Title")</tt>).
|
458
460
|
color_pound_spec_reporter :: Test names print Ruby Object types in color with
|
459
461
|
your Minitest Spec style tests.
|
460
462
|
minispec-metadata :: Metadata for describe/it blocks & CLI tag filter.
|
461
|
-
E.g.
|
462
|
-
|
463
|
+
E.g. <tt>it "requires JS driver", js: true do</tt> &
|
464
|
+
<tt>ruby test.rb --tag js</tt> runs tests tagged :js.
|
463
465
|
minitest-around :: Around block for minitest. An alternative to
|
464
466
|
setup/teardown dance.
|
465
467
|
minitest-assert_errors :: Adds Minitest assertions to test for errors raised
|
@@ -549,7 +551,7 @@ minitest-sequel :: Minitest assertions to speed-up development and
|
|
549
551
|
testing of Ruby Sequel database setups.
|
550
552
|
minitest-shared_description :: Support for shared specs and shared spec
|
551
553
|
subclasses
|
552
|
-
minitest-should_syntax :: RSpec-style
|
554
|
+
minitest-should_syntax :: RSpec-style <tt>x.should == y</tt> assertions for
|
553
555
|
Minitest.
|
554
556
|
minitest-shouldify :: Adding all manner of shoulds to Minitest (bad
|
555
557
|
idea)
|
@@ -606,6 +608,7 @@ Authors... Please send me a pull request with a description of your minitest ext
|
|
606
608
|
== REQUIREMENTS:
|
607
609
|
|
608
610
|
* Ruby 1.8.7+. No magic is involved. I hope.
|
611
|
+
* NOTE: 1.8 and 1.9 will be dropped in minitest 6+.
|
609
612
|
|
610
613
|
== INSTALL:
|
611
614
|
|
data/lib/hoe/minitest.rb
CHANGED
@@ -4,22 +4,16 @@ class Hoe
|
|
4
4
|
end
|
5
5
|
|
6
6
|
module Hoe::Minitest
|
7
|
-
def minitest?
|
8
|
-
self.name == "minitest"
|
9
|
-
end
|
10
|
-
|
11
7
|
def initialize_minitest
|
12
|
-
|
13
|
-
|
14
|
-
Hoe.add_include_dirs dir if File.directory? dir
|
15
|
-
end
|
8
|
+
dir = "../../minitest/dev/lib"
|
9
|
+
Hoe.add_include_dirs dir if File.directory? dir
|
16
10
|
|
17
11
|
gem "minitest"
|
18
12
|
require "minitest"
|
19
13
|
version = Minitest::VERSION.split(/\./).first(2).join(".")
|
20
14
|
|
21
15
|
dependency "minitest", "~> #{version}", :development unless
|
22
|
-
minitest
|
16
|
+
self.name == "minitest" or ENV["MT_NO_ISOLATE"]
|
23
17
|
end
|
24
18
|
|
25
19
|
def define_minitest_tasks
|
@@ -27,6 +21,6 @@ module Hoe::Minitest
|
|
27
21
|
|
28
22
|
# make sure we use the gemmed minitest on 1.9
|
29
23
|
self.test_prelude = 'gem "minitest"' unless
|
30
|
-
minitest
|
24
|
+
self.name == "minitest" or ENV["MT_NO_ISOLATE"]
|
31
25
|
end
|
32
26
|
end
|
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.9.0" # :nodoc:
|
11
11
|
ENCS = "".respond_to? :encoding # :nodoc:
|
12
12
|
|
13
13
|
@@installed_at_exit ||= false
|
@@ -39,6 +39,12 @@ module Minitest
|
|
39
39
|
|
40
40
|
mc.send :attr_accessor, :extensions
|
41
41
|
|
42
|
+
##
|
43
|
+
# The signal to use for dumping information to STDERR. Defaults to "INFO".
|
44
|
+
|
45
|
+
mc.send :attr_accessor, :info_signal
|
46
|
+
self.info_signal = "INFO"
|
47
|
+
|
42
48
|
##
|
43
49
|
# Registers Minitest to run at process exit
|
44
50
|
|
@@ -181,6 +187,10 @@ module Minitest
|
|
181
187
|
options[:filter] = a
|
182
188
|
end
|
183
189
|
|
190
|
+
opts.on "-e", "--exclude PATTERN", "Exclude /regexp/ or string from run." do |a|
|
191
|
+
options[:exclude] = a
|
192
|
+
end
|
193
|
+
|
184
194
|
unless extensions.empty?
|
185
195
|
opts.separator ""
|
186
196
|
opts.separator "Known extensions: #{extensions.join(", ")}"
|
@@ -286,6 +296,13 @@ module Minitest
|
|
286
296
|
filter === m || filter === "#{self}##{m}"
|
287
297
|
}
|
288
298
|
|
299
|
+
exclude = options[:exclude]
|
300
|
+
exclude = Regexp.new $1 if exclude =~ %r%/(.*)/%
|
301
|
+
|
302
|
+
filtered_methods.delete_if { |m|
|
303
|
+
exclude === m || exclude === "#{self}##{m}"
|
304
|
+
}
|
305
|
+
|
289
306
|
return if filtered_methods.empty?
|
290
307
|
|
291
308
|
with_info_handler reporter do
|
@@ -315,7 +332,7 @@ module Minitest
|
|
315
332
|
end
|
316
333
|
end
|
317
334
|
|
318
|
-
on_signal
|
335
|
+
on_signal ::Minitest.info_signal, handler, &block
|
319
336
|
end
|
320
337
|
|
321
338
|
SIGNALS = Signal.list # :nodoc:
|
@@ -612,6 +629,10 @@ module Minitest
|
|
612
629
|
self.reporters = reporters
|
613
630
|
end
|
614
631
|
|
632
|
+
def io # :nodoc:
|
633
|
+
reporters.first.io
|
634
|
+
end
|
635
|
+
|
615
636
|
##
|
616
637
|
# Add another reporter to the mix.
|
617
638
|
|
data/lib/minitest/assertions.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require "rbconfig"
|
2
4
|
require "tempfile"
|
3
5
|
require "stringio"
|
@@ -104,7 +106,15 @@ module Minitest
|
|
104
106
|
|
105
107
|
def mu_pp obj
|
106
108
|
s = obj.inspect
|
107
|
-
|
109
|
+
|
110
|
+
if defined? Encoding then
|
111
|
+
s = s.encode Encoding.default_external
|
112
|
+
|
113
|
+
if String === obj && obj.encoding != Encoding.default_external then
|
114
|
+
s = "# encoding: #{obj.encoding}\n#{s}"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
108
118
|
s
|
109
119
|
end
|
110
120
|
|
@@ -124,7 +134,7 @@ module Minitest
|
|
124
134
|
def assert test, msg = nil
|
125
135
|
self.assertions += 1
|
126
136
|
unless test then
|
127
|
-
msg ||= "
|
137
|
+
msg ||= "Expected #{mu_pp test} to be truthy."
|
128
138
|
msg = msg.call if Proc === msg
|
129
139
|
raise Minitest::Assertion, msg
|
130
140
|
end
|
@@ -152,7 +162,8 @@ module Minitest
|
|
152
162
|
#
|
153
163
|
# If there is no visible difference but the assertion fails, you
|
154
164
|
# should suspect that your #== is buggy, or your inspect output is
|
155
|
-
# missing crucial details.
|
165
|
+
# missing crucial details. For nicer structural diffing, set
|
166
|
+
# Minitest::Test.make_my_diffs_pretty!
|
156
167
|
#
|
157
168
|
# For floats use assert_in_delta.
|
158
169
|
#
|
@@ -252,6 +263,8 @@ module Minitest
|
|
252
263
|
# "" if you require it to be silent. Pass in a regexp if you want
|
253
264
|
# to pattern match.
|
254
265
|
#
|
266
|
+
# assert_output(/hey/) { method_with_output }
|
267
|
+
#
|
255
268
|
# NOTE: this uses #capture_io, not #capture_subprocess_io.
|
256
269
|
#
|
257
270
|
# See also: #assert_silent
|
@@ -501,7 +514,7 @@ module Minitest
|
|
501
514
|
# Fails if +test+ is truthy.
|
502
515
|
|
503
516
|
def refute test, msg = nil
|
504
|
-
msg ||= "
|
517
|
+
msg ||= message { "Expected #{mu_pp(test)} to not be truthy" }
|
505
518
|
not assert !test, msg
|
506
519
|
end
|
507
520
|
|
data/lib/minitest/autorun.rb
CHANGED
data/lib/minitest/benchmark.rb
CHANGED
data/lib/minitest/hell.rb
CHANGED
data/lib/minitest/mock.rb
CHANGED
@@ -166,6 +166,15 @@ module Minitest # :nodoc:
|
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
|
+
module Minitest::Assertions
|
170
|
+
##
|
171
|
+
# Assert that the mock verifies correctly.
|
172
|
+
|
173
|
+
def assert_mock mock
|
174
|
+
assert mock.verify
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
169
178
|
##
|
170
179
|
# Object extensions for Minitest::Mock.
|
171
180
|
|
data/lib/minitest/test.rb
CHANGED
@@ -11,8 +11,7 @@ module Minitest
|
|
11
11
|
require "minitest/assertions"
|
12
12
|
include Minitest::Assertions
|
13
13
|
|
14
|
-
PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException, # :nodoc:
|
15
|
-
Interrupt, SystemExit]
|
14
|
+
PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException, SystemExit] # :nodoc:
|
16
15
|
|
17
16
|
class << self; attr_accessor :io_lock; end # :nodoc:
|
18
17
|
self.io_lock = Mutex.new
|
@@ -273,7 +272,7 @@ module Minitest
|
|
273
272
|
warn "\nCurrent: %s#%s %.2fs" % [self.class, self.name, Minitest.clock_time - t0]
|
274
273
|
end
|
275
274
|
|
276
|
-
self.class.on_signal
|
275
|
+
self.class.on_signal ::Minitest.info_signal, handler, &block
|
277
276
|
end
|
278
277
|
|
279
278
|
include LifecycleHooks
|
data/lib/minitest/unit.rb
CHANGED