minitest 5.10.3 → 5.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 32d4df1397bf8fc366b4b18555936d7c92853121
4
- data.tar.gz: 4000474506d5056f3117b1a93e1bc4019dfd15af
2
+ SHA256:
3
+ metadata.gz: 6db5992e9a08e2dc6f38cae45eb2b363db069130b15103a42dbc62e675f89120
4
+ data.tar.gz: 61852113ccc15d225be0e9f751315833be115e10215a88911fde0b3d933b0622
5
5
  SHA512:
6
- metadata.gz: 195277b6093c3650634809f445c274d8df6bfafb4f32be448f4cdde07de9edf47c64e4f05cdf3572bf79f61e2597ce33c2b7821cd147d4c8bd2f251451e86098
7
- data.tar.gz: a8a16930df76274303310ba4faf115914913bea38b559ec4edfad8ae2a835fb22e7d6308c88eadf93044ea422b334d65e33c8c59f15f0ece27a962b1fc8d7e9c
6
+ metadata.gz: 3b3d3f7ba9ec79e2e8f5a286c47b97fb588e5b1b8e157c598e930257342f7b82b8b37fdde2687196a5efa0e3ef1f713aecf64f9bddad3f562a6f13718dc387c8
7
+ data.tar.gz: ee3c67d52c3fd56d0514b067774771738297225670478f945f7144797914bc7a975d5c8f064a54efbffbe08084ee0fcd4d6c903e80f25e2dcd19fa38644a5afc
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- V���%s�geQ�K�͝PuI}����I6I}Kj��ڳt8a"w��TFig�"��(��Hڞ�Ӱ�V�ص^����Z=�j�=���'����-���i*-u�/�d���1�z��/��X�E8a��� �•�z֍?!�$�:�uwR"b��C��3L���j��Tk��!�Y6���޶���n^/w�o@J
2
- /���-�*�^~)ZY' �,5��vCM 1��B�����Ny8
1
+ ^&�_�&��&��Hf��F9��"r�l�@*S0OqqgmfBG��ٮ��3�w��1xM"U󠑪���Sj��5t�+�cO����в�� g����X树>#�W��y̧�����$���ID�>�S����X��ɂo���b
2
+ O���D6����ܔ�0YR ���nArø@�l��b����7g�$^F7�:����}TK{�Y~e��z��eR8j{8w���.1r��fr�.6��tr�� Ta(n�� �
@@ -1,3 +1,91 @@
1
+ === 5.12.0 / 2019-09-22
2
+
3
+ * 8 minor enhancements:
4
+
5
+ * Added a descriptive error if assert_output or assert_raises called without a block. (okuramasafumi)
6
+ * Changed mu_pp_for_diff to make having both \n and \\n easier to debug.
7
+ * Deprecated $N for specifying number of parallel test runners. Use MT_CPU.
8
+ * Deprecated use of global expectations. To be removed from MT6.
9
+ * Extended Assertions#mu_pp to encoding validity output for strings to improve diffs.
10
+ * Extended Assertions#mu_pp to output encoding and validity if invalid to improve diffs.
11
+ * Extended Assertions#mu_pp_for_diff to make escaped newlines more obvious in diffs.
12
+ * Fail gracefully when expectation used outside of `it`.
13
+
14
+ * 3 bug fixes:
15
+
16
+ * Check `option[:filter]` klass before match. Fixes 2.6 warning. (y-yagi)
17
+ * Fixed Assertions#diff from recalculating if set to nil
18
+ * Fixed spec section of readme to not use deprecated global expectations. (CheezItMan)
19
+
20
+ === 5.11.3 / 2018-01-26
21
+
22
+ * 1 bug fix:
23
+
24
+ * Pushed #error? up to Reportable module. (composerinteralia)
25
+
26
+ === 5.11.2 / 2018-01-25
27
+
28
+ * 1 minor enhancement:
29
+
30
+ * Reversed Test < Result. Back to < Runnable and using Reportable for shared code.
31
+
32
+ * 2 bug fixes:
33
+
34
+ * Fixed Result#location for instances of Test. (alexisbernard)
35
+ * Fixed deprecation message for Runnable#marshal_dump. (y-yagi)
36
+
37
+ === 5.11.1 / 2018-01-02
38
+
39
+ * 1 bug fix:
40
+
41
+ * Fixed Result (a superclass of Test) overriding Runnable's name accessors. (y-yagi, MSP-Greg)
42
+
43
+ === 5.11.0 / 2018-01-01
44
+
45
+ * 2 major enhancements:
46
+
47
+ * Added Minitest::Result and Minitest::Result.from(runnable).
48
+ * Changed Minitest::Test to subclass Result and refactored methods up.
49
+
50
+ * 7 minor enhancements:
51
+
52
+ * Added --no-plugins and MT_NO_PLUGINS to bypass MT plugin autoloading. Helps with bad actors installed globally.
53
+ * Added bench_performance_{logarithmic,power} for spec-style benchmarks. (rickhull)
54
+ * Added deprecation warning for Runnable#marshal_dump.
55
+ * Minitest.run_one_method now checks for instance of Result, not exact same class.
56
+ * Minitest::Test.run returns a Result version of self, not self.
57
+ * ProgressReporter#prerecord now explicitly prints klass.name. Allows for fakers.
58
+
59
+ * 4 bug fixes:
60
+
61
+ * Object.stub no longer calls the passed block if stubbed with a callable.
62
+ * Object.stub now passes blocks down to the callable result.
63
+ * Pushed Minitest::Test#time & #time_it up to Runnable.
64
+ * Test nil equality directly in assert_equal. Fixes #679. (voxik)
65
+
66
+ === 5.11.0b1 / 2017-12-20
67
+
68
+ * 2 major enhancements:
69
+
70
+ * Added Minitest::Result and Minitest::Result.from(runnable).
71
+ * Changed Minitest::Test to subclass Result and refactored methods up.
72
+
73
+ * 6 minor enhancements:
74
+
75
+ * Added --no-plugins and MT_NO_PLUGINS to bypass MT plugin autoloading. Helps with bad actors installed globally.
76
+ * Added bench_performance_{logarithmic,power} for spec-style benchmarks. (rickhull)
77
+ * Minitest.run_one_method now checks for instance of Result, not exact same class.
78
+ * Minitest::Test.run returns a Result version of self, not self.
79
+ * ProgressReporter#prerecord now explicitly prints klass.name. Allows for fakers.
80
+ * Removed Runnable.marshal_dump/load.
81
+
82
+ * 4 bug fixes:
83
+
84
+ * Object.stub no longer calls the passed block if stubbed with a callable.
85
+ * Object.stub now passes blocks down to the callable result.
86
+ * Pushed Minitest::Test#time & #time_it up to Runnable.
87
+ * Test nil equality directly in assert_equal. Fixes #679. (voxik)
88
+
1
89
  === 5.10.3 / 2017-07-21
2
90
 
3
91
  * 1 minor enhancement:
@@ -19,6 +19,7 @@ lib/minitest/spec.rb
19
19
  lib/minitest/test.rb
20
20
  lib/minitest/unit.rb
21
21
  test/minitest/metametameta.rb
22
+ test/minitest/test_minitest_assertions.rb
22
23
  test/minitest/test_minitest_benchmark.rb
23
24
  test/minitest/test_minitest_mock.rb
24
25
  test/minitest/test_minitest_reporter.rb
@@ -126,13 +126,13 @@ Define your tests as methods beginning with +test_+.
126
126
 
127
127
  describe "when asked about cheeseburgers" do
128
128
  it "must respond positively" do
129
- @meme.i_can_has_cheezburger?.must_equal "OHAI!"
129
+ _(@meme.i_can_has_cheezburger?).must_equal "OHAI!"
130
130
  end
131
131
  end
132
132
 
133
133
  describe "when asked about blending possibilities" do
134
134
  it "won't say no" do
135
- @meme.will_it_blend?.wont_match /^no/i
135
+ _(@meme.will_it_blend?).wont_match /^no/i
136
136
  end
137
137
  end
138
138
  end
@@ -294,6 +294,18 @@ provided via plugins. To see them, simply run with +--help+:
294
294
  -p, --pride Pride. Show your testing pride!
295
295
  -a, --autotest Connect to autotest server.
296
296
 
297
+ You can set up a rake task to run all your tests by adding this to your Rakefile:
298
+
299
+ require "rake/testtask"
300
+
301
+ Rake::TestTask.new(:test) do |t|
302
+ t.libs << "test"
303
+ t.libs << "lib"
304
+ t.test_files = FileList["test/**/test_*.rb"]
305
+ end
306
+
307
+ task :default => :test
308
+
297
309
  == Writing Extensions
298
310
 
299
311
  To define a plugin, add a file named minitest/XXX_plugin.rb to your
@@ -379,7 +391,7 @@ The following implementation and test:
379
391
  end
380
392
 
381
393
  it "must respond to work" do
382
- @worker.must_respond_to :work
394
+ _(@worker).must_respond_to :work
383
395
  end
384
396
  end
385
397
 
@@ -434,11 +446,26 @@ you want to extend your test using setup/teardown via a module, just
434
446
  make sure you ALWAYS call super. before/after automatically call super
435
447
  for you, so make sure you don't do it twice.
436
448
 
449
+ === How to run code before a group of tests?
450
+
451
+ Use a constant with begin...end like this:
452
+
453
+ describe Blah do
454
+ SETUP = begin
455
+ # ... this runs once when describe Blah starts
456
+ end
457
+ # ...
458
+ end
459
+
460
+ This can be useful for expensive initializations or sharing state.
461
+ Remember, this is just ruby code, so you need to make sure this
462
+ technique and sharing state doesn't interfere with your tests.
463
+
437
464
  === Why am I seeing <tt>uninitialized constant MiniTest::Test (NameError)</tt>?
438
465
 
439
- Are you running the test with Bundler (e.g. via <tt>bundle exec</tt> )? If so,
466
+ Are you running the test with Bundler (e.g. via <tt>bundle exec</tt> )? If so,
440
467
  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
468
+ to your Gemfile and run +bundle+. Once it's installed, you should be
442
469
  able to require minitest and run your tests.
443
470
 
444
471
  == Prominent Projects using Minitest:
@@ -506,7 +533,7 @@ If you see failures like either of these, you are probably missing diff tool:
506
533
 
507
534
 
508
535
  If you use Cygwin or MSYS2 or similar there are packages that include a
509
- GNU diff for Widnows. If you don't, you can download GNU diffutils from
536
+ GNU diff for Windows. If you don't, you can download GNU diffutils from
510
537
  http://gnuwin32.sourceforge.net/packages/diffutils.htm
511
538
  (make sure to add it to your PATH).
512
539
 
@@ -578,7 +605,7 @@ minitest-great_expectations :: Generally useful additions to minitest's
578
605
  assertions and expectations.
579
606
  minitest-growl :: Test notifier for minitest via growl.
580
607
  minitest-happy :: GLOBALLY ACTIVATE MINITEST PRIDE! RAWR!
581
- minitest-have_tag :: Adds Minitest assertions to test for the existence of
608
+ minitest-have_tag :: Adds Minitest assertions to test for the existence of
582
609
  HTML tags, including contents, within a provided string.
583
610
  minitest-hooks :: Around and before_all/after_all/around_all hooks
584
611
  minitest-hyper :: Pretty, single-page HTML reports for your Minitest runs
@@ -588,6 +615,7 @@ minitest-instrument :: Instrument ActiveSupport::Notifications when
588
615
  minitest-instrument-db :: Store information about speed of test execution
589
616
  provided by minitest-instrument in database.
590
617
  minitest-junit :: JUnit-style XML reporter for minitest.
618
+ minitest-keyword :: Use Minitest assertions with keyword arguments.
591
619
  minitest-libnotify :: Test notifier for minitest via libnotify.
592
620
  minitest-line :: Run test at line number.
593
621
  minitest-logger :: Define assert_log and enable minitest to test log messages.
@@ -599,6 +627,7 @@ minitest-matchers :: Adds support for RSpec-style matchers to
599
627
  minitest-matchers_vaccine :: Adds assertions that adhere to the matcher spec,
600
628
  but without any expectation infections.
601
629
  minitest-metadata :: Annotate tests with metadata (key-value).
630
+ minitest-mock_expectations :: Provides method call assertions for minitest.
602
631
  minitest-mongoid :: Mongoid assertion matchers for Minitest.
603
632
  minitest-must_not :: Provides must_not as an alias for wont in
604
633
  Minitest.
@@ -614,10 +643,10 @@ minitest-rails-capybara :: Capybara integration for Minitest::Rails.
614
643
  minitest-reporters :: Create customizable Minitest output formats.
615
644
  minitest-rg :: Colored red/green output for Minitest.
616
645
  minitest-rspec_mocks :: Use RSpec Mocks with Minitest.
617
- minitest-server :: minitest-server provides a client/server setup
618
- with your minitest process, allowing your test
646
+ minitest-server :: minitest-server provides a client/server setup
647
+ with your minitest process, allowing your test
619
648
  run to send its results directly to a handler.
620
- minitest-sequel :: Minitest assertions to speed-up development and
649
+ minitest-sequel :: Minitest assertions to speed-up development and
621
650
  testing of Ruby Sequel database setups.
622
651
  minitest-shared_description :: Support for shared specs and shared spec
623
652
  subclasses
@@ -648,6 +677,7 @@ minitest_owrapper :: Get tests results as a TestResult object.
648
677
  minitest_should :: Shoulda style syntax for minitest test::unit.
649
678
  minitest_tu_shim :: Bridges between test/unit and minitest.
650
679
  mongoid-minitest :: Minitest matchers for Mongoid.
680
+ mutant-minitest :: Minitest integration for mutant.
651
681
  pry-rescue :: A pry plugin w/ minitest support. See
652
682
  pry-rescue/minitest.rb.
653
683
  rspec2minitest :: Easily translate any RSpec matchers to Minitest
@@ -8,7 +8,7 @@ require "stringio"
8
8
  # :include: README.rdoc
9
9
 
10
10
  module Minitest
11
- VERSION = "5.10.3" # :nodoc:
11
+ VERSION = "5.12.0" # :nodoc:
12
12
  ENCS = "".respond_to? :encoding # :nodoc:
13
13
 
14
14
  @@installed_at_exit ||= false
@@ -21,7 +21,10 @@ module Minitest
21
21
  # Parallel test executor
22
22
 
23
23
  mc.send :attr_accessor, :parallel_executor
24
- self.parallel_executor = Parallel::Executor.new((ENV["N"] || 2).to_i)
24
+
25
+ warn "DEPRECATED: use MT_CPU instead of N for parallel test runs" if ENV["N"]
26
+ n_threads = (ENV["MT_CPU"] || ENV["N"] || 2).to_i
27
+ self.parallel_executor = Parallel::Executor.new n_threads
25
28
 
26
29
  ##
27
30
  # Filter object for backtraces.
@@ -118,7 +121,7 @@ module Minitest
118
121
  # klass.new(runnable_method).run
119
122
 
120
123
  def self.run args = []
121
- self.load_plugins
124
+ self.load_plugins unless args.delete("--no-plugins") || ENV["MT_NO_PLUGINS"]
122
125
 
123
126
  options = process_args args
124
127
 
@@ -175,6 +178,8 @@ module Minitest
175
178
  exit
176
179
  end
177
180
 
181
+ opts.on "--no-plugins", "Bypass minitest plugin auto-loading (or set $MT_NO_PLUGINS)."
182
+
178
183
  desc = "Sets random seed. Also via env. Eg: SEED=n rake"
179
184
  opts.on "-s", "--seed SEED", Integer, desc do |m|
180
185
  options[:seed] = m.to_i
@@ -252,6 +257,19 @@ module Minitest
252
257
 
253
258
  attr_accessor :failures
254
259
 
260
+ ##
261
+ # The time it took to run.
262
+
263
+ attr_accessor :time
264
+
265
+ def time_it # :nodoc:
266
+ t0 = Minitest.clock_time
267
+
268
+ yield
269
+ ensure
270
+ self.time = Minitest.clock_time - t0
271
+ end
272
+
255
273
  ##
256
274
  # Name of the run.
257
275
 
@@ -266,11 +284,6 @@ module Minitest
266
284
  @NAME = o
267
285
  end
268
286
 
269
- def self.inherited klass # :nodoc:
270
- self.runnables << klass
271
- super
272
- end
273
-
274
287
  ##
275
288
  # Returns all instance methods matching the pattern +re+.
276
289
 
@@ -291,7 +304,7 @@ module Minitest
291
304
 
292
305
  def self.run reporter, options = {}
293
306
  filter = options[:filter] || "/./"
294
- filter = Regexp.new $1 if filter =~ %r%/(.*)/%
307
+ filter = Regexp.new $1 if filter.is_a?(String) && filter =~ %r%/(.*)/%
295
308
 
296
309
  filtered_methods = self.runnable_methods.find_all { |m|
297
310
  filter === m || filter === "#{self}##{m}"
@@ -367,12 +380,20 @@ module Minitest
367
380
  @@runnables
368
381
  end
369
382
 
383
+ @@marshal_dump_warned = false
384
+
370
385
  def marshal_dump # :nodoc:
371
- [self.name, self.failures, self.assertions]
386
+ unless @@marshal_dump_warned then
387
+ warn ["Minitest::Runnable#marshal_dump is deprecated.",
388
+ "You might be violating internals. From", caller.first].join " "
389
+ @@marshal_dump_warned = true
390
+ end
391
+
392
+ [self.name, self.failures, self.assertions, self.time]
372
393
  end
373
394
 
374
395
  def marshal_load ary # :nodoc:
375
- self.name, self.failures, self.assertions = ary
396
+ self.name, self.failures, self.assertions, self.time = ary
376
397
  end
377
398
 
378
399
  def failure # :nodoc:
@@ -418,6 +439,109 @@ module Minitest
418
439
  end
419
440
  end
420
441
 
442
+ ##
443
+ # Shared code for anything that can get passed to a Reporter. See
444
+ # Minitest::Test & Minitest::Result.
445
+
446
+ module Reportable
447
+ ##
448
+ # Did this run pass?
449
+ #
450
+ # Note: skipped runs are not considered passing, but they don't
451
+ # cause the process to exit non-zero.
452
+
453
+ def passed?
454
+ not self.failure
455
+ end
456
+
457
+ ##
458
+ # The location identifier of this test. Depends on a method
459
+ # existing called class_name.
460
+
461
+ def location
462
+ loc = " [#{self.failure.location}]" unless passed? or error?
463
+ "#{self.class_name}##{self.name}#{loc}"
464
+ end
465
+
466
+ def class_name # :nodoc:
467
+ raise NotImplementedError, "subclass responsibility"
468
+ end
469
+
470
+ ##
471
+ # Returns ".", "F", or "E" based on the result of the run.
472
+
473
+ def result_code
474
+ self.failure and self.failure.result_code or "."
475
+ end
476
+
477
+ ##
478
+ # Was this run skipped?
479
+
480
+ def skipped?
481
+ self.failure and Skip === self.failure
482
+ end
483
+
484
+ ##
485
+ # Did this run error?
486
+
487
+ def error?
488
+ self.failures.any? { |f| UnexpectedError === f }
489
+ end
490
+ end
491
+
492
+ ##
493
+ # This represents a test result in a clean way that can be
494
+ # marshalled over a wire. Tests can do anything they want to the
495
+ # test instance and can create conditions that cause Marshal.dump to
496
+ # blow up. By using Result.from(a_test) you can be reasonably sure
497
+ # that the test result can be marshalled.
498
+
499
+ class Result < Runnable
500
+ include Minitest::Reportable
501
+
502
+ undef_method :marshal_dump
503
+ undef_method :marshal_load
504
+
505
+ ##
506
+ # The class name of the test result.
507
+
508
+ attr_accessor :klass
509
+
510
+ ##
511
+ # The location of the test method.
512
+
513
+ attr_accessor :source_location
514
+
515
+ ##
516
+ # Create a new test result from a Runnable instance.
517
+
518
+ def self.from runnable
519
+ o = runnable
520
+
521
+ r = self.new o.name
522
+ r.klass = o.class.name
523
+ r.assertions = o.assertions
524
+ r.failures = o.failures.dup
525
+ r.time = o.time
526
+
527
+ r.source_location = o.method(o.name).source_location rescue ["unknown", -1]
528
+
529
+ r
530
+ end
531
+
532
+ def class_name # :nodoc:
533
+ self.klass # for Minitest::Reportable
534
+ end
535
+
536
+ def to_s # :nodoc:
537
+ return location if passed? and not skipped?
538
+
539
+ failures.map { |failure|
540
+ "#{failure.result_label}:\n#{self.location}:\n#{failure.message}\n"
541
+ }.join "\n"
542
+ end
543
+ end
544
+
421
545
  ##
422
546
  # Defines the API for Reporters. Subclass this and override whatever
423
547
  # you want. Go nuts.
@@ -488,7 +612,7 @@ module Minitest
488
612
  class ProgressReporter < Reporter
489
613
  def prerecord klass, name #:nodoc:
490
614
  if options[:verbose] then
491
- io.print "%s#%s = " % [klass, name]
615
+ io.print "%s#%s = " % [klass.name, name]
492
616
  io.flush
493
617
  end
494
618
  end
@@ -837,7 +961,7 @@ module Minitest
837
961
 
838
962
  def self.run_one_method klass, method_name # :nodoc:
839
963
  result = klass.new(method_name).run
840
- raise "#{klass}#run _must_ return self" unless klass === result
964
+ raise "#{klass}#run _must_ return a Result" unless Result === result
841
965
  result
842
966
  end
843
967
 
@@ -853,6 +977,13 @@ module Minitest
853
977
  end
854
978
  end
855
979
 
980
+ class Runnable # re-open
981
+ def self.inherited klass # :nodoc:
982
+ self.runnables << klass
983
+ super
984
+ end
985
+ end
986
+
856
987
  # :startdoc:
857
988
  end
858
989