minitest-5.10.3/ 0000755 0000041 0000041 00000000000 13135676423 013476 5 ustar www-data www-data minitest-5.10.3/Rakefile 0000444 0000041 0000041 00000005051 13135676423 015142 0 ustar www-data www-data # -*- ruby -*-
require "rubygems"
require "hoe"
Hoe.plugin :seattlerb
Hoe.plugin :rdoc
Hoe.spec "minitest" do
developer "Ryan Davis", "ryand-ruby@zenspider.com"
license "MIT"
## TODO: uncomment this on the last point release on 5.x
#
# self.post_install_message = <<-"EOM"
# NOTE: minitest 5 will be the last in the minitest family to support
# ruby 1.8 and 1.9 (and maybe 2.0?). If you need to keep using 1.8
# or 1.9, you need to pin your dependency to minitest with
# something like "~> 5.0".
#
# Further, minitest 6 will be dropping the following:
#
# + MiniTest (it's been Minitest for *years*)
# + MiniTest::Unit
# + MiniTest::Unit::TestCase
# + assert_send (unless you argue for it well)
# EOM
end
desc "Find missing expectations"
task :specs do
$:.unshift "lib"
require "minitest/test"
require "minitest/spec"
pos_prefix, neg_prefix = "must", "wont"
skip_re = /^(must|wont)$|wont_(throw)|must_(block|not?_|nothing|raise$)/x
dont_flip_re = /(must|wont)_(include|respond_to)/
map = {
/(must_throw)s/ => '\1',
/(?!not)_same/ => "_be_same_as",
/_in_/ => "_be_within_",
/_operator/ => "_be",
/_includes/ => "_include",
/(must|wont)_(.*_of|nil|silent|empty)/ => '\1_be_\2',
/must_raises/ => "must_raise",
}
expectations = Minitest::Expectations.public_instance_methods.map(&:to_s)
assertions = Minitest::Assertions.public_instance_methods.map(&:to_s)
assertions.sort.each do |assertion|
expectation = case assertion
when /^assert/ then
assertion.sub(/^assert/, pos_prefix.to_s)
when /^refute/ then
assertion.sub(/^refute/, neg_prefix.to_s)
end
next unless expectation
next if expectation =~ skip_re
regexp, replacement = map.find { |re, _| expectation =~ re }
expectation.sub! regexp, replacement if replacement
next if expectations.include? expectation
args = [assertion, expectation].map(&:to_sym).map(&:inspect)
args << :reverse if expectation =~ dont_flip_re
puts
puts "##"
puts "# :method: #{expectation}"
puts "# See Minitest::Assertions##{assertion}"
puts
puts "infect_an_assertion #{args.join ", "}"
end
end
task :bugs do
sh "for f in bug*.rb ; do echo $f; echo; #{Gem.ruby} -Ilib $f && rm $f ; done"
end
# vim: syntax=Ruby
minitest-5.10.3/Manifest.txt 0000444 0000041 0000041 00000001153 13135676423 016003 0 ustar www-data www-data .autotest
History.rdoc
Manifest.txt
README.rdoc
Rakefile
design_rationale.rb
lib/hoe/minitest.rb
lib/minitest.rb
lib/minitest/assertions.rb
lib/minitest/autorun.rb
lib/minitest/benchmark.rb
lib/minitest/expectations.rb
lib/minitest/hell.rb
lib/minitest/mock.rb
lib/minitest/parallel.rb
lib/minitest/pride.rb
lib/minitest/pride_plugin.rb
lib/minitest/spec.rb
lib/minitest/test.rb
lib/minitest/unit.rb
test/minitest/metametameta.rb
test/minitest/test_minitest_benchmark.rb
test/minitest/test_minitest_mock.rb
test/minitest/test_minitest_reporter.rb
test/minitest/test_minitest_spec.rb
test/minitest/test_minitest_test.rb
minitest-5.10.3/.autotest 0000444 0000041 0000041 00000002123 13135676423 015343 0 ustar www-data www-data # -*- ruby -*-
require 'autotest/restart'
require 'autotest/rcov' if ENV['RCOV']
Autotest.add_hook :initialize do |at|
at.testlib = 'minitest/autorun'
bench_tests = %w(TestMinitestBenchmark)
mock_tests = %w(TestMinitestMock TestMinitestStub)
spec_tests = %w(TestMinitestReporter TestMetaStatic TestMeta
TestSpecInTestCase)
unit_tests = %w(TestMinitestGuard TestMinitestRunnable
TestMinitestRunner TestMinitestTest TestMinitestUnit
TestMinitestUnitInherited TestMinitestUnitOrder
TestMinitestUnitRecording TestMinitestUnitTestCase)
{
bench_tests => "test/minitest/test_minitest_benchmark.rb",
mock_tests => "test/minitest/test_minitest_mock.rb",
spec_tests => "test/minitest/test_minitest_reporter.rb",
unit_tests => "test/minitest/test_minitest_unit.rb",
}.each do |klasses, file|
klasses.each do |klass|
at.extra_class_map[klass] = file
end
end
at.add_exception 'coverage.info'
at.add_exception 'coverage'
end
# require 'autotest/rcov'
# Autotest::RCov.command = 'rcov_info'
minitest-5.10.3/History.rdoc 0000444 0000041 0000041 00000112622 13135676423 016012 0 ustar www-data www-data === 5.10.3 / 2017-07-21
* 1 minor enhancement:
* Extended documentation for Mock#expect for multiple calls to mock object. (insti)
* 2 bug fixes:
* Finished off missing doco.
* Fixed verbose output on parallelize_me! classes. (chanks)
=== 5.10.2 / 2017-05-09
* 1 minor enhancement:
* Added suggestion in minitest/hell to install minitest/proveit.
* 7 bug fixes:
* Expand MT6 to Minitest 6. (xaviershay)
* Fixed location of assert_send deprecation. (rab)
* Fixed location of nil assert_equal deprecation to work with expectations. (jeremyevans)
* Fixed minitest/hell to use parallelize_me! (azul)
* Made deprecation use warn so -W0 will silence it.
* Workaround for rdoc nodoc generation bug that totally f'd up minitest doco. (Paxa)
* Write aggregated_results directly to the IO object to avoid mixed encoding errors. (tenderlove)
=== 5.10.1 / 2016-12-01
* 1 bug fix:
* Added a hack/kludge to deal with missing #prerecord on reporters that aren't properly subclassing AbstractReporter (I'm looking at you minitest-reporters)
=== 5.10.0 / 2016-11-30
* 1 major enhancement:
* Deprecated ruby 1.8, 1.9, possibly 2.0, assert_send, & old MiniTest namespace.
* 3 minor enhancements:
* Warn if assert_equal expects a nil. This will fail in minitest 6+. (tenderlove)
* Added AbstractReporter#prerecord and extended ProgressReporter and CompositeReporter to use it.
* Minor optimization: remove runnables with no runnable methods before run.
* 3 bug fixes:
* Fix assert_throw rescuing any NameError and ArgumentError. (waldyr)
* Clean up (most of the) last remaining vestiges of minitest/unit.
* 2.4: removed deprecation warnings when referring to Fixnum.
=== 5.9.1 / 2016-09-25
* 2 bug fixes:
* Re-release to refresh gem certificate signing. ugh.
* Fixed hoe/minitest to not augment load path if we're actually testing minitest.
=== 5.9.0 / 2016-05-16
* 8 minor enhancements:
* Added Minitest.info_signal accessors to customize signal for test run info. (nate)
* Added assert_mock to make it more clear that you're testing w/ them.
* Added negative filter by test name. (utilum)
* Added warning to README that 1.8 and 1.9 support will be dropped in minitest 6.
* Automatically activate minitest/hell if $MT_HELL is defined.
* Improved default error messages for assert and refute. (bhenderson)
* minitest/hell now tries to require minitest/proveit
* mu_pp for strings prints out non-standard encodings to improve assert_equal diffs.
* 1 bug fix:
* Removed Interrupt from PASSTHROUGH_EXCEPTIONS (already handled). (waldyr)
=== 5.8.5 / 2016-09-25
* 2 bug fixes:
* Re-release to refresh gem certificate signing. ugh.
* Fixed hoe/minitest to not augment load path if we're actually testing minitest.
=== 5.8.4 / 2016-01-21
* 1 bug fix:
* Allow Minitest::Assertion to pass through assert_raises so inner failures are dealt with first.
=== 5.8.3 / 2015-11-17
* 1 minor enhancement:
* Added extra note about mocks and threads to readme. (zamith)
* 1 bug fix:
* Fixed bug in Mock#verify. (pithub/zamith)
=== 5.8.2 / 2015-10-26
* 1 bug fix:
* Fixed using parallelize_me! and capture_io (or any locking io). (arlt/tenderlove)
=== 5.8.1 / 2015-09-23
* 1 minor enhancement:
* Refactor assert_raises to be cleaner and to pass SystemExit and SignalException. (bhenderson)
=== 5.8.0 / 2015-08-06
* 2 minor enhancements:
* Add optional delegation mechanism to extend object with a mock. (zamith)
* Return early if there are no filtered methods. (jeremyevans)
* 1 bug fix:
* Don't extend io with pride if io is not a tty. (toy)
=== 5.7.0 / 2015-05-27
* 1 major enhancement:
* assert_raises now matches subclasses of the expected exception types. (jeremyevans)
* 3 minor enhancements:
* Added :block type for minitest/spec's #infect_an_assertion. (jeremyevans)
* Inline verification error messages in minitest/mock for GC performance. (zamith)
* assert_raises defaults to RuntimeError if not specified. (jeremyevans)
* 4 bug fixes:
* Added 'class' to minitest/mock's overridden_methods list. (zamith)
* Added file/line to infect_an_assertion's class_eval call. (jeremyevans)
* Cleared UnexpectedError's mesg w/ generic string.
* Fixed non-proc-oriented expectations when used on proc target. (jeremyevans)
=== 5.6.1 / 2015-04-27
* 2 bug fixes:
* Added Minitest.clock_time and switched all Time.now to it. (tenderlove)
* Moved Minitest::Expectations#_ into Minitest::Spec::DSL.
=== 5.6.0 / 2015-04-13
* 4 major enhancements:
* Added Minitest::Expectation value monad.
* Added Minitest::Expectations#_ that returns an Expectation. Aliased to value.
* All expectations are added to Minitest::Expectation.
* At some point, the methods on Object will be deprecated and then removed.
* 4 minor enhancements:
* Added a note about bundle exec pitfall in ruby 2.2+. (searls)
* Lazily start the parallel executor. (tenderlove)
* Make mocks more debugger-friendly (edward)
* Print out the current test run on interrupt. (riffraff)
* 3 bug fixes:
* Fix failing test under Windows. (kimhmadsen)
* Record mocked calls before they happen so mocks can raise exceptions easier (tho I'm not a fan). (corecode)
* Tried to clarify mocks vs stubs terminology better. (kkirsche)
=== 5.5.1 / 2015-01-09
* 1 bug fix:
* Fixed doco problems. (zzak)
=== 5.5.0 / 2014-12-12 // mri 2.2.0 (as a real gem)
* 1 minor enhancement:
* Allow seed to be given via ENV for rake test loader sadness: eg rake SEED=42.
=== 5.4.3 / 2014-11-11
* 2 bug fixes:
* Clarified requirements for ruby are now 1.8.7 or better.
* Force encode error output in case mal-encoded exception is raised. (jasonrclark)
=== 5.4.2 / 2014-09-26
* 2 minor enhancements:
* Extract teardown method list.
* Thanks to minitest-gcstats got a 5-10% speedup via reduced GC!
=== 5.4.1 / 2014-08-28
* 1 bug fix:
* Fixed specs hidden by nesting/ordering bug (blowmage/apotonick)
=== 5.4.0 / 2014-07-07
* 2 minor enhancements:
* Kernel#describe extended to splat additional_desc.
* Spec#spec_type extended to take a splat of additional items, passed to matcher procs.
* 1 bug fix:
* minitest/spec should require minitest/test, not minitest/unit. (doudou)
=== 5.3.5 / 2014-06-17
* 1 minor enhancement:
* Spit and polish (mostly spit).
=== 5.3.4 / 2014-05-15
* 1 minor enhancement:
* Test classes are randomized before running. (judofyr)
=== 5.3.3 / 2014-04-14
* 1 bug fix:
* Fixed using expectations w/ DSL in Test class w/o describe. (blowmage+others)
=== 5.3.2 / 2014-04-02
* 1 bug fix:
* Fixed doco on Assertions.assertions. (xaviershay)
=== 5.3.1 / 2014-03-14
* 1 minor enhancement:
* Modified verbage on bad 'let' names to be more helpful. (Archytaus)
* 1 bug fix:
* Fixed 2 cases still using MiniTest. (mikesea)
=== 5.3.0 / 2014-02-25
* 1 minor enhancement:
* Mocked methods can take a block to verify state. Seattle.rb 12 bday present from ernie! Thanks!!
=== 5.2.3 / 2014-02-10
* 1 bug fix:
* Fixed Spec#let check to allow overriding of other lets. (mvz)
=== 5.2.2 / 2014-01-22
* 1 minor enhancement:
* Spec#let raises ArgumentError if you override _any_ instance method (except subject). (rynr)
* 1 bug fix:
* Fixed up benchmark spec doco and added a test to demonstrate. (bhenderson)
=== 5.2.1 / 2014-01-07
* 1 bug fix:
* Properly deal with horrible mix of runtime load errors + other at_exit handlers. (dougo/chqr)
=== 5.2.0 / 2013-12-13
* 1 minor enhancement:
* Change expectations to allow calling most on procs (but not calling the proc). (bhenderson+others)
=== 5.1.0 / 2013-12-05
* 1 minor enhancement:
* Use a Queue for scheduling parallel tests. (tenderlove)
* 1 bug fix:
* Fixed misspelling in doco. (amatsuda)
=== 5.0.8 / 2013-09-20
* 1 bug fix:
* Fixed siginfo handler by rearranging reporters and fixing to_s. (tenderlove)
=== 5.0.7 / 2013-09-05
* 2 minor enhancements:
* Added clarification about the use of thread local variables in expectations. (jemc)
* Added extra message about skipped tests, if any. Disable globally with $MT_NO_SKIP_MSG.
* 2 bug fixes:
* Only require minitest, not minitest/autorun in pride_plugin. (judofyr)
* Require rubygems in load_plugins in case you're not using minitest/autorun.
=== 5.0.6 / 2013-06-28
* 3 minor enhancements:
* Allow stub to pass args to blocks. (swindsor)
* Improved warning message about minitest/autorun to address 1.9's minitest/autorun.
* Made minitest/test require minitest as needed. For lib writers. (erikh)
* 1 bug fix:
* Fixed missing require in minitest/test. (erikh)
=== 4.7.5 / 2013-06-21 // mri 2.1.1
* 2 bug fixes:
* Fix Spec#describe_stack to be thread local.
* Fix multithreaded test failures by defining Time local to mock test namespace
=== 5.0.5 / 2013-06-20
* 6 bug fixes:
* DOH! Fixed the rest of the new casing on Minitest. (splattael)
* Fixed typo on minitest/mock rdoc. (mrgilman/guiceolin)
* Make Spec::DSL.describe_stack thread local to avoid failing on my own tests.
* Make a fake Time.now local to the tests so they won't interfere with real reporter timings.
* Make everything mockable by wrapping all 'special' methods in a smarter wrapper. (bestie)
* Raise ArgumentError if let name starts with 'test'. (johnmaxwell)
=== 5.0.4 / 2013-06-07
* 5 minor enhancements:
* Added AbstractReporter, defining required Reporter API to quack properly.
* Added doco for writing reporters.
* Refactored Reporter into ProgressReporter and SummaryReporter. (idea: phiggins, code:me+scotch)
* Refactored SummaryReporter pushing up to StatisticsReporter. (phiggins)
* Removed Reporter#run_and_report... cleaner, but doesn't "fit" in the API.
=== 5.0.3 / 2013-05-29
* 4 minor enhancements:
* Added Runnable.with_info_handler and Runnable.on_signal.
* Moved io.sync restore to Reporter#run_and_report.
* Refactored inner loop of Reporter#report to #to_s. Callable for status updates.
* Restored MT4's mid-run report (^t). (tenderlove).
=== 5.0.2 / 2013-05-20
* 3 bug fixes:
* Gem.find_files is smarter than I remember... cause I wrote it that way. *sigh* I'm getting old.
* Pride wasn't doing puts through its #io. (tmiller/tenderlove)
* Replaced Runnable#dup and Test#dup with marshal_dump/load. Too many problems cropping up on untested rails code. (tenderlove/rubys)
=== 5.0.1 / 2013-05-14
* 2 bug fixes:
* Documented Assertions' need for @assertions to be defined by the includer.
* Only load one plugin version per name. Tries for latest.
=== 5.0.0 / 2013-05-10
Oh god... here we go...
Minitest 5:
* 4 deaths in the family:
* MiniTest.runner is dead. No more manager objects.
* MiniTest::Unit#record is dead. Use a Reporter instance instead.
* MiniTest::Unit._run_* is dead. Runnable things are responsible for their own runs.
* MiniTest::Unit.output is dead. No more centralized IO.
* 12 major (oft incompatible) changes:
* Renamed MiniTest to Minitest. Your pinkies will thank me. (aliased to MiniTest)
* Removed MiniTest::Unit entirely. No more manager objects.
* Added Minitest::Runnable. Everything minitest can run subclasses this.
* Renamed MiniTest::Unit::TestCase to Minitest::Test (subclassing Runnable).
* Added Minitest::Benchmark.
* Your benchmarks need to move to their own subclass.
* Benchmarks using the spec DSL have to have "Bench" somewhere in their describe.
* MiniTest::Unit.after_tests moved to Minitest.after_tests
* MiniTest::Unit.autorun is now Minitest.autorun. Just require minitest/autorun pls.
* Removed ParallelEach#grep since it isn't used anywhere.
* Renamed Runnable#__name__ to Runnable#name (but uses @NAME internally).
* Runnable#run needs to return self. Allows for swapping of results as needed.
* 8 minor moves:
* Moved Assertions module to minitest/assertions.rb
* Moved Expectations module to minitest/expectations.rb
* Moved Test to minitest/test.rb
* Moved everything else in minitest/unit.rb to minitest.rb
* minitest/unit.rb is now just a small (user-test only) compatibility layer.
* Moved most of minitest/pride into minitest/pride_plugin.
* minitest/pride now just activates pride.
* Moved ParallelEach under Minitest.
* 9 additions:
* Added a plugin system that can extend command-line options.
* Added Minitest.extensions.
* Added Minitest.reporter (only available during startup).
* Added Minitest.run(args). This is the very top of any Minitest run.
* Added Minitest::Reporter. Everything minitest can report goes through here.
* Minitest.reporter is a composite so you can add your own.
* Added Minitest::CompositeReporter. Much easier to extend with your own reporters.
* Added UnexpectedError, an Assertion subclass, to wrap up errors.
* Minitest::Test#run is now freakin' beautiful. 47 -> 17 loc
* 11 other:
* Removed Object.infect_with_assertions (it was already dead code).
* Runnables are responsible for knowing their result_code (eg "." or "F").
* Minitest.autorun now returns boolean, not exit code.
* Added FAQ entry for extending via modules. (phiggins)
* Implement Runnable#dup to cleanse state back to test results. Helps with serialization. pair:tenderlove
* Moved ParallelEach under Minitest.
* Runnable#run needs to return self. Allows for swapping of results as needed.
* Minitest.init_plugins passes down options.
* Minitest.load_plugins only loads once.
* Fixed minitest/pride to work with rake test loader again. (tmiller)
* Added count/size to ParallelEach to fix use w/in stdlib's test/unit. :( (btaitelb)
* 5 voodoo:
* Removed mutex from minitest.rb (phiggins)
* Removed mutex from test.rb (phiggins)
* Removed Minitest::Reporter.synchronize (phiggins)
* Removed Minitest::Test.synchronize (phiggins)
* Upon loading minitest/parallel_each, record, capture_io and capture_subprocess_io are doped with synchronization code. (phiggins)
=== 4.7.4 / 2013-05-01
This is probably the last release of the 4.x series. It will be merged
to ruby and will be put into maintenance mode there.
I'm not set in stone on this, but at this point further development of
minitest (5+) will be gem-only. It is just too hard to work w/in
ruby-core w/ test-unit compatibility holding minitest development
back.
* 2 minor enhancements:
* Added count/size to ParallelEach to fix use w/in stdlib's test/unit. :( (btaitelb)
* Allow disabling of info_signal handler in runner. (erikh)
=== 4.7.3 / 2013-04-20
* 1 bug fix:
* Reverted stubbing of module methods change. Stub the user, not the impl. (ab9/tyabe)
=== 4.7.2 / 2013-04-18
* 2 bug fixes:
* Fixed inconsistency in refute_in_delta/epsilon. I double negatived my logic. (nettsundere)
* Fixed stubbing of module methods (eg Kernel#sleep). (steveklabnik)
=== 4.7.1 / 2013-04-09
* 1 minor enhancement:
* Added FAQ section to README
* 1 bug fix:
* Fixed bug where guard runs tests bypassing minitest/autorun and an ivar isn't set right. (darrencauthon)
=== 4.7.0 / 2013-03-18
* 1 major enhancement:
* Refactored MiniTest::Spec into MiniTest::Spec::DSL.
* 1 bug fix:
* Removed $DEBUG handler that detected when test/unit and minitest were both loaded. (tenderlove)
=== 4.6.2 / 2013-02-27
* 1 minor enhancement:
* Change error output to match Class#method, making it easier to use -n filter.
=== 4.6.1 / 2013-02-14
* 1 bug fix:
* Fixed an option processing bug caused by test/unit's irresponsibly convoluted code. (floehopper)
=== 4.6.0 / 2013-02-07
* 3 major enhancements:
* Removed ::reset_setup_teardown_hooks
* Removed the long deprecated assert_block
* Removed the long deprecated lifecycle hooks: add_(setup|teardown)_hook
* 1 minor enhancement:
* Allow filtering tests by suite name as well as test name. (lazyatom)
* 2 bug fixes:
* Made hex handling (eg object_ids) in mu_pp_for_diff more specific. (maxim)
* nodoc top-level module. (zzak)
=== 4.5.0 / 2013-01-22
* 1 major enhancement:
* Rearranged minitest/unit.rb so NO parallelization code is loaded/used until you opt-in.
* 4 minor enhancements:
* Added TestCase#skipped? for teardown guards
* Added maglev? guard
* Document that record can be sent twice if teardown fails or errors (randycoulman)
* Errors in teardown are now recorded. (randycoulman)
* 3 bug fixes:
* Added hacks and skips to get clean test runs on maglev
* Modified float tests for maglev float output differences. Not sure this is right. Not sure I care.
* Test for existance of diff.exe instead of assuming they have devkit. (blowmage/Cumbayah)
=== 4.4.0 / 2013-01-07
* 3 minor enhancements:
* Added fit_logarithic and assert_performance_logarithmic. (ktheory)
* Merge processed options so others can mess with defaults. (tenderlove)
* TestCase#message can now take another proc to defer custom message cost. (ordinaryzelig/bhenderson)
* 1 bug fix:
* TestCase#passed? now true if test is skipped. (qanhd)
=== 4.3.3 / 2012-12-06
* 1 bug fix:
* Updated information about stubbing. (daviddavis)
=== 4.3.2 / 2012-11-27 // mri 2.0.0
* 1 minor enhancement:
* Improved assert_equals error message to point you at #== of member objects. (kcurtin)
=== 4.3.1 / 2012-11-23
* 1 bug fix:
* Moved test_children to serial testcase to prevent random failures.
=== 4.3.0 / 2012-11-17
* 4 minor enhancements:
* Allow #autorun to run even if loaded with other test libs that call exit. (sunaku)
* Do not include Expectations in Object if $MT_NO_EXPECTATIONS is set (experimental?)
* Gave some much needed love to assert_raises.
* Mock#expect can take a block to custom-validate args. (gmoothart)
=== 4.2.0 / 2012-11-02
* 4 major enhancements:
* Added minitest/hell - run all your tests through the ringer!
* Added support for :parallel test_order to run test cases in parallel.
* Removed last_error and refactored runner code to be threadsafe.
* _run_suites now runs suites in parallel if they opt-in.
* 4 minor enhancements:
* Added TestCase#synchronize
* Added TestCase.make_my_diffs_pretty!
* Added TestCase.parallelize_me!
* Lock on capture_io for thread safety (tenderlove)
=== 4.1.0 / 2012-10-05
* 2 minor enhancements:
* Added skip example to readme. (dissolved)
* Extracted backtrace filter to object. (tenderlove)
* 1 bug fix:
* OMG I'm so dumb. Fixed access to deprecated hook class methods. I hate ruby modules. (route)
=== 4.0.0 / 2012-09-28
* 1 major enhancement:
* The names of a privately-used undocumented constants are Super Important™.
* 1 minor enhancement:
* Support stubbing methods that would be handled via method_missing. (jhsu)
* 3 bug fixes:
* Add include_private param to MiniTest::Mock#respond_to? (rf-)
* Fixed use of minitest/pride with --help. (zw963)
* Made 'No visible difference.' message more clear. (ckrailo)
=== 3.5.0 / 2012-09-21
* 1 minor enhancement:
* Added #capture_subprocess_io. (route)
=== 3.4.0 / 2012-09-05
* 2 minor enhancements:
* assert_output can now take regexps for expected values. (suggested by stomar)
* Clarified that ruby 1.9/2.0's phony gems cause serious confusion for rubygems.
=== 3.3.0 / 2012-07-26
* 1 major enhancement:
* Deprecated add_(setup|teardown)_hook in favor of (before|after)_(setup|teardown) [2013-01-01]
* 4 minor enhancements:
* Refactored deprecated hook system into a module.
* Refactored lifecycle hooks into a module.
* Removed after_setup/before_teardown + run_X_hooks from Spec.
* Spec#before/after now do a simple define_method and call super. DUR.
* 2 bug fixes:
* Fixed #passed? when used against a test that called flunk. (floehopper)
* Fixed rdoc bug preventing doco for some expectations. (stomar).
=== 3.2.0 / 2012-06-26
* 1 minor enhancement:
* Stubs now yield self. (peterhellberg)
* 1 bug fix:
* Fixed verbose test that only fails when run in verbose mode. mmmm irony.
=== 3.1.0 / 2012-06-13
* 2 minor enhancements:
* Removed LONG deprecated Unit.out accessor
* Removed generated method name munging from minitest/spec. (ordinaryzelig/tenderlove)
=== 3.0.1 / 2012-05-24
* 1 bug fix:
* I'm a dumbass and refactored into Mock#call. Renamed to #__call so you can mock #call. (mschuerig)
=== 3.0.0 / 2012-05-08
* 3 major enhancements:
* Added Object#stub (in minitest/mock.rb).
* Mock#expect mocks are used in the order they're given.
* Mock#verify now strictly compares against expect calls.
* 3 minor enhancements:
* Added caller to deprecation message.
* Mock error messages are much prettier.
* Removed String check for RHS of assert/refute_match. This lets #to_str work properly.
* 1 bug fix:
* Support drive letter on Windows. Patch provided from MRI by Usaku NAKAMURA. (ayumin)
=== 2.12.1 / 2012-04-10
* 1 minor enhancement:
* Added ruby releases to History.txt to make it easier to see what you're missing
* 1 bug fix:
* Rolled my own deprecate msg to allow MT to work with rubygems < 1.7
=== 2.12.0 / 2012-04-03
* 4 minor enhancements:
* ::it returns test method name (wojtekmach)
* Added #record method to runner so runner subclasses can cleanly gather data.
* Added Minitest alias for MiniTest because even I forget.
* Deprecated assert_block!! Yay!!!
* 1 bug fix:
* Fixed warning in i_suck_and_my_tests_are_order_dependent! (phiggins)
=== 2.11.4 / 2012-03-20
* 2 minor enhancements:
* Updated known extensions
* You got your unicode in my tests! You got your tests in my unicode! (fl00r)
* 1 bug fix:
* Fixed MiniTest::Mock example in the readme. (conradwt)
=== 2.11.3 / 2012-02-29
* 2 bug fixes:
* Clarified that assert_raises returns the exception for further testing
* Fixed assert_in_epsilon when both args are negative. (tamc)
=== 2.11.2 / 2012-02-14
* 1 minor enhancement:
* Display failures/errors on SIGINFO. (tenderlove)
* 1 bug fix:
* Fixed MiniTest::Unit.after_tests for Ruby 1.9.3. (ysbaddaden)
=== 2.11.1 / 2012-02-01
* 3 bug fixes:
* Improved description for --name argument. (drd)
* Ensure Mock#expect's expected args is an Array. (mperham)
* Ensure Mock#verify verifies multiple expects of the same method. (chastell)
=== 2.11.0 / 2012-01-25
* 2 minor enhancements:
* Added before / after hooks for setup and teardown. (tenderlove)
* Pushed run_setup_hooks down to Spec. (tenderlove)
=== 2.10.1 / 2012-01-17
* 1 bug fix:
* Fixed stupid 1.9 path handling grumble grumble. (graaff)
=== 2.10.0 / 2011-12-20
* 3 minor enhancements:
* Added specs for must/wont be_empty/respond_to/be_kind_of and others.
* Added tests for assert/refute predicate.
* Split minitest/excludes.rb out to its own gem.
* 1 bug fix:
* Fixed must_be_empty and wont_be_empty argument handling. (mrsimo)
=== 2.9.1 / 2011-12-13
* 4 minor enhancements:
* Added a ton of tests on spec error message output.
* Cleaned up consistency of msg handling on unary expectations.
* Improved error messages on assert/refute_in_delta.
* infect_an_assertion no longer checks arity and better handles args.
* 1 bug fix:
* Fixed error message on specs when 2+ args and custom message provided. (chastell)
=== 2.9.0 / 2011-12-07
* 4 minor enhancements:
* Added TestCase.exclude and load_excludes for programmatic filtering of tests.
* Added guard methods so you can cleanly skip based on platform/impl
* Holy crap! 100% doco! `rdoc -C` ftw
* Switch assert_output to test stderr before stdout to possibly improve debugging
=== 2.8.1 / 2011-11-17
* 1 bug fix:
* Ugh. 1.9's test/unit violates my internals. Added const_missing.
=== 2.8.0 / 2011-11-08
* 2 minor enhancements:
* Add a method so that code can be run around a particular test case (tenderlove)
* Turn off backtrace filtering if we're running inside a ruby checkout. (drbrain)
* 2 bug fixes:
* Fixed 2 typos and 2 doc glitches. (splattael)
* Remove unused block arguments to avoid creating Proc objects. (k-tsj)
=== 2.7.0 / 2011-10-25
* 2 minor enhancements:
* Include failed values in the expected arg output in MockExpectationError. (nono)
* Make minitest/pride work with other 256 color capable terms. (sunaku)
* 2 bug fixes:
* Clarified the documentation of minitest/benchmark (eregon)
* Fixed using expectations in regular unit tests. (sunaku)
=== 2.6.2 / 2011-10-19
* 1 minor enhancement:
* Added link to vim bundle. (sunaku)
* 2 bug fixes:
* Force gem activation in hoe minitest plugin
* Support RUBY_VERSION='2.0.0' (nagachika)
=== 2.6.1 / 2011-09-27
* 2 bug fixes:
* Alias Spec.name from Spec.to_s so it works when @name is nil (nathany)
* Fixed assert and refute_operator where second object has a bad == method.
=== 2.6.0 / 2011-09-13
* 2 minor enhancements:
* Added specify alias for it and made desc optional.
* Spec#must_be and #wont_be can be used with predicates (metaskills)
* 1 bug fix:
* Fixed Mock.respond_to?(var) to work with strings. (holli)
=== 2.5.1 / 2011-08-27 // ruby 1.9.3: p0, p125, p34579
* 2 minor enhancements:
* Added gem activation for minitest in minitest/autoload to help out 1.9 users
* Extended Spec.register_spec_type to allow for procs instead of just regexps.
=== 2.5.0 / 2011-08-18
* 4 minor enhancements:
* Added 2 more arguments against rspec: let & subject in 9 loc! (emmanuel/luis)
* Added TestCase.i_suck_and_my_tests_are_order_dependent!
* Extended describe to take an optional method name (2 line change!). (emmanuel)
* Refactored and extended minitest/pride to do full 256 color support. (lolcat)
* 1 bug fix:
* Doc fixes. (chastell)
=== 2.4.0 / 2011-08-09
* 4 minor enhancements:
* Added simple examples for all expectations.
* Improved Mock error output when args mismatch.
* Moved all expectations from Object to MiniTest::Expectations.
* infect_with_assertions has been removed due to excessive clever
* 4 bug fixes:
* Fix Assertions#mu_pp to deal with immutable encoded strings. (ferrous26)
* Fix minitest/pride for MacRuby (ferrous26)
* Made error output less fancy so it is more readable
* Mock shouldn't undef === and inspect. (dgraham)
=== 2.3.1 / 2011-06-22
* 1 bug fix:
* Fixed minitest hoe plugin to be a spermy dep and not depend on itself.
=== 2.3.0 / 2011-06-15
* 5 minor enhancements:
* Add setup and teardown hooks to MiniTest::TestCase. (phiggins)
* Added nicer error messages for MiniTest::Mock. (phiggins)
* Allow for less specific expected arguments in Mock. (bhenderson/phiggins)
* Made MiniTest::Mock a blank slate. (phiggins)
* Refactored minitest/spec to use the hooks instead of define_inheritable_method. (phiggins)
* 2 bug fixes:
* Fixed TestCase's inherited hook. (dchelimsky/phiggins/jamis, the 'good' neighbor)
* MiniTest::Assertions#refute_empty should use mu_pp in the default message. (whatthejeff)
=== 2.2.2 / 2011-06-01
* 2 bug fixes:
* Got rid of the trailing period in message for assert_equal. (tenderlove)
* Windows needs more flushing. (Akio Tajima)
=== 2.2.1 / 2011-05-31
* 1 bug fix:
* My _ONE_ non-rubygems-using minitest user goes to Seattle.rb!
=== 2.2.0 / 2011-05-29
* 6 minor enhancements:
* assert_equal (and must_equal) now tries to diff output where it makes sense.
* Added Assertions#diff(exp, act) to be used by assert_equal.
* Added Assertions#mu_pp_for_diff
* Added Assertions.diff and diff=
* Moved minitest hoe-plugin from hoe-seattlerb. (erikh)
* Skipped tests only output details in verbose mode. (tenderlove+zenspider=xoxo)
=== 2.1.0 / 2011-04-11
* 5 minor enhancements:
* Added MiniTest::Spec.register_spec_type(matcher, klass) and spec_type(desc)
* Added ability for specs to share code via subclassing of Spec. (metaskills)
* Clarified (or tried to) bench_performance_linear's use of threshold.
* MiniTest::Unit.runner=(runner) provides an easy way of creating custom test runners for specialized needs. (justinweiss)
* Reverse order of inheritance in teardowns of specs. (deepfryed)
* 3 bug fixes:
* FINALLY fixed problems of inheriting specs in describe/it/describe scenario. (MGPalmer)
* Fixed a new warning in 1.9.3.
* Fixed assert_block's message handling. (nobu)
=== 2.0.2 / 2010-12-24
* 1 minor enhancement:
* Completed doco on minitest/benchmark for specs.
* 1 bug fix:
* Benchmarks in specs that didn't call bench_range would die. (zzak).
=== 2.0.1 / 2010-12-15
* 4 minor enhancements:
* Do not filter backtrace if $DEBUG
* Exit autorun via nested at_exit handler, in case other libs call exit
* Make options accesor lazy.
* Split printing of test name and its time. (nurse)
* 1 bug fix:
* Fix bug when ^T is hit before runner start
=== 2.0.0 / 2010-11-11
* 3 major enhancements:
* Added minitest/benchmark! Assert your performance! YAY!
* Refactored runner to allow for more extensibility. See minitest/benchmark.
* This makes the runner backwards incompatible in some ways!
* 9 minor enhancements:
* Added MiniTest::Unit.after_tests { ... }
* Improved output by adding test rates and a more sortable verbose format
* Improved readme based on feedback from others
* Added io method to TestCase. If used, it'll supplant '.EF' output.
* Refactored IO in MiniTest::Unit.
* Refactored _run_anything to _run_suite to make it easier to wrap (ngauthier)
* Spec class names are now the unmunged descriptions (btakita)
* YAY for not having redundant rdoc/readmes!
* Help output is now generated from the flags you passed straight up.
* 4 bug fixes:
* Fixed scoping issue on minitest/mock (srbaker/prosperity)
* Fixed some of the assertion default messages
* Fixes autorun when on windows with ruby install on different drive (larsch)
* Fixed rdoc output bug in spec.rb
=== 1.7.2 / 2010-09-23
* 3 bug fixes:
* Fixed doco for expectations and Spec.
* Fixed test_capture_io on 1.9.3+ (sora_h)
* assert_raises now lets MiniTest::Skip through. (shyouhei)
=== 1.7.1 / 2010-09-01
* 1 bug fix:
* 1.9.2 fixes for spec tests
=== 1.7.0 / 2010-07-15
* 5 minor enhancements:
* Added assert_output (mapped to must_output).
* Added assert_silent (mapped to must_be_silent).
* Added examples to readme (Mike Dalessio)
* Added options output at the top of the run, for fatal run debugging (tenderlove)
* Spec's describe method returns created class
=== 1.6.0 / 2010-03-27 // ruby 1.9.2-p290
* 10 minor enhancements:
* Added --seed argument so you can reproduce a random order for debugging.
* Added documentation for assertions
* Added more rdoc and tons of :nodoc:
* Added output to give you all the options you need to reproduce that run.
* Added proper argument parsing to minitest.
* Added unique serial # to spec names so order can be preserved (needs tests). (phrogz)
* Empty 'it' fails with default msg. (phrogz)
* Remove previous method on expect to remove 1.9 warnings
* Spec#it is now order-proof wrt subclasses/nested describes.
* assert_same error message now reports in decimal, eg: oid=123. (mattkent)
* 2 bug fixes:
* Fixed message on refute_same to be consistent with assert_same.
* Fixed method randomization to be stable for testing.
=== 1.5.0 / 2010-01-06
* 4 minor enhancements:
* Added ability to specify what assertions should have their args flipped.
* Don't flip arguments on *include and *respond_to assertions.
* Refactored Module.infect_an_assertion from Module.infect_with_assertions.
* before/after :all now bitches and acts like :each
* 3 bug fixes:
* Nested describes now map to nested test classes to avoid namespace collision.
* Using undef_method instead of remove_method to clean out inherited specs.
* assert_raises was ignoring passed in message.
=== 1.4.2 / 2009-06-25
* 1 bug fix:
* Fixed info handler for systems that don't have siginfo.
=== 1.4.1 / 2009-06-23
* 1 major enhancement:
* Handle ^C and other fatal exceptions by failing
* 1 minor enhancement:
* Added something to catch mixed use of test/unit and minitest if $DEBUG
* 1 bug fix:
* Added SIGINFO handler for finding slow tests without verbose
=== 1.4.0 / 2009-06-18
* 5 minor enhancement:
* Added clarification doco.
* Added specs and mocks to autorun.
* Changed spec test class creation to be non-destructive.
* Updated rakefile for new hoe capabilities.
* describes are nestable (via subclass). before/after/def inherits, specs don't.
* 3 bug fixes:
* Fixed location on must/wont.
* Switched to __name__ to avoid common ivar name.
* Fixed indentation in test file (1.9).
=== 1.3.1 / 2009-01-20 // ruby 1.9.1-p431
* 1 minor enhancement:
* Added miniunit/autorun.rb as replacement for test/unit.rb's autorun.
* 16 bug fixes:
* 1.9 test fixes.
* Bug fixes from nobu and akira for really odd scenarios. They run ruby funny.
* Fixed (assert|refute)_match's argument order.
* Fixed LocalJumpError in autorun if exception thrown before at_exit.
* Fixed assert_in_delta (should be >=, not >).
* Fixed assert_raises to match Modules.
* Fixed capture_io to not dup IOs.
* Fixed indentation of capture_io for ruby 1.9 warning.
* Fixed location to deal better with custom assertions and load paths. (Yuki)
* Fixed order of (must|wont)_include in MiniTest::Spec.
* Fixed skip's backtrace.
* Got arg order wrong in *_match in tests, message wrong as a result.
* Made describe private. For some reason I thought that an attribute of Kernel.
* Removed disable_autorun method, added autorun.rb instead.
* assert_match escapes if passed string for pattern.
* instance_of? is different from ===, use instance_of.
=== 1.3.0 / 2008-10-09
* 2 major enhancements:
* renamed to minitest and pulled out test/unit compatibility.
* mini/test.rb is now minitest/unit.rb, everything else maps directly.
* 12 minor enhancements:
* assert_match now checks that act can call =~ and converts exp to a
regexp only if needed.
* Added assert_send... seems useless to me tho.
* message now forces to string... ruby-core likes to pass classes and arrays :(
* Added -v handling and switched to @verbose from $DEBUG.
* Verbose output now includes test class name and adds a sortable running time!
* Switched message generation into procs for message deferment.
* Added skip and renamed fail to flunk.
* Improved output failure messages for assert_instance_of, assert_kind_of
* Improved output for assert_respond_to, assert_same.
* at_exit now exits false instead of errors+failures.
* Made the tests happier and more readable imhfo.
* Switched index(s) == 0 to rindex(s, 0) on nobu's suggestion. Faster.
* 5 bug fixes:
* 1.9: Added encoding normalization in mu_pp.
* 1.9: Fixed backtrace filtering (BTs are expanded now)
* Added back exception_details to assert_raises. DOH.
* Fixed shadowed variable in mock.rb
* Fixed stupid muscle memory message bug in assert_send.
=== 1.2.1 / 2008-06-10
* 7 minor enhancements:
* Added deprecations everywhere in test/unit.
* Added test_order to TestCase. :random on mini, :sorted on test/unit (for now).
* Big cleanup in test/unit for rails. Thanks Jeremy Kemper!
* Minor readability cleanup.
* Pushed setup/run/teardown down to testcase allowing specialized testcases.
* Removed pp. Tests run 2x faster. :/
* Renamed deprecation methods and moved to test/unit/deprecate.rb.
=== 1.2.0 / 2008-06-09
* 2 major enhancements:
* Added Mini::Spec.
* Added Mini::Mock. Thanks Steven Baker!!
* 23 minor enhancements:
* Added bin/use_miniunit to make it easy to test out miniunit.
* Added -n filtering, thanks to Phil Hagelberg!
* Added args argument to #run, takes ARGV from at_exit.
* Added test name output if $DEBUG.
* Added a refute (was deny) for every assert.
* Added capture_io and a bunch of nice assertions from zentest.
* Added deprecation mechanism for assert_no/not methods to test/unit/assertions.
* Added pp output when available.
* Added tests for all assertions. Pretty much maxed out coverage.
* Added tests to verify consistency and good naming.
* Aliased and deprecated all ugly assertions.
* Cleaned out test/unit. Moved autorun there.
* Code cleanup to make extensions easier. Thanks Chad!
* Got spec args reversed in all but a couple assertions. Much more readable.
* Improved error messages across the board. Adds your message to the default.
* Moved into Mini namespace, renamed to Mini::Test and Mini::Spec.
* Pulled the assertions into their own module...
* Removed as much code as I could while still maintaining full functionality.
* Moved filter_backtrace into MiniTest.
* Removed MiniTest::Unit::run. Unnecessary.
* Removed location_of_failure. Unnecessary.
* Rewrote test/unit's filter_backtrace. Flog from 37.0 to 18.1
* Removed assert_send. Google says it is never used.
* Renamed MiniTest::Unit.autotest to #run.
* Renamed deny to refute.
* Rewrote some ugly/confusing default assertion messages.
* assert_in_delta now defaults to 0.001 precision. Makes specs prettier.
* 9 bug fixes:
* Fixed assert_raises to raise outside of the inner-begin/rescue.
* Fixed for ruby 1.9 and rubinius.
* No longer exits 0 if exception in code PRE-test run causes early exit.
* Removed implementors method list from mini/test.rb - too stale.
* assert_nothing_raised takes a class as an arg. wtf? STUPID
* ".EF" output is now unbuffered.
* Bunch of changes to get working with rails... UGH.
* Added stupid hacks to deal with rails not requiring their dependencies.
* Now bitch loudly if someone defines one of my classes instead of requiring.
* Fixed infect method to work better on 1.9.
* Fixed all shadowed variable warnings in 1.9.
=== 1.1.0 / 2007-11-08
* 4 major enhancements:
* Finished writing all missing assertions.
* Output matches original test/unit.
* Documented every method needed by language implementor.
* Fully switched over to self-testing setup.
* 2 minor enhancements:
* Added deny (assert ! test), our favorite extension to test/unit.
* Added .autotest and fairly complete unit tests. (thanks Chad for help here)
=== 1.0.0 / 2006-10-30
* 1 major enhancement
* Birthday!
minitest-5.10.3/data.tar.gz.sig 0000444 0000041 0000041 00000000400 13135676423 016307 0 ustar www-data www-data V%sgeQK͝PuI}I6I}Kjڳt8a"wTFig"(HڞӰVص^Z=j='-i*-u/d1z/XE8a z֍?!$:uwR"bC3LjTk!Y6n^/wo@J
/-*^~)ZY',5vCM 1BNy8 minitest-5.10.3/README.rdoc 0000444 0000041 0000041 00000065465 13135676423 015322 0 ustar www-data www-data = minitest/{test,spec,mock,benchmark}
home :: https://github.com/seattlerb/minitest
bugs :: https://github.com/seattlerb/minitest/issues
rdoc :: http://docs.seattlerb.org/minitest
vim :: https://github.com/sunaku/vim-ruby-minitest
emacs:: https://github.com/arthurnn/minitest-emacs
== DESCRIPTION:
minitest provides a complete suite of testing facilities supporting
TDD, BDD, mocking, and benchmarking.
"I had a class with Jim Weirich on testing last week and we were
allowed to choose our testing frameworks. Kirk Haines and I were
paired up and we cracked open the code for a few test
frameworks...
I MUST say that minitest is *very* readable / understandable
compared to the 'other two' options we looked at. Nicely done and
thank you for helping us keep our mental sanity."
-- Wayne E. Seguin
minitest/test is a small and incredibly fast unit testing framework.
It provides a rich set of assertions to make your tests clean and
readable.
minitest/spec is a functionally complete spec engine. It hooks onto
minitest/test and seamlessly bridges test assertions over to spec
expectations.
minitest/benchmark is an awesome way to assert the performance of your
algorithms in a repeatable manner. Now you can assert that your newb
co-worker doesn't replace your linear algorithm with an exponential
one!
minitest/mock by Steven Baker, is a beautifully tiny mock (and stub)
object framework.
minitest/pride shows pride in testing and adds coloring to your test
output. I guess it is an example of how to write IO pipes too. :P
minitest/test is meant to have a clean implementation for language
implementors that need a minimal set of methods to bootstrap a working
test suite. For example, there is no magic involved for test-case
discovery.
"Again, I can't praise enough the idea of a testing/specing
framework that I can actually read in full in one sitting!"
-- Piotr Szotkowski
Comparing to rspec:
rspec is a testing DSL. minitest is ruby.
-- Adam Hawkins, "Bow Before MiniTest"
minitest doesn't reinvent anything that ruby already provides, like:
classes, modules, inheritance, methods. This means you only have to
learn ruby to use minitest and all of your regular OO practices like
extract-method refactorings still apply.
== FEATURES/PROBLEMS:
* minitest/autorun - the easy and explicit way to run all your tests.
* minitest/test - a very fast, simple, and clean test system.
* minitest/spec - a very fast, simple, and clean spec system.
* minitest/mock - a simple and clean mock/stub system.
* minitest/benchmark - an awesome way to assert your algorithm's performance.
* minitest/pride - show your pride in testing!
* Incredibly small and fast runner, but no bells and whistles.
* Written by squishy human beings. Software can never be perfect. We will all eventually die.
== RATIONALE:
See design_rationale.rb to see how specs and tests work in minitest.
== SYNOPSIS:
Given that you'd like to test the following class:
class Meme
def i_can_has_cheezburger?
"OHAI!"
end
def will_it_blend?
"YES!"
end
end
=== Unit tests
Define your tests as methods beginning with +test_+.
require "minitest/autorun"
class TestMeme < Minitest::Test
def setup
@meme = Meme.new
end
def test_that_kitty_can_eat
assert_equal "OHAI!", @meme.i_can_has_cheezburger?
end
def test_that_it_will_not_blend
refute_match /^no/i, @meme.will_it_blend?
end
def test_that_will_be_skipped
skip "test this later"
end
end
=== Specs
require "minitest/autorun"
describe Meme do
before do
@meme = Meme.new
end
describe "when asked about cheeseburgers" do
it "must respond positively" do
@meme.i_can_has_cheezburger?.must_equal "OHAI!"
end
end
describe "when asked about blending possibilities" do
it "won't say no" do
@meme.will_it_blend?.wont_match /^no/i
end
end
end
For matchers support check out:
* https://github.com/wojtekmach/minitest-matchers
* https://github.com/rmm5t/minitest-matchers_vaccine
=== Benchmarks
Add benchmarks to your tests.
# optionally run benchmarks, good for CI-only work!
require "minitest/benchmark" if ENV["BENCH"]
class TestMeme < Minitest::Benchmark
# Override self.bench_range or default range is [1, 10, 100, 1_000, 10_000]
def bench_my_algorithm
assert_performance_linear 0.9999 do |n| # n is a range value
@obj.my_algorithm(n)
end
end
end
Or add them to your specs. If you make benchmarks optional, you'll
need to wrap your benchmarks in a conditional since the methods won't
be defined. In minitest 5, the describe name needs to match
/Bench(mark)?$/.
describe "Meme Benchmark" do
if ENV["BENCH"] then
bench_performance_linear "my_algorithm", 0.9999 do |n|
100.times do
@obj.my_algorithm(n)
end
end
end
end
outputs something like:
# Running benchmarks:
TestBlah 100 1000 10000
bench_my_algorithm 0.006167 0.079279 0.786993
bench_other_algorithm 0.061679 0.792797 7.869932
Output is tab-delimited to make it easy to paste into a spreadsheet.
=== Mocks
Mocks and stubs defined using terminology by Fowler & Meszaros at
http://www.martinfowler.com/bliki/TestDouble.html:
"Mocks are pre-programmed with expectations which form a specification
of the calls they are expected to receive. They can throw an exception
if they receive a call they don't expect and are checked during
verification to ensure they got all the calls they were expecting."
class MemeAsker
def initialize(meme)
@meme = meme
end
def ask(question)
method = question.tr(" ", "_") + "?"
@meme.__send__(method)
end
end
require "minitest/autorun"
describe MemeAsker, :ask do
describe "when passed an unpunctuated question" do
it "should invoke the appropriate predicate method on the meme" do
@meme = Minitest::Mock.new
@meme_asker = MemeAsker.new @meme
@meme.expect :will_it_blend?, :return_value
@meme_asker.ask "will it blend"
@meme.verify
end
end
end
**Multi-threading and Mocks**
Minitest mocks do not support multi-threading if it works, fine, if it doesn't
you can use regular ruby patterns and facilities like local variables. Here's
an example of asserting that code inside a thread is run:
def test_called_inside_thread
called = false
pr = Proc.new { called = true }
thread = Thread.new(&pr)
thread.join
assert called, "proc not called"
end
=== Stubs
Mocks and stubs are defined using terminology by Fowler & Meszaros at
http://www.martinfowler.com/bliki/TestDouble.html:
"Stubs provide canned answers to calls made during the test".
Minitest's stub method overrides a single method for the duration of
the block.
def test_stale_eh
obj_under_test = Something.new
refute obj_under_test.stale?
Time.stub :now, Time.at(0) do # stub goes away once the block is done
assert obj_under_test.stale?
end
end
A note on stubbing: In order to stub a method, the method must
actually exist prior to stubbing. Use a singleton method to create a
new non-existing method:
def obj_under_test.fake_method
...
end
=== Running Your Tests
Ideally, you'll use a rake task to run your tests, either piecemeal or
all at once. Both rake and rails ship with rake tasks for running your
tests. BUT! You don't have to:
% ruby -Ilib:test test/minitest/test_minitest_test.rb
Run options: --seed 37685
# Running:
...................................................................... (etc)
Finished in 0.107130s, 1446.8403 runs/s, 2959.0217 assertions/s.
155 runs, 317 assertions, 0 failures, 0 errors, 0 skips
There are runtime options available, both from minitest itself, and also
provided via plugins. To see them, simply run with +--help+:
% ruby -Ilib:test test/minitest/test_minitest_test.rb --help
minitest options:
-h, --help Display this help.
-s, --seed SEED Sets random seed. Also via env. Eg: SEED=n rake
-v, --verbose Verbose. Show progress processing files.
-n, --name PATTERN Filter run on /regexp/ or string.
-e, --exclude PATTERN Exclude /regexp/ or string from run.
Known extensions: pride, autotest
-p, --pride Pride. Show your testing pride!
-a, --autotest Connect to autotest server.
== Writing Extensions
To define a plugin, add a file named minitest/XXX_plugin.rb to your
project/gem. That file must be discoverable via ruby's LOAD_PATH (via
rubygems or otherwise). Minitest will find and require that file using
Gem.find_files. It will then try to call +plugin_XXX_init+ during
startup. The option processor will also try to call +plugin_XXX_options+
passing the OptionParser instance and the current options hash. This
lets you register your own command-line options. Here's a totally
bogus example:
# minitest/bogus_plugin.rb:
module Minitest
def self.plugin_bogus_options(opts, options)
opts.on "--myci", "Report results to my CI" do
options[:myci] = true
options[:myci_addr] = get_myci_addr
options[:myci_port] = get_myci_port
end
end
def self.plugin_bogus_init(options)
self.reporter << MyCI.new(options) if options[:myci]
end
end
=== Adding custom reporters
Minitest uses composite reporter to output test results using multiple
reporter instances. You can add new reporters to the composite during
the init_plugins phase. As we saw in +plugin_bogus_init+ above, you
simply add your reporter instance to the composite via <<.
+AbstractReporter+ defines the API for reporters. You may subclass it
and override any method you want to achieve your desired behavior.
start :: Called when the run has started.
record :: Called for each result, passed or otherwise.
report :: Called at the end of the run.
passed? :: Called to see if you detected any problems.
Using our example above, here is how we might implement MyCI:
# minitest/bogus_plugin.rb
module Minitest
class MyCI < AbstractReporter
attr_accessor :results, :addr, :port
def initialize options
self.results = []
self.addr = options[:myci_addr]
self.port = options[:myci_port]
end
def record result
self.results << result
end
def report
CI.connect(addr, port).send_results self.results
end
end
# code from above...
end
== FAQ
=== How to test SimpleDelegates?
The following implementation and test:
class Worker < SimpleDelegator
def work
end
end
describe Worker do
before do
@worker = Worker.new(Object.new)
end
it "must respond to work" do
@worker.must_respond_to :work
end
end
outputs a failure:
1) Failure:
Worker#test_0001_must respond to work [bug11.rb:16]:
Expected # (Object) to respond to #work.
Worker is a SimpleDelegate which in 1.9+ is a subclass of BasicObject.
Expectations are put on Object (one level down) so the Worker
(SimpleDelegate) hits +method_missing+ and delegates down to the
+Object.new+ instance. That object doesn't respond to work so the test
fails.
You can bypass SimpleDelegate#method_missing by extending the worker
with Minitest::Expectations. You can either do that in your setup at
the instance level, like:
before do
@worker = Worker.new(Object.new)
@worker.extend Minitest::Expectations
end
or you can extend the Worker class (within the test file!), like:
class Worker
include ::Minitest::Expectations
end
=== How to share code across test classes?
Use a module. That's exactly what they're for:
module UsefulStuff
def useful_method
# ...
end
end
describe Blah do
include UsefulStuff
def test_whatever
# useful_method available here
end
end
Remember, +describe+ simply creates test classes. It's just ruby at
the end of the day and all your normal Good Ruby Rules (tm) apply. If
you want to extend your test using setup/teardown via a module, just
make sure you ALWAYS call super. before/after automatically call super
for you, so make sure you don't do it twice.
=== Why am I seeing uninitialized constant MiniTest::Test (NameError)?
Are you running the test with Bundler (e.g. via bundle exec )? If so,
in order to require minitest, you must first add the gem 'minitest'
to your Gemfile and run +bundle+. Once it's installed, you should be
able to require minitest and run your tests.
== Prominent Projects using Minitest:
* arel
* journey
* mime-types
* nokogiri
* rails (active_support et al)
* rake
* rdoc
* ...and of course, everything from seattle.rb...
== Developing Minitest:
=== Minitest's own tests require UTF-8 external encoding.
This is a common problem in Windows, where the default external Encoding is
often CP850, but can affect any platform.
Minitest can run test suites using any Encoding, but to run Minitest's
own tests you must have a default external Encoding of UTF-8.
If your encoding is wrong, you'll see errors like:
--- expected
+++ actual
@@ -1,2 +1,3 @@
# encoding: UTF-8
-"Expected /\\w+/ to not match \"blah blah blah\"."
+"Expected /\\w+/ to not match # encoding: UTF-8
+\"blah blah blah\"."
To check your current encoding, run:
ruby -e 'puts Encoding.default_external'
If your output is something other than UTF-8, you can set the RUBYOPTS
env variable to a value of '-Eutf-8'. Something like:
RUBYOPT='-Eutf-8' ruby -e 'puts Encoding.default_external'
Check your OS/shell documentation for the precise syntax (the above
will not work on a basic Windows CMD prompt, look for the SET command).
Once you've got it successfully outputing UTF-8, use the same setting
when running rake in Minitest.
=== Minitest's own tests require GNU (or similar) diff.
This is also a problem primarily affecting Windows developers. PowerShell
has a command called diff, but it is not suitable for use with Minitest.
If you see failures like either of these, you are probably missing diff tool:
4) Failure:
TestMinitestUnitTestCase#test_assert_equal_different_long [D:/ruby/seattlerb/minitest/test/minitest/test_minitest_test.rb:936]:
Expected: "--- expected\n+++ actual\n@@ -1 +1 @@\n-\"hahahahahahahahahahahahahahahahahahahaha\"\n+\"blahblahblahblahblahblahblahblahblahblah\"\n"
Actual: "Expected: \"hahahahahahahahahahahahahahahahahahahaha\"\n Actual: \"blahblahblahblahblahblahblahblahblahblah\""
5) Failure:
TestMinitestUnitTestCase#test_assert_equal_different_collection_hash_hex_invisible [D:/ruby/seattlerb/minitest/test/minitest/test_minitest_test.rb:845]:
Expected: "No visible difference in the Hash#inspect output.\nYou should look at the implementation of #== on Hash or its members.\n
{1=>#}"
Actual: "Expected: {1=>#}\n Actual: {1=>#}"
If you use Cygwin or MSYS2 or similar there are packages that include a
GNU diff for Widnows. If you don't, you can download GNU diffutils from
http://gnuwin32.sourceforge.net/packages/diffutils.htm
(make sure to add it to your PATH).
You can make sure it's installed and path is configured properly with:
diff.exe -v
There are multiple lines of output, the first should be something like:
diff (GNU diffutils) 2.8.1
If you are using PowerShell make sure you run diff.exe, not just diff,
which will invoke the PowerShell built in function.
== Known Extensions:
capybara_minitest_spec :: Bridge between Capybara RSpec matchers and
Minitest::Spec expectations (e.g.
page.must_have_content("Title")).
color_pound_spec_reporter :: Test names print Ruby Object types in color with
your Minitest Spec style tests.
minispec-metadata :: Metadata for describe/it blocks & CLI tag filter.
E.g. it "requires JS driver", js: true do &
ruby test.rb --tag js runs tests tagged :js.
minispec-rails :: Minimal support to use Spec style in Rails 5+.
minitest-around :: Around block for minitest. An alternative to
setup/teardown dance.
minitest-assert_errors :: Adds Minitest assertions to test for errors raised
or not raised by Minitest itself.
minitest-autotest :: autotest is a continuous testing facility meant to
be used during development.
minitest-bacon :: minitest-bacon extends minitest with bacon-like
functionality.
minitest-bang :: Adds support for RSpec-style let! to immediately
invoke let statements before each test.
minitest-bisect :: Helps you isolate and debug random test failures.
minitest-blink1_reporter :: Display test results with a Blink1.
minitest-capistrano :: Assertions and expectations for testing
Capistrano recipes.
minitest-capybara :: Capybara matchers support for minitest unit and
spec.
minitest-chef-handler :: Run Minitest suites as Chef report handlers
minitest-ci :: CI reporter plugin for Minitest.
minitest-context :: Defines contexts for code reuse in Minitest
specs that share common expectations.
minitest-debugger :: Wraps assert so failed assertions drop into
the ruby debugger.
minitest-display :: Patches Minitest to allow for an easily
configurable output.
minitest-documentation :: Minimal documentation format inspired by rspec's.
minitest-doc_reporter :: Detailed output inspired by rspec's documentation
format.
minitest-emoji :: Print out emoji for your test passes, fails, and
skips.
minitest-english :: Semantically symmetric aliases for assertions and
expectations.
minitest-excludes :: Clean API for excluding certain tests you
don't want to run under certain conditions.
minitest-fail-fast :: Reimplements RSpec's "fail fast" feature
minitest-filecontent :: Support unit tests with expectation results in files.
Differing results will be stored again in files.
minitest-filesystem :: Adds assertion and expectation to help testing
filesystem contents.
minitest-firemock :: Makes your Minitest mocks more resilient.
minitest-focus :: Focus on one test at a time.
minitest-gcstats :: A minitest plugin that adds a report of the top
tests by number of objects allocated.
minitest-great_expectations :: Generally useful additions to minitest's
assertions and expectations.
minitest-growl :: Test notifier for minitest via growl.
minitest-happy :: GLOBALLY ACTIVATE MINITEST PRIDE! RAWR!
minitest-have_tag :: Adds Minitest assertions to test for the existence of
HTML tags, including contents, within a provided string.
minitest-hooks :: Around and before_all/after_all/around_all hooks
minitest-hyper :: Pretty, single-page HTML reports for your Minitest runs
minitest-implicit-subject :: Implicit declaration of the test subject.
minitest-instrument :: Instrument ActiveSupport::Notifications when
test method is executed.
minitest-instrument-db :: Store information about speed of test execution
provided by minitest-instrument in database.
minitest-junit :: JUnit-style XML reporter for minitest.
minitest-libnotify :: Test notifier for minitest via libnotify.
minitest-line :: Run test at line number.
minitest-logger :: Define assert_log and enable minitest to test log messages.
Supports Logger and Log4r::Logger.
minitest-macruby :: Provides extensions to minitest for macruby UI
testing.
minitest-matchers :: Adds support for RSpec-style matchers to
minitest.
minitest-matchers_vaccine :: Adds assertions that adhere to the matcher spec,
but without any expectation infections.
minitest-metadata :: Annotate tests with metadata (key-value).
minitest-mongoid :: Mongoid assertion matchers for Minitest.
minitest-must_not :: Provides must_not as an alias for wont in
Minitest.
minitest-optional_retry :: Automatically retry failed test to help with flakiness.
minitest-osx :: Reporter for the Mac OS X notification center.
minitest-parallel_fork :: Fork-based parallelization
minitest-parallel-db :: Run tests in parallel with a single database.
minitest-power_assert :: PowerAssert for Minitest.
minitest-predicates :: Adds support for .predicate? methods.
minitest-profile :: List the 10 slowest tests in your suite.
minitest-rails :: Minitest integration for Rails 3.x.
minitest-rails-capybara :: Capybara integration for Minitest::Rails.
minitest-reporters :: Create customizable Minitest output formats.
minitest-rg :: Colored red/green output for Minitest.
minitest-rspec_mocks :: Use RSpec Mocks with Minitest.
minitest-server :: minitest-server provides a client/server setup
with your minitest process, allowing your test
run to send its results directly to a handler.
minitest-sequel :: Minitest assertions to speed-up development and
testing of Ruby Sequel database setups.
minitest-shared_description :: Support for shared specs and shared spec
subclasses
minitest-should_syntax :: RSpec-style x.should == y assertions for
Minitest.
minitest-shouldify :: Adding all manner of shoulds to Minitest (bad
idea)
minitest-snail :: Print a list of tests that take too long
minitest-spec-context :: Provides rspec-ish context method to
Minitest::Spec.
minitest-spec-expect :: Expect syntax for Minitest::Spec (e.g.
expect(sequences).to_include :celery_man).
minitest-spec-magic :: Minitest::Spec extensions for Rails and beyond.
minitest-spec-rails :: Drop in Minitest::Spec superclass for
ActiveSupport::TestCase.
minitest-sprint :: Runs (Get it? It's fast!) your tests and makes
it easier to rerun individual failures.
minitest-stately :: Find leaking state between tests
minitest-stub_any_instance :: Stub any instance of a method on the given class
for the duration of a block.
minitest-stub-const :: Stub constants for the duration of a block.
minitest-tags :: Add tags for minitest.
minitest-unordered :: Adds a new assertion to minitest for checking the
contents of a collection, ignoring element order.
minitest-vcr :: Automatic cassette managment with Minitest::Spec
and VCR.
minitest_owrapper :: Get tests results as a TestResult object.
minitest_should :: Shoulda style syntax for minitest test::unit.
minitest_tu_shim :: Bridges between test/unit and minitest.
mongoid-minitest :: Minitest matchers for Mongoid.
pry-rescue :: A pry plugin w/ minitest support. See
pry-rescue/minitest.rb.
rspec2minitest :: Easily translate any RSpec matchers to Minitest
assertions and expectations.
== Unknown Extensions:
Authors... Please send me a pull request with a description of your minitest extension.
* assay-minitest
* detroit-minitest
* em-minitest-spec
* flexmock-minitest
* guard-minitest
* guard-minitest-decisiv
* minitest-activemodel
* minitest-ar-assertions
* minitest-capybara-unit
* minitest-colorer
* minitest-deluxe
* minitest-extra-assertions
* minitest-rails-shoulda
* minitest-spec
* minitest-spec-should
* minitest-sugar
* spork-minitest
== Minitest related goods
* minitest/pride fabric: http://www.spoonflower.com/fabric/3928730-again-by-katie_allen
== REQUIREMENTS:
* Ruby 1.8.7+. No magic is involved. I hope.
* NOTE: 1.8 and 1.9 will be dropped in minitest 6+.
== INSTALL:
sudo gem install minitest
On 1.9, you already have it. To get newer candy you can still install
the gem, and then requiring "minitest/autorun" should automatically
pull it in. If not, you'll need to do it yourself:
gem "minitest" # ensures you"re using the gem, and not the built-in MT
require "minitest/autorun"
# ... usual testing stuffs ...
DO NOTE: There is a serious problem with the way that ruby 1.9/2.0
packages their own gems. They install a gem specification file, but
don't install the gem contents in the gem path. This messes up
Gem.find_files and many other things (gem which, gem contents, etc).
Just install minitest as a gem for real and you'll be happier.
== LICENSE:
(The MIT License)
Copyright (c) Ryan Davis, seattle.rb
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
minitest-5.10.3/lib/ 0000755 0000041 0000041 00000000000 13135676423 014244 5 ustar www-data www-data minitest-5.10.3/lib/hoe/ 0000755 0000041 0000041 00000000000 13135676423 015017 5 ustar www-data www-data minitest-5.10.3/lib/hoe/minitest.rb 0000444 0000041 0000041 00000001243 13135676423 017176 0 ustar www-data www-data # :stopdoc:
class Hoe
end
module Hoe::Minitest
def minitest?
self.name == "minitest"
end
def initialize_minitest
unless minitest? then
dir = "../../minitest/dev/lib"
Hoe.add_include_dirs dir if File.directory? dir
end
gem "minitest"
require "minitest"
version = Minitest::VERSION.split(/\./).first(2).join(".")
dependency "minitest", "~> #{version}", :development unless
minitest? or ENV["MT_NO_ISOLATE"]
end
def define_minitest_tasks
self.testlib = :minitest
# make sure we use the gemmed minitest on 1.9
self.test_prelude = 'gem "minitest"' unless
minitest? or ENV["MT_NO_ISOLATE"]
end
end
minitest-5.10.3/lib/minitest.rb 0000444 0000041 0000041 00000046574 13135676423 016443 0 ustar www-data www-data require "optparse"
require "thread"
require "mutex_m"
require "minitest/parallel"
require "stringio"
##
# :include: README.rdoc
module Minitest
VERSION = "5.10.3" # :nodoc:
ENCS = "".respond_to? :encoding # :nodoc:
@@installed_at_exit ||= false
@@after_run = []
@extensions = []
mc = (class << self; self; end)
##
# Parallel test executor
mc.send :attr_accessor, :parallel_executor
self.parallel_executor = Parallel::Executor.new((ENV["N"] || 2).to_i)
##
# Filter object for backtraces.
mc.send :attr_accessor, :backtrace_filter
##
# Reporter object to be used for all runs.
#
# NOTE: This accessor is only available during setup, not during runs.
mc.send :attr_accessor, :reporter
##
# Names of known extension plugins.
mc.send :attr_accessor, :extensions
##
# The signal to use for dumping information to STDERR. Defaults to "INFO".
mc.send :attr_accessor, :info_signal
self.info_signal = "INFO"
##
# Registers Minitest to run at process exit
def self.autorun
at_exit {
next if $! and not ($!.kind_of? SystemExit and $!.success?)
exit_code = nil
at_exit {
@@after_run.reverse_each(&:call)
exit exit_code || false
}
exit_code = Minitest.run ARGV
} unless @@installed_at_exit
@@installed_at_exit = true
end
##
# A simple hook allowing you to run a block of code after everything
# is done running. Eg:
#
# Minitest.after_run { p $debugging_info }
def self.after_run &block
@@after_run << block
end
def self.init_plugins options # :nodoc:
self.extensions.each do |name|
msg = "plugin_#{name}_init"
send msg, options if self.respond_to? msg
end
end
def self.load_plugins # :nodoc:
return unless self.extensions.empty?
seen = {}
require "rubygems" unless defined? Gem
Gem.find_files("minitest/*_plugin.rb").each do |plugin_path|
name = File.basename plugin_path, "_plugin.rb"
next if seen[name]
seen[name] = true
require plugin_path
self.extensions << name
end
end
##
# This is the top-level run method. Everything starts from here. It
# tells each Runnable sub-class to run, and each of those are
# responsible for doing whatever they do.
#
# The overall structure of a run looks like this:
#
# Minitest.autorun
# Minitest.run(args)
# Minitest.__run(reporter, options)
# Runnable.runnables.each
# runnable.run(reporter, options)
# self.runnable_methods.each
# self.run_one_method(self, runnable_method, reporter)
# Minitest.run_one_method(klass, runnable_method)
# klass.new(runnable_method).run
def self.run args = []
self.load_plugins
options = process_args args
reporter = CompositeReporter.new
reporter << SummaryReporter.new(options[:io], options)
reporter << ProgressReporter.new(options[:io], options)
self.reporter = reporter # this makes it available to plugins
self.init_plugins options
self.reporter = nil # runnables shouldn't depend on the reporter, ever
self.parallel_executor.start if parallel_executor.respond_to?(:start)
reporter.start
begin
__run reporter, options
rescue Interrupt
warn "Interrupted. Exiting..."
end
self.parallel_executor.shutdown
reporter.report
reporter.passed?
end
##
# Internal run method. Responsible for telling all Runnable
# sub-classes to run.
def self.__run reporter, options
suites = Runnable.runnables.reject { |s| s.runnable_methods.empty? }.shuffle
parallel, serial = suites.partition { |s| s.test_order == :parallel }
# If we run the parallel tests before the serial tests, the parallel tests
# could run in parallel with the serial tests. This would be bad because
# the serial tests won't lock around Reporter#record. Run the serial tests
# first, so that after they complete, the parallel tests will lock when
# recording results.
serial.map { |suite| suite.run reporter, options } +
parallel.map { |suite| suite.run reporter, options }
end
def self.process_args args = [] # :nodoc:
options = {
:io => $stdout,
}
orig_args = args.dup
OptionParser.new do |opts|
opts.banner = "minitest options:"
opts.version = Minitest::VERSION
opts.on "-h", "--help", "Display this help." do
puts opts
exit
end
desc = "Sets random seed. Also via env. Eg: SEED=n rake"
opts.on "-s", "--seed SEED", Integer, desc do |m|
options[:seed] = m.to_i
end
opts.on "-v", "--verbose", "Verbose. Show progress processing files." do
options[:verbose] = true
end
opts.on "-n", "--name PATTERN", "Filter run on /regexp/ or string." do |a|
options[:filter] = a
end
opts.on "-e", "--exclude PATTERN", "Exclude /regexp/ or string from run." do |a|
options[:exclude] = a
end
unless extensions.empty?
opts.separator ""
opts.separator "Known extensions: #{extensions.join(", ")}"
extensions.each do |meth|
msg = "plugin_#{meth}_options"
send msg, opts, options if self.respond_to?(msg)
end
end
begin
opts.parse! args
rescue OptionParser::InvalidOption => e
puts
puts e
puts
puts opts
exit 1
end
orig_args -= args
end
unless options[:seed] then
srand
options[:seed] = (ENV["SEED"] || srand).to_i % 0xFFFF
orig_args << "--seed" << options[:seed].to_s
end
srand options[:seed]
options[:args] = orig_args.map { |s|
s =~ /[\s|&<>$()]/ ? s.inspect : s
}.join " "
options
end
def self.filter_backtrace bt # :nodoc:
backtrace_filter.filter bt
end
##
# Represents anything "runnable", like Test, Spec, Benchmark, or
# whatever you can dream up.
#
# Subclasses of this are automatically registered and available in
# Runnable.runnables.
class Runnable
##
# Number of assertions executed in this run.
attr_accessor :assertions
##
# An assertion raised during the run, if any.
attr_accessor :failures
##
# Name of the run.
def name
@NAME
end
##
# Set the name of the run.
def name= o
@NAME = o
end
def self.inherited klass # :nodoc:
self.runnables << klass
super
end
##
# Returns all instance methods matching the pattern +re+.
def self.methods_matching re
public_instance_methods(true).grep(re).map(&:to_s)
end
def self.reset # :nodoc:
@@runnables = []
end
reset
##
# Responsible for running all runnable methods in a given class,
# each in its own instance. Each instance is passed to the
# reporter to record.
def self.run reporter, options = {}
filter = options[:filter] || "/./"
filter = Regexp.new $1 if filter =~ %r%/(.*)/%
filtered_methods = self.runnable_methods.find_all { |m|
filter === m || filter === "#{self}##{m}"
}
exclude = options[:exclude]
exclude = Regexp.new $1 if exclude =~ %r%/(.*)/%
filtered_methods.delete_if { |m|
exclude === m || exclude === "#{self}##{m}"
}
return if filtered_methods.empty?
with_info_handler reporter do
filtered_methods.each do |method_name|
run_one_method self, method_name, reporter
end
end
end
##
# Runs a single method and has the reporter record the result.
# This was considered internal API but is factored out of run so
# that subclasses can specialize the running of an individual
# test. See Minitest::ParallelTest::ClassMethods for an example.
def self.run_one_method klass, method_name, reporter
reporter.prerecord klass, method_name
reporter.record Minitest.run_one_method(klass, method_name)
end
def self.with_info_handler reporter, &block # :nodoc:
handler = lambda do
unless reporter.passed? then
warn "Current results:"
warn ""
warn reporter.reporters.first
warn ""
end
end
on_signal ::Minitest.info_signal, handler, &block
end
SIGNALS = Signal.list # :nodoc:
def self.on_signal name, action # :nodoc:
supported = SIGNALS[name]
old_trap = trap name do
old_trap.call if old_trap.respond_to? :call
action.call
end if supported
yield
ensure
trap name, old_trap if supported
end
##
# Each subclass of Runnable is responsible for overriding this
# method to return all runnable methods. See #methods_matching.
def self.runnable_methods
raise NotImplementedError, "subclass responsibility"
end
##
# Returns all subclasses of Runnable.
def self.runnables
@@runnables
end
def marshal_dump # :nodoc:
[self.name, self.failures, self.assertions]
end
def marshal_load ary # :nodoc:
self.name, self.failures, self.assertions = ary
end
def failure # :nodoc:
self.failures.first
end
def initialize name # :nodoc:
self.name = name
self.failures = []
self.assertions = 0
end
##
# Runs a single method. Needs to return self.
def run
raise NotImplementedError, "subclass responsibility"
end
##
# Did this run pass?
#
# Note: skipped runs are not considered passing, but they don't
# cause the process to exit non-zero.
def passed?
raise NotImplementedError, "subclass responsibility"
end
##
# Returns a single character string to print based on the result
# of the run. Eg ".", "F", or "E".
def result_code
raise NotImplementedError, "subclass responsibility"
end
##
# Was this run skipped? See #passed? for more information.
def skipped?
raise NotImplementedError, "subclass responsibility"
end
end
##
# Defines the API for Reporters. Subclass this and override whatever
# you want. Go nuts.
class AbstractReporter
include Mutex_m
##
# Starts reporting on the run.
def start
end
##
# About to start running a test. This allows a reporter to show
# that it is starting or that we are in the middle of a test run.
def prerecord klass, name
end
##
# Record a result and output the Runnable#result_code. Stores the
# result of the run if the run did not pass.
def record result
end
##
# Outputs the summary of the run.
def report
end
##
# Did this run pass?
def passed?
true
end
end
class Reporter < AbstractReporter # :nodoc:
##
# The IO used to report.
attr_accessor :io
##
# Command-line options for this run.
attr_accessor :options
def initialize io = $stdout, options = {} # :nodoc:
super()
self.io = io
self.options = options
end
end
##
# A very simple reporter that prints the "dots" during the run.
#
# This is added to the top-level CompositeReporter at the start of
# the run. If you want to change the output of minitest via a
# plugin, pull this out of the composite and replace it with your
# own.
class ProgressReporter < Reporter
def prerecord klass, name #:nodoc:
if options[:verbose] then
io.print "%s#%s = " % [klass, name]
io.flush
end
end
def record result # :nodoc:
io.print "%.2f s = " % [result.time] if options[:verbose]
io.print result.result_code
io.puts if options[:verbose]
end
end
##
# A reporter that gathers statistics about a test run. Does not do
# any IO because meant to be used as a parent class for a reporter
# that does.
#
# If you want to create an entirely different type of output (eg,
# CI, HTML, etc), this is the place to start.
class StatisticsReporter < Reporter
# :stopdoc:
attr_accessor :assertions
attr_accessor :count
attr_accessor :results
attr_accessor :start_time
attr_accessor :total_time
attr_accessor :failures
attr_accessor :errors
attr_accessor :skips
# :startdoc:
def initialize io = $stdout, options = {} # :nodoc:
super
self.assertions = 0
self.count = 0
self.results = []
self.start_time = nil
self.total_time = nil
self.failures = nil
self.errors = nil
self.skips = nil
end
def passed? # :nodoc:
results.all?(&:skipped?)
end
def start # :nodoc:
self.start_time = Minitest.clock_time
end
def record result # :nodoc:
self.count += 1
self.assertions += result.assertions
results << result if not result.passed? or result.skipped?
end
def report # :nodoc:
aggregate = results.group_by { |r| r.failure.class }
aggregate.default = [] # dumb. group_by should provide this
self.total_time = Minitest.clock_time - start_time
self.failures = aggregate[Assertion].size
self.errors = aggregate[UnexpectedError].size
self.skips = aggregate[Skip].size
end
end
##
# A reporter that prints the header, summary, and failure details at
# the end of the run.
#
# This is added to the top-level CompositeReporter at the start of
# the run. If you want to change the output of minitest via a
# plugin, pull this out of the composite and replace it with your
# own.
class SummaryReporter < StatisticsReporter
# :stopdoc:
attr_accessor :sync
attr_accessor :old_sync
# :startdoc:
def start # :nodoc:
super
io.puts "Run options: #{options[:args]}"
io.puts
io.puts "# Running:"
io.puts
self.sync = io.respond_to? :"sync=" # stupid emacs
self.old_sync, io.sync = io.sync, true if self.sync
end
def report # :nodoc:
super
io.sync = self.old_sync
io.puts unless options[:verbose] # finish the dots
io.puts
io.puts statistics
aggregated_results io
io.puts summary
end
def statistics # :nodoc:
"Finished in %.6fs, %.4f runs/s, %.4f assertions/s." %
[total_time, count / total_time, assertions / total_time]
end
def aggregated_results io # :nodoc:
filtered_results = results.dup
filtered_results.reject!(&:skipped?) unless options[:verbose]
filtered_results.each_with_index { |result, i|
io.puts "\n%3d) %s" % [i+1, result]
}
io.puts
io
end
def to_s # :nodoc:
aggregated_results(StringIO.new(binary_string)).string
end
def summary # :nodoc:
extra = ""
extra = "\n\nYou have skipped tests. Run with --verbose for details." if
results.any?(&:skipped?) unless options[:verbose] or ENV["MT_NO_SKIP_MSG"]
"%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
[count, assertions, failures, errors, skips, extra]
end
private
if '<3'.respond_to? :b
def binary_string; ''.b; end
else
def binary_string; ''.force_encoding(Encoding::ASCII_8BIT); end
end
end
##
# Dispatch to multiple reporters as one.
class CompositeReporter < AbstractReporter
##
# The list of reporters to dispatch to.
attr_accessor :reporters
def initialize *reporters # :nodoc:
super()
self.reporters = reporters
end
def io # :nodoc:
reporters.first.io
end
##
# Add another reporter to the mix.
def << reporter
self.reporters << reporter
end
def passed? # :nodoc:
self.reporters.all?(&:passed?)
end
def start # :nodoc:
self.reporters.each(&:start)
end
def prerecord klass, name # :nodoc:
self.reporters.each do |reporter|
# TODO: remove conditional for minitest 6
reporter.prerecord klass, name if reporter.respond_to? :prerecord
end
end
def record result # :nodoc:
self.reporters.each do |reporter|
reporter.record result
end
end
def report # :nodoc:
self.reporters.each(&:report)
end
end
##
# Represents run failures.
class Assertion < Exception
def error # :nodoc:
self
end
##
# Where was this run before an assertion was raised?
def location
last_before_assertion = ""
self.backtrace.reverse_each do |s|
break if s =~ /in .(assert|refute|flunk|pass|fail|raise|must|wont)/
last_before_assertion = s
end
last_before_assertion.sub(/:in .*$/, "")
end
def result_code # :nodoc:
result_label[0, 1]
end
def result_label # :nodoc:
"Failure"
end
end
##
# Assertion raised when skipping a run.
class Skip < Assertion
def result_label # :nodoc:
"Skipped"
end
end
##
# Assertion wrapping an unexpected error that was raised during a run.
class UnexpectedError < Assertion
attr_accessor :exception # :nodoc:
def initialize exception # :nodoc:
super "Unexpected exception"
self.exception = exception
end
def backtrace # :nodoc:
self.exception.backtrace
end
def error # :nodoc:
self.exception
end
def message # :nodoc:
bt = Minitest.filter_backtrace(self.backtrace).join "\n "
"#{self.exception.class}: #{self.exception.message}\n #{bt}"
end
def result_label # :nodoc:
"Error"
end
end
##
# Provides a simple set of guards that you can use in your tests
# to skip execution if it is not applicable. These methods are
# mixed into Test as both instance and class methods so you
# can use them inside or outside of the test methods.
#
# def test_something_for_mri
# skip "bug 1234" if jruby?
# # ...
# end
#
# if windows? then
# # ... lots of test methods ...
# end
module Guard
##
# Is this running on jruby?
def jruby? platform = RUBY_PLATFORM
"java" == platform
end
##
# Is this running on maglev?
def maglev? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
"maglev" == platform
end
##
# Is this running on mri?
def mri? platform = RUBY_DESCRIPTION
/^ruby/ =~ platform
end
##
# Is this running on rubinius?
def rubinius? platform = defined?(RUBY_ENGINE) && RUBY_ENGINE
"rbx" == platform
end
##
# Is this running on windows?
def windows? platform = RUBY_PLATFORM
/mswin|mingw/ =~ platform
end
end
##
# The standard backtrace filter for minitest.
#
# See Minitest.backtrace_filter=.
class BacktraceFilter
MT_RE = %r%lib/minitest% #:nodoc:
##
# Filter +bt+ to something useful. Returns the whole thing if $DEBUG.
def filter bt
return ["No backtrace"] unless bt
return bt.dup if $DEBUG
new_bt = bt.take_while { |line| line !~ MT_RE }
new_bt = bt.select { |line| line !~ MT_RE } if new_bt.empty?
new_bt = bt.dup if new_bt.empty?
new_bt
end
end
self.backtrace_filter = BacktraceFilter.new
def self.run_one_method klass, method_name # :nodoc:
result = klass.new(method_name).run
raise "#{klass}#run _must_ return self" unless klass === result
result
end
# :stopdoc:
if defined? Process::CLOCK_MONOTONIC # :nodoc:
def self.clock_time
Process.clock_gettime Process::CLOCK_MONOTONIC
end
else
def self.clock_time
Time.now
end
end
# :startdoc:
end
require "minitest/test"
minitest-5.10.3/lib/minitest/ 0000755 0000041 0000041 00000000000 13135676423 016100 5 ustar www-data www-data minitest-5.10.3/lib/minitest/unit.rb 0000444 0000041 0000041 00000002354 13135676423 017406 0 ustar www-data www-data # :stopdoc:
unless defined?(Minitest) then
# all of this crap is just to avoid circular requires and is only
# needed if a user requires "minitest/unit" directly instead of
# "minitest/autorun", so we also warn
from = caller.reject { |s| s =~ /rubygems/ }.join("\n ")
warn "Warning: you should require 'minitest/autorun' instead."
warn %(Warning: or add 'gem "minitest"' before 'require "minitest/autorun"')
warn "From:\n #{from}"
module Minitest; end
MiniTest = Minitest # prevents minitest.rb from requiring back to us
require "minitest"
end
MiniTest = Minitest unless defined?(MiniTest)
module Minitest
class Unit
VERSION = Minitest::VERSION
class TestCase < Minitest::Test
def self.inherited klass # :nodoc:
from = caller.first
warn "MiniTest::Unit::TestCase is now Minitest::Test. From #{from}"
super
end
end
def self.autorun # :nodoc:
from = caller.first
warn "MiniTest::Unit.autorun is now Minitest.autorun. From #{from}"
Minitest.autorun
end
def self.after_tests &b # :nodoc:
from = caller.first
warn "MiniTest::Unit.after_tests is now Minitest.after_run. From #{from}"
Minitest.after_run(&b)
end
end
end
# :startdoc:
minitest-5.10.3/lib/minitest/pride.rb 0000444 0000041 0000041 00000000103 13135676423 017520 0 ustar www-data www-data require "minitest"
Minitest.load_plugins
Minitest::PrideIO.pride!
minitest-5.10.3/lib/minitest/expectations.rb 0000444 0000041 0000041 00000013403 13135676423 021132 0 ustar www-data www-data ##
# It's where you hide your "assertions".
#
# Please note, because of the way that expectations are implemented,
# all expectations (eg must_equal) are dependent upon a thread local
# variable +:current_spec+. If your specs rely on mixing threads into
# the specs themselves, you're better off using assertions or the new
# _(value) wrapper. For example:
#
# it "should still work in threads" do
# my_threaded_thingy do
# (1+1).must_equal 2 # bad
# assert_equal 2, 1+1 # good
# _(1 + 1).must_equal 2 # good
# value(1 + 1).must_equal 2 # good, also #expect
# end
# end
module Minitest::Expectations
##
# See Minitest::Assertions#assert_empty.
#
# collection.must_be_empty
#
# :method: must_be_empty
infect_an_assertion :assert_empty, :must_be_empty, :unary
##
# See Minitest::Assertions#assert_equal
#
# a.must_equal b
#
# :method: must_equal
infect_an_assertion :assert_equal, :must_equal
##
# See Minitest::Assertions#assert_in_delta
#
# n.must_be_close_to m [, delta]
#
# :method: must_be_close_to
infect_an_assertion :assert_in_delta, :must_be_close_to
alias :must_be_within_delta :must_be_close_to # :nodoc:
##
# See Minitest::Assertions#assert_in_epsilon
#
# n.must_be_within_epsilon m [, epsilon]
#
# :method: must_be_within_epsilon
infect_an_assertion :assert_in_epsilon, :must_be_within_epsilon
##
# See Minitest::Assertions#assert_includes
#
# collection.must_include obj
#
# :method: must_include
infect_an_assertion :assert_includes, :must_include, :reverse
##
# See Minitest::Assertions#assert_instance_of
#
# obj.must_be_instance_of klass
#
# :method: must_be_instance_of
infect_an_assertion :assert_instance_of, :must_be_instance_of
##
# See Minitest::Assertions#assert_kind_of
#
# obj.must_be_kind_of mod
#
# :method: must_be_kind_of
infect_an_assertion :assert_kind_of, :must_be_kind_of
##
# See Minitest::Assertions#assert_match
#
# a.must_match b
#
# :method: must_match
infect_an_assertion :assert_match, :must_match
##
# See Minitest::Assertions#assert_nil
#
# obj.must_be_nil
#
# :method: must_be_nil
infect_an_assertion :assert_nil, :must_be_nil, :unary
##
# See Minitest::Assertions#assert_operator
#
# n.must_be :<=, 42
#
# This can also do predicates:
#
# str.must_be :empty?
#
# :method: must_be
infect_an_assertion :assert_operator, :must_be, :reverse
##
# See Minitest::Assertions#assert_output
#
# proc { ... }.must_output out_or_nil [, err]
#
# :method: must_output
infect_an_assertion :assert_output, :must_output, :block
##
# See Minitest::Assertions#assert_raises
#
# proc { ... }.must_raise exception
#
# :method: must_raise
infect_an_assertion :assert_raises, :must_raise, :block
##
# See Minitest::Assertions#assert_respond_to
#
# obj.must_respond_to msg
#
# :method: must_respond_to
infect_an_assertion :assert_respond_to, :must_respond_to, :reverse
##
# See Minitest::Assertions#assert_same
#
# a.must_be_same_as b
#
# :method: must_be_same_as
infect_an_assertion :assert_same, :must_be_same_as
##
# See Minitest::Assertions#assert_silent
#
# proc { ... }.must_be_silent
#
# :method: must_be_silent
infect_an_assertion :assert_silent, :must_be_silent, :block
##
# See Minitest::Assertions#assert_throws
#
# proc { ... }.must_throw sym
#
# :method: must_throw
infect_an_assertion :assert_throws, :must_throw, :block
##
# See Minitest::Assertions#refute_empty
#
# collection.wont_be_empty
#
# :method: wont_be_empty
infect_an_assertion :refute_empty, :wont_be_empty, :unary
##
# See Minitest::Assertions#refute_equal
#
# a.wont_equal b
#
# :method: wont_equal
infect_an_assertion :refute_equal, :wont_equal
##
# See Minitest::Assertions#refute_in_delta
#
# n.wont_be_close_to m [, delta]
#
# :method: wont_be_close_to
infect_an_assertion :refute_in_delta, :wont_be_close_to
alias :wont_be_within_delta :wont_be_close_to # :nodoc:
##
# See Minitest::Assertions#refute_in_epsilon
#
# n.wont_be_within_epsilon m [, epsilon]
#
# :method: wont_be_within_epsilon
infect_an_assertion :refute_in_epsilon, :wont_be_within_epsilon
##
# See Minitest::Assertions#refute_includes
#
# collection.wont_include obj
#
# :method: wont_include
infect_an_assertion :refute_includes, :wont_include, :reverse
##
# See Minitest::Assertions#refute_instance_of
#
# obj.wont_be_instance_of klass
#
# :method: wont_be_instance_of
infect_an_assertion :refute_instance_of, :wont_be_instance_of
##
# See Minitest::Assertions#refute_kind_of
#
# obj.wont_be_kind_of mod
#
# :method: wont_be_kind_of
infect_an_assertion :refute_kind_of, :wont_be_kind_of
##
# See Minitest::Assertions#refute_match
#
# a.wont_match b
#
# :method: wont_match
infect_an_assertion :refute_match, :wont_match
##
# See Minitest::Assertions#refute_nil
#
# obj.wont_be_nil
#
# :method: wont_be_nil
infect_an_assertion :refute_nil, :wont_be_nil, :unary
##
# See Minitest::Assertions#refute_operator
#
# n.wont_be :<=, 42
#
# This can also do predicates:
#
# str.wont_be :empty?
#
# :method: wont_be
infect_an_assertion :refute_operator, :wont_be, :reverse
##
# See Minitest::Assertions#refute_respond_to
#
# obj.wont_respond_to msg
#
# :method: wont_respond_to
infect_an_assertion :refute_respond_to, :wont_respond_to, :reverse
##
# See Minitest::Assertions#refute_same
#
# a.wont_be_same_as b
#
# :method: wont_be_same_as
infect_an_assertion :refute_same, :wont_be_same_as
end
minitest-5.10.3/lib/minitest/hell.rb 0000444 0000041 0000041 00000000313 13135676423 017344 0 ustar www-data www-data require "minitest/parallel"
class Minitest::Test
parallelize_me!
end
begin
require "minitest/proveit"
rescue LoadError
warn "NOTE: `gem install minitest-proveit` for even more hellish tests"
end
minitest-5.10.3/lib/minitest/spec.rb 0000444 0000041 0000041 00000020742 13135676423 017362 0 ustar www-data www-data require "minitest/test"
class Module # :nodoc:
def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
block = dont_flip == :block
dont_flip = false if block
# warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
self.class_eval <<-EOM, __FILE__, __LINE__ + 1
def #{new_name} *args
Minitest::Expectation.new(self, Minitest::Spec.current).#{new_name}(*args)
end
EOM
Minitest::Expectation.class_eval <<-EOM, __FILE__, __LINE__ + 1
def #{new_name} *args
case
when #{!!dont_flip} then
ctx.#{meth}(target, *args)
when #{block} && Proc === target then
ctx.#{meth}(*args, &target)
else
ctx.#{meth}(args.first, target, *args[1..-1])
end
end
EOM
end
end
Minitest::Expectation = Struct.new :target, :ctx # :nodoc:
##
# Kernel extensions for minitest
module Kernel
##
# Describe a series of expectations for a given target +desc+.
#
# Defines a test class subclassing from either Minitest::Spec or
# from the surrounding describe's class. The surrounding class may
# subclass Minitest::Spec manually in order to easily share code:
#
# class MySpec < Minitest::Spec
# # ... shared code ...
# end
#
# class TestStuff < MySpec
# it "does stuff" do
# # shared code available here
# end
# describe "inner stuff" do
# it "still does stuff" do
# # ...and here
# end
# end
# end
#
# For more information on getting started with writing specs, see:
#
# http://www.rubyinside.com/a-minitestspec-tutorial-elegant-spec-style-testing-that-comes-with-ruby-5354.html
#
# For some suggestions on how to improve your specs, try:
#
# http://betterspecs.org
#
# but do note that several items there are debatable or specific to
# rspec.
#
# For more information about expectations, see Minitest::Expectations.
def describe desc, *additional_desc, &block # :doc:
stack = Minitest::Spec.describe_stack
name = [stack.last, desc, *additional_desc].compact.join("::")
sclas = stack.last || if Class === self && kind_of?(Minitest::Spec::DSL) then
self
else
Minitest::Spec.spec_type desc, *additional_desc
end
cls = sclas.create name, desc
stack.push cls
cls.class_eval(&block)
stack.pop
cls
end
private :describe
end
##
# Minitest::Spec -- The faster, better, less-magical spec framework!
#
# For a list of expectations, see Minitest::Expectations.
class Minitest::Spec < Minitest::Test
def self.current # :nodoc:
Thread.current[:current_spec]
end
def initialize name # :nodoc:
super
Thread.current[:current_spec] = self
end
##
# Oh look! A Minitest::Spec::DSL module! Eat your heart out DHH.
module DSL
##
# Contains pairs of matchers and Spec classes to be used to
# calculate the superclass of a top-level describe. This allows for
# automatically customizable spec types.
#
# See: register_spec_type and spec_type
TYPES = [[//, Minitest::Spec]]
##
# Register a new type of spec that matches the spec's description.
# This method can take either a Regexp and a spec class or a spec
# class and a block that takes the description and returns true if
# it matches.
#
# Eg:
#
# register_spec_type(/Controller$/, Minitest::Spec::Rails)
#
# or:
#
# register_spec_type(Minitest::Spec::RailsModel) do |desc|
# desc.superclass == ActiveRecord::Base
# end
def register_spec_type *args, &block
if block then
matcher, klass = block, args.first
else
matcher, klass = *args
end
TYPES.unshift [matcher, klass]
end
##
# Figure out the spec class to use based on a spec's description. Eg:
#
# spec_type("BlahController") # => Minitest::Spec::Rails
def spec_type desc, *additional
TYPES.find { |matcher, _klass|
if matcher.respond_to? :call then
matcher.call desc, *additional
else
matcher === desc.to_s
end
}.last
end
def describe_stack # :nodoc:
Thread.current[:describe_stack] ||= []
end
def children # :nodoc:
@children ||= []
end
def nuke_test_methods! # :nodoc:
self.public_instance_methods.grep(/^test_/).each do |name|
self.send :undef_method, name
end
end
##
# Define a 'before' action. Inherits the way normal methods should.
#
# NOTE: +type+ is ignored and is only there to make porting easier.
#
# Equivalent to Minitest::Test#setup.
def before _type = nil, &block
define_method :setup do
super()
self.instance_eval(&block)
end
end
##
# Define an 'after' action. Inherits the way normal methods should.
#
# NOTE: +type+ is ignored and is only there to make porting easier.
#
# Equivalent to Minitest::Test#teardown.
def after _type = nil, &block
define_method :teardown do
self.instance_eval(&block)
super()
end
end
##
# Define an expectation with name +desc+. Name gets morphed to a
# proper test method name. For some freakish reason, people who
# write specs don't like class inheritance, so this goes way out of
# its way to make sure that expectations aren't inherited.
#
# This is also aliased to #specify and doesn't require a +desc+ arg.
#
# Hint: If you _do_ want inheritance, use minitest/test. You can mix
# and match between assertions and expectations as much as you want.
def it desc = "anonymous", &block
block ||= proc { skip "(no tests defined)" }
@specs ||= 0
@specs += 1
name = "test_%04d_%s" % [ @specs, desc ]
undef_klasses = self.children.reject { |c| c.public_method_defined? name }
define_method name, &block
undef_klasses.each do |undef_klass|
undef_klass.send :undef_method, name
end
name
end
##
# Essentially, define an accessor for +name+ with +block+.
#
# Why use let instead of def? I honestly don't know.
def let name, &block
name = name.to_s
pre, post = "let '#{name}' cannot ", ". Please use another name."
methods = Minitest::Spec.instance_methods.map(&:to_s) - %w[subject]
raise ArgumentError, "#{pre}begin with 'test'#{post}" if
name =~ /\Atest/
raise ArgumentError, "#{pre}override a method in Minitest::Spec#{post}" if
methods.include? name
define_method name do
@_memoized ||= {}
@_memoized.fetch(name) { |k| @_memoized[k] = instance_eval(&block) }
end
end
##
# Another lazy man's accessor generator. Made even more lazy by
# setting the name for you to +subject+.
def subject &block
let :subject, &block
end
def create name, desc # :nodoc:
cls = Class.new(self) do
@name = name
@desc = desc
nuke_test_methods!
end
children << cls
cls
end
def name # :nodoc:
defined?(@name) ? @name : super
end
def to_s # :nodoc:
name # Can't alias due to 1.8.7, not sure why
end
attr_reader :desc # :nodoc:
alias :specify :it
##
# Rdoc... why are you so dumb?
module InstanceMethods
##
# Returns a value monad that has all of Expectations methods
# available to it.
#
# Also aliased to #value and #expect for your aesthetic pleasure:
#
# _(1 + 1).must_equal 2
# value(1 + 1).must_equal 2
# expect(1 + 1).must_equal 2
#
# This method of expectation-based testing is preferable to
# straight-expectation methods (on Object) because it stores its
# test context, bypassing our hacky use of thread-local variables.
#
# At some point, the methods on Object will be deprecated and then
# removed.
def _ value = nil, &block
Minitest::Expectation.new block || value, self
end
alias value _
alias expect _
def before_setup # :nodoc:
super
Thread.current[:current_spec] = self
end
end
def self.extended obj # :nodoc:
obj.send :include, InstanceMethods
end
end
extend DSL
TYPES = DSL::TYPES # :nodoc:
end
require "minitest/expectations"
class Object # :nodoc:
include Minitest::Expectations unless ENV["MT_NO_EXPECTATIONS"]
end
minitest-5.10.3/lib/minitest/mock.rb 0000444 0000041 0000041 00000015560 13135676423 017363 0 ustar www-data www-data class MockExpectationError < StandardError; end # :nodoc:
module Minitest # :nodoc:
##
# A simple and clean mock object framework.
#
# All mock objects are an instance of Mock
class Mock
alias :__respond_to? :respond_to?
overridden_methods = %w[
===
class
inspect
instance_eval
instance_variables
object_id
public_send
respond_to_missing?
send
to_s
]
instance_methods.each do |m|
undef_method m unless overridden_methods.include?(m.to_s) || m =~ /^__/
end
overridden_methods.map(&:to_sym).each do |method_id|
define_method method_id do |*args, &b|
if @expected_calls.key? method_id then
method_missing(method_id, *args, &b)
else
super(*args, &b)
end
end
end
def initialize delegator = nil # :nodoc:
@delegator = delegator
@expected_calls = Hash.new { |calls, name| calls[name] = [] }
@actual_calls = Hash.new { |calls, name| calls[name] = [] }
end
##
# Expect that method +name+ is called, optionally with +args+ or a
# +blk+, and returns +retval+.
#
# @mock.expect(:meaning_of_life, 42)
# @mock.meaning_of_life # => 42
#
# @mock.expect(:do_something_with, true, [some_obj, true])
# @mock.do_something_with(some_obj, true) # => true
#
# @mock.expect(:do_something_else, true) do |a1, a2|
# a1 == "buggs" && a2 == :bunny
# end
#
# +args+ is compared to the expected args using case equality (ie, the
# '===' operator), allowing for less specific expectations.
#
# @mock.expect(:uses_any_string, true, [String])
# @mock.uses_any_string("foo") # => true
# @mock.verify # => true
#
# @mock.expect(:uses_one_string, true, ["foo"])
# @mock.uses_one_string("bar") # => raises MockExpectationError
#
# If a method will be called multiple times, specify a new expect for each one.
# They will be used in the order you define them.
#
# @mock.expect(:ordinal_increment, 'first')
# @mock.expect(:ordinal_increment, 'second')
#
# @mock.ordinal_increment # => 'first'
# @mock.ordinal_increment # => 'second'
# @mock.ordinal_increment # => raises MockExpectationError "No more expects available for :ordinal_increment"
#
def expect name, retval, args = [], &blk
name = name.to_sym
if block_given?
raise ArgumentError, "args ignored when block given" unless args.empty?
@expected_calls[name] << { :retval => retval, :block => blk }
else
raise ArgumentError, "args must be an array" unless Array === args
@expected_calls[name] << { :retval => retval, :args => args }
end
self
end
def __call name, data # :nodoc:
case data
when Hash then
"#{name}(#{data[:args].inspect[1..-2]}) => #{data[:retval].inspect}"
else
data.map { |d| __call name, d }.join ", "
end
end
##
# Verify that all methods were called as expected. Raises
# +MockExpectationError+ if the mock object was not called as
# expected.
def verify
@expected_calls.each do |name, expected|
actual = @actual_calls.fetch(name, nil)
raise MockExpectationError, "expected #{__call name, expected[0]}" unless actual
raise MockExpectationError, "expected #{__call name, expected[actual.size]}, got [#{__call name, actual}]" if
actual.size < expected.size
end
true
end
def method_missing sym, *args, &block # :nodoc:
unless @expected_calls.key?(sym) then
if @delegator && @delegator.respond_to?(sym)
return @delegator.public_send(sym, *args, &block)
else
raise NoMethodError, "unmocked method %p, expected one of %p" %
[sym, @expected_calls.keys.sort_by(&:to_s)]
end
end
index = @actual_calls[sym].length
expected_call = @expected_calls[sym][index]
unless expected_call then
raise MockExpectationError, "No more expects available for %p: %p" %
[sym, args]
end
expected_args, retval, val_block =
expected_call.values_at(:args, :retval, :block)
if val_block then
# keep "verify" happy
@actual_calls[sym] << expected_call
raise MockExpectationError, "mocked method %p failed block w/ %p" %
[sym, args] unless val_block.call(*args, &block)
return retval
end
if expected_args.size != args.size then
raise ArgumentError, "mocked method %p expects %d arguments, got %d" %
[sym, expected_args.size, args.size]
end
zipped_args = expected_args.zip(args)
fully_matched = zipped_args.all? { |mod, a|
mod === a or mod == a
}
unless fully_matched then
raise MockExpectationError, "mocked method %p called with unexpected arguments %p" %
[sym, args]
end
@actual_calls[sym] << {
:retval => retval,
:args => zipped_args.map! { |mod, a| mod === a ? mod : a },
}
retval
end
def respond_to? sym, include_private = false # :nodoc:
return true if @expected_calls.key? sym.to_sym
return true if @delegator && @delegator.respond_to?(sym, include_private)
__respond_to?(sym, include_private)
end
end
end
module Minitest::Assertions
##
# Assert that the mock verifies correctly.
def assert_mock mock
assert mock.verify
end
end
##
# Object extensions for Minitest::Mock.
class Object
##
# Add a temporary stubbed method replacing +name+ for the duration
# of the +block+. If +val_or_callable+ responds to #call, then it
# returns the result of calling it, otherwise returns the value
# as-is. If stubbed method yields a block, +block_args+ will be
# passed along. Cleans up the stub at the end of the +block+. The
# method +name+ must exist before stubbing.
#
# def test_stale_eh
# obj_under_test = Something.new
# refute obj_under_test.stale?
#
# Time.stub :now, Time.at(0) do
# assert obj_under_test.stale?
# end
# end
#
def stub name, val_or_callable, *block_args
new_name = "__minitest_stub__#{name}"
metaclass = class << self; self; end
if respond_to? name and not methods.map(&:to_s).include? name.to_s then
metaclass.send :define_method, name do |*args|
super(*args)
end
end
metaclass.send :alias_method, new_name, name
metaclass.send :define_method, name do |*args, &blk|
ret = if val_or_callable.respond_to? :call then
val_or_callable.call(*args)
else
val_or_callable
end
blk.call(*block_args) if blk
ret
end
yield self
ensure
metaclass.send :undef_method, name
metaclass.send :alias_method, name, new_name
metaclass.send :undef_method, new_name
end
end
minitest-5.10.3/lib/minitest/pride_plugin.rb 0000444 0000041 0000041 00000006115 13135676423 021107 0 ustar www-data www-data require "minitest"
module Minitest
def self.plugin_pride_options opts, _options # :nodoc:
opts.on "-p", "--pride", "Pride. Show your testing pride!" do
PrideIO.pride!
end
end
def self.plugin_pride_init options # :nodoc:
if PrideIO.pride? then
klass = ENV["TERM"] =~ /^xterm|-256color$/ ? PrideLOL : PrideIO
io = klass.new options[:io]
self.reporter.reporters.grep(Minitest::Reporter).each do |rep|
rep.io = io if rep.io.tty?
end
end
end
##
# Show your testing pride!
class PrideIO
##
# Activate the pride plugin. Called from both -p option and minitest/pride
def self.pride!
@pride = true
end
##
# Are we showing our testing pride?
def self.pride?
@pride ||= false
end
# Start an escape sequence
ESC = "\e["
# End the escape sequence
NND = "#{ESC}0m"
# The IO we're going to pipe through.
attr_reader :io
def initialize io # :nodoc:
@io = io
# stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm
# also reference http://en.wikipedia.org/wiki/ANSI_escape_code
@colors ||= (31..36).to_a
@size = @colors.size
@index = 0
end
##
# Wrap print to colorize the output.
def print o
case o
when "." then
io.print pride o
when "E", "F" then
io.print "#{ESC}41m#{ESC}37m#{o}#{NND}"
when "S" then
io.print pride o
else
io.print o
end
end
def puts *o # :nodoc:
o.map! { |s|
s.to_s.sub(/Finished/) {
@index = 0
"Fabulous run".split(//).map { |c|
pride(c)
}.join
}
}
io.puts(*o)
end
##
# Color a string.
def pride string
string = "*" if string == "."
c = @colors[@index % @size]
@index += 1
"#{ESC}#{c}m#{string}#{NND}"
end
def method_missing msg, *args # :nodoc:
io.send(msg, *args)
end
end
##
# If you thought the PrideIO was colorful...
#
# (Inspired by lolcat, but with clean math)
class PrideLOL < PrideIO
PI_3 = Math::PI / 3 # :nodoc:
def initialize io # :nodoc:
# walk red, green, and blue around a circle separated by equal thirds.
#
# To visualize, type this into wolfram-alpha:
#
# plot (3*sin(x)+3), (3*sin(x+2*pi/3)+3), (3*sin(x+4*pi/3)+3)
# 6 has wide pretty gradients. 3 == lolcat, about half the width
@colors = (0...(6 * 7)).map { |n|
n *= 1.0 / 6
r = (3 * Math.sin(n ) + 3).to_i
g = (3 * Math.sin(n + 2 * PI_3) + 3).to_i
b = (3 * Math.sin(n + 4 * PI_3) + 3).to_i
# Then we take rgb and encode them in a single number using base 6.
# For some mysterious reason, we add 16... to clear the bottom 4 bits?
# Yes... they're ugly.
36 * r + 6 * g + b + 16
}
super
end
##
# Make the string even more colorful. Damnit.
def pride string
c = @colors[@index % @size]
@index += 1
"#{ESC}38;5;#{c}m#{string}#{NND}"
end
end
end
minitest-5.10.3/lib/minitest/test.rb 0000444 0000041 0000041 00000015316 13135676423 017410 0 ustar www-data www-data require "minitest" unless defined? Minitest::Runnable
module Minitest
##
# Subclass Test to create your own tests. Typically you'll want a
# Test subclass per implementation class.
#
# See Minitest::Assertions
class Test < Runnable
require "minitest/assertions"
include Minitest::Assertions
PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException, SystemExit] # :nodoc:
# :stopdoc:
class << self; attr_accessor :io_lock; end
self.io_lock = Mutex.new
# :startdoc:
##
# Call this at the top of your tests when you absolutely
# positively need to have ordered tests. In doing so, you're
# admitting that you suck and your tests are weak.
def self.i_suck_and_my_tests_are_order_dependent!
class << self
undef_method :test_order if method_defined? :test_order
define_method :test_order do :alpha end
end
end
##
# Make diffs for this Test use #pretty_inspect so that diff
# in assert_equal can have more details. NOTE: this is much slower
# than the regular inspect but much more usable for complex
# objects.
def self.make_my_diffs_pretty!
require "pp"
define_method :mu_pp, &:pretty_inspect
end
##
# Call this at the top of your tests when you want to run your
# tests in parallel. In doing so, you're admitting that you rule
# and your tests are awesome.
def self.parallelize_me!
include Minitest::Parallel::Test
extend Minitest::Parallel::Test::ClassMethods
end
##
# Returns all instance methods starting with "test_". Based on
# #test_order, the methods are either sorted, randomized
# (default), or run in parallel.
def self.runnable_methods
methods = methods_matching(/^test_/)
case self.test_order
when :random, :parallel then
max = methods.size
methods.sort.sort_by { rand max }
when :alpha, :sorted then
methods.sort
else
raise "Unknown test_order: #{self.test_order.inspect}"
end
end
##
# Defines the order to run tests (:random by default). Override
# this or use a convenience method to change it for your tests.
def self.test_order
:random
end
##
# The time it took to run this test.
attr_accessor :time
def marshal_dump # :nodoc:
super << self.time
end
def marshal_load ary # :nodoc:
self.time = ary.pop
super
end
TEARDOWN_METHODS = %w[ before_teardown teardown after_teardown ] # :nodoc:
##
# Runs a single test with setup/teardown hooks.
def run
with_info_handler do
time_it do
capture_exceptions do
before_setup; setup; after_setup
self.send self.name
end
TEARDOWN_METHODS.each do |hook|
capture_exceptions do
self.send hook
end
end
end
end
self # per contract
end
##
# Provides before/after hooks for setup and teardown. These are
# meant for library writers, NOT for regular test authors. See
# #before_setup for an example.
module LifecycleHooks
##
# Runs before every test, before setup. This hook is meant for
# libraries to extend minitest. It is not meant to be used by
# test developers.
#
# As a simplistic example:
#
# module MyMinitestPlugin
# def before_setup
# super
# # ... stuff to do before setup is run
# end
#
# def after_setup
# # ... stuff to do after setup is run
# super
# end
#
# def before_teardown
# super
# # ... stuff to do before teardown is run
# end
#
# def after_teardown
# # ... stuff to do after teardown is run
# super
# end
# end
#
# class MiniTest::Test
# include MyMinitestPlugin
# end
def before_setup; end
##
# Runs before every test. Use this to set up before each test
# run.
def setup; end
##
# Runs before every test, after setup. This hook is meant for
# libraries to extend minitest. It is not meant to be used by
# test developers.
#
# See #before_setup for an example.
def after_setup; end
##
# Runs after every test, before teardown. This hook is meant for
# libraries to extend minitest. It is not meant to be used by
# test developers.
#
# See #before_setup for an example.
def before_teardown; end
##
# Runs after every test. Use this to clean up after each test
# run.
def teardown; end
##
# Runs after every test, after teardown. This hook is meant for
# libraries to extend minitest. It is not meant to be used by
# test developers.
#
# See #before_setup for an example.
def after_teardown; end
end # LifecycleHooks
def capture_exceptions # :nodoc:
yield
rescue *PASSTHROUGH_EXCEPTIONS
raise
rescue Assertion => e
self.failures << e
rescue Exception => e
self.failures << UnexpectedError.new(e)
end
##
# Did this run error?
def error?
self.failures.any? { |f| UnexpectedError === f }
end
##
# The location identifier of this test.
def location
loc = " [#{self.failure.location}]" unless passed? or error?
"#{self.class}##{self.name}#{loc}"
end
##
# Did this run pass?
#
# Note: skipped runs are not considered passing, but they don't
# cause the process to exit non-zero.
def passed?
not self.failure
end
##
# Returns ".", "F", or "E" based on the result of the run.
def result_code
self.failure and self.failure.result_code or "."
end
##
# Was this run skipped?
def skipped?
self.failure and Skip === self.failure
end
def time_it # :nodoc:
t0 = Minitest.clock_time
yield
ensure
self.time = Minitest.clock_time - t0
end
def to_s # :nodoc:
return location if passed? and not skipped?
failures.map { |failure|
"#{failure.result_label}:\n#{self.location}:\n#{failure.message}\n"
}.join "\n"
end
def with_info_handler &block # :nodoc:
t0 = Minitest.clock_time
handler = lambda do
warn "\nCurrent: %s#%s %.2fs" % [self.class, self.name, Minitest.clock_time - t0]
end
self.class.on_signal ::Minitest.info_signal, handler, &block
end
include LifecycleHooks
include Guard
extend Guard
end # Test
end
require "minitest/unit" unless defined?(MiniTest) # compatibility layer only
minitest-5.10.3/lib/minitest/benchmark.rb 0000444 0000041 0000041 00000026342 13135676423 020364 0 ustar www-data www-data require "minitest/test"
require "minitest/spec"
module Minitest
##
# Subclass Benchmark to create your own benchmark runs. Methods
# starting with "bench_" get executed on a per-class.
#
# See Minitest::Assertions
class Benchmark < Test
def self.io # :nodoc:
@io
end
def io # :nodoc:
self.class.io
end
def self.run reporter, options = {} # :nodoc:
@io = reporter.io
super
end
def self.runnable_methods # :nodoc:
methods_matching(/^bench_/)
end
##
# Returns a set of ranges stepped exponentially from +min+ to
# +max+ by powers of +base+. Eg:
#
# bench_exp(2, 16, 2) # => [2, 4, 8, 16]
def self.bench_exp min, max, base = 10
min = (Math.log10(min) / Math.log10(base)).to_i
max = (Math.log10(max) / Math.log10(base)).to_i
(min..max).map { |m| base ** m }.to_a
end
##
# Returns a set of ranges stepped linearly from +min+ to +max+ by
# +step+. Eg:
#
# bench_linear(20, 40, 10) # => [20, 30, 40]
def self.bench_linear min, max, step = 10
(min..max).step(step).to_a
rescue LocalJumpError # 1.8.6
r = []; (min..max).step(step) { |n| r << n }; r
end
##
# Specifies the ranges used for benchmarking for that class.
# Defaults to exponential growth from 1 to 10k by powers of 10.
# Override if you need different ranges for your benchmarks.
#
# See also: ::bench_exp and ::bench_linear.
def self.bench_range
bench_exp 1, 10_000
end
##
# Runs the given +work+, gathering the times of each run. Range
# and times are then passed to a given +validation+ proc. Outputs
# the benchmark name and times in tab-separated format, making it
# easy to paste into a spreadsheet for graphing or further
# analysis.
#
# Ranges are specified by ::bench_range.
#
# Eg:
#
# def bench_algorithm
# validation = proc { |x, y| ... }
# assert_performance validation do |n|
# @obj.algorithm(n)
# end
# end
def assert_performance validation, &work
range = self.class.bench_range
io.print "#{self.name}"
times = []
range.each do |x|
GC.start
t0 = Minitest.clock_time
instance_exec(x, &work)
t = Minitest.clock_time - t0
io.print "\t%9.6f" % t
times << t
end
io.puts
validation[range, times]
end
##
# Runs the given +work+ and asserts that the times gathered fit to
# match a constant rate (eg, linear slope == 0) within a given
# +threshold+. Note: because we're testing for a slope of 0, R^2
# is not a good determining factor for the fit, so the threshold
# is applied against the slope itself. As such, you probably want
# to tighten it from the default.
#
# See http://www.graphpad.com/curvefit/goodness_of_fit.htm for
# more details.
#
# Fit is calculated by #fit_linear.
#
# Ranges are specified by ::bench_range.
#
# Eg:
#
# def bench_algorithm
# assert_performance_constant 0.9999 do |n|
# @obj.algorithm(n)
# end
# end
def assert_performance_constant threshold = 0.99, &work
validation = proc do |range, times|
a, b, rr = fit_linear range, times
assert_in_delta 0, b, 1 - threshold
[a, b, rr]
end
assert_performance validation, &work
end
##
# Runs the given +work+ and asserts that the times gathered fit to
# match a exponential curve within a given error +threshold+.
#
# Fit is calculated by #fit_exponential.
#
# Ranges are specified by ::bench_range.
#
# Eg:
#
# def bench_algorithm
# assert_performance_exponential 0.9999 do |n|
# @obj.algorithm(n)
# end
# end
def assert_performance_exponential threshold = 0.99, &work
assert_performance validation_for_fit(:exponential, threshold), &work
end
##
# Runs the given +work+ and asserts that the times gathered fit to
# match a logarithmic curve within a given error +threshold+.
#
# Fit is calculated by #fit_logarithmic.
#
# Ranges are specified by ::bench_range.
#
# Eg:
#
# def bench_algorithm
# assert_performance_logarithmic 0.9999 do |n|
# @obj.algorithm(n)
# end
# end
def assert_performance_logarithmic threshold = 0.99, &work
assert_performance validation_for_fit(:logarithmic, threshold), &work
end
##
# Runs the given +work+ and asserts that the times gathered fit to
# match a straight line within a given error +threshold+.
#
# Fit is calculated by #fit_linear.
#
# Ranges are specified by ::bench_range.
#
# Eg:
#
# def bench_algorithm
# assert_performance_linear 0.9999 do |n|
# @obj.algorithm(n)
# end
# end
def assert_performance_linear threshold = 0.99, &work
assert_performance validation_for_fit(:linear, threshold), &work
end
##
# Runs the given +work+ and asserts that the times gathered curve
# fit to match a power curve within a given error +threshold+.
#
# Fit is calculated by #fit_power.
#
# Ranges are specified by ::bench_range.
#
# Eg:
#
# def bench_algorithm
# assert_performance_power 0.9999 do |x|
# @obj.algorithm
# end
# end
def assert_performance_power threshold = 0.99, &work
assert_performance validation_for_fit(:power, threshold), &work
end
##
# Takes an array of x/y pairs and calculates the general R^2 value.
#
# See: http://en.wikipedia.org/wiki/Coefficient_of_determination
def fit_error xys
y_bar = sigma(xys) { |_, y| y } / xys.size.to_f
ss_tot = sigma(xys) { |_, y| (y - y_bar) ** 2 }
ss_err = sigma(xys) { |x, y| (yield(x) - y) ** 2 }
1 - (ss_err / ss_tot)
end
##
# To fit a functional form: y = ae^(bx).
#
# Takes x and y values and returns [a, b, r^2].
#
# See: http://mathworld.wolfram.com/LeastSquaresFittingExponential.html
def fit_exponential xs, ys
n = xs.size
xys = xs.zip(ys)
sxlny = sigma(xys) { |x, y| x * Math.log(y) }
slny = sigma(xys) { |_, y| Math.log(y) }
sx2 = sigma(xys) { |x, _| x * x }
sx = sigma xs
c = n * sx2 - sx ** 2
a = (slny * sx2 - sx * sxlny) / c
b = ( n * sxlny - sx * slny ) / c
return Math.exp(a), b, fit_error(xys) { |x| Math.exp(a + b * x) }
end
##
# To fit a functional form: y = a + b*ln(x).
#
# Takes x and y values and returns [a, b, r^2].
#
# See: http://mathworld.wolfram.com/LeastSquaresFittingLogarithmic.html
def fit_logarithmic xs, ys
n = xs.size
xys = xs.zip(ys)
slnx2 = sigma(xys) { |x, _| Math.log(x) ** 2 }
slnx = sigma(xys) { |x, _| Math.log(x) }
sylnx = sigma(xys) { |x, y| y * Math.log(x) }
sy = sigma(xys) { |_, y| y }
c = n * slnx2 - slnx ** 2
b = ( n * sylnx - sy * slnx ) / c
a = (sy - b * slnx) / n
return a, b, fit_error(xys) { |x| a + b * Math.log(x) }
end
##
# Fits the functional form: a + bx.
#
# Takes x and y values and returns [a, b, r^2].
#
# See: http://mathworld.wolfram.com/LeastSquaresFitting.html
def fit_linear xs, ys
n = xs.size
xys = xs.zip(ys)
sx = sigma xs
sy = sigma ys
sx2 = sigma(xs) { |x| x ** 2 }
sxy = sigma(xys) { |x, y| x * y }
c = n * sx2 - sx**2
a = (sy * sx2 - sx * sxy) / c
b = ( n * sxy - sx * sy ) / c
return a, b, fit_error(xys) { |x| a + b * x }
end
##
# To fit a functional form: y = ax^b.
#
# Takes x and y values and returns [a, b, r^2].
#
# See: http://mathworld.wolfram.com/LeastSquaresFittingPowerLaw.html
def fit_power xs, ys
n = xs.size
xys = xs.zip(ys)
slnxlny = sigma(xys) { |x, y| Math.log(x) * Math.log(y) }
slnx = sigma(xs) { |x | Math.log(x) }
slny = sigma(ys) { | y| Math.log(y) }
slnx2 = sigma(xs) { |x | Math.log(x) ** 2 }
b = (n * slnxlny - slnx * slny) / (n * slnx2 - slnx ** 2)
a = (slny - b * slnx) / n
return Math.exp(a), b, fit_error(xys) { |x| (Math.exp(a) * (x ** b)) }
end
##
# Enumerates over +enum+ mapping +block+ if given, returning the
# sum of the result. Eg:
#
# sigma([1, 2, 3]) # => 1 + 2 + 3 => 7
# sigma([1, 2, 3]) { |n| n ** 2 } # => 1 + 4 + 9 => 14
def sigma enum, &block
enum = enum.map(&block) if block
enum.inject { |sum, n| sum + n }
end
##
# Returns a proc that calls the specified fit method and asserts
# that the error is within a tolerable threshold.
def validation_for_fit msg, threshold
proc do |range, times|
a, b, rr = send "fit_#{msg}", range, times
assert_operator rr, :>=, threshold
[a, b, rr]
end
end
end
end
module Minitest
##
# The spec version of Minitest::Benchmark.
class BenchSpec < Benchmark
extend Minitest::Spec::DSL
##
# This is used to define a new benchmark method. You usually don't
# use this directly and is intended for those needing to write new
# performance curve fits (eg: you need a specific polynomial fit).
#
# See ::bench_performance_linear for an example of how to use this.
def self.bench name, &block
define_method "bench_#{name.gsub(/\W+/, "_")}", &block
end
##
# Specifies the ranges used for benchmarking for that class.
#
# bench_range do
# bench_exp(2, 16, 2)
# end
#
# See Minitest::Benchmark#bench_range for more details.
def self.bench_range &block
return super unless block
meta = (class << self; self; end)
meta.send :define_method, "bench_range", &block
end
##
# Create a benchmark that verifies that the performance is linear.
#
# describe "my class Bench" do
# bench_performance_linear "fast_algorithm", 0.9999 do |n|
# @obj.fast_algorithm(n)
# end
# end
def self.bench_performance_linear name, threshold = 0.99, &work
bench name do
assert_performance_linear threshold, &work
end
end
##
# Create a benchmark that verifies that the performance is constant.
#
# describe "my class Bench" do
# bench_performance_constant "zoom_algorithm!" do |n|
# @obj.zoom_algorithm!(n)
# end
# end
def self.bench_performance_constant name, threshold = 0.99, &work
bench name do
assert_performance_constant threshold, &work
end
end
##
# Create a benchmark that verifies that the performance is exponential.
#
# describe "my class Bench" do
# bench_performance_exponential "algorithm" do |n|
# @obj.algorithm(n)
# end
# end
def self.bench_performance_exponential name, threshold = 0.99, &work
bench name do
assert_performance_exponential threshold, &work
end
end
end
Minitest::Spec.register_spec_type(/Bench(mark)?$/, Minitest::BenchSpec)
end
minitest-5.10.3/lib/minitest/autorun.rb 0000444 0000041 0000041 00000000325 13135676423 020120 0 ustar www-data www-data begin
require "rubygems"
gem "minitest"
rescue Gem::LoadError
# do nothing
end
require "minitest"
require "minitest/spec"
require "minitest/mock"
require "minitest/hell" if ENV["MT_HELL"]
Minitest.autorun
minitest-5.10.3/lib/minitest/parallel.rb 0000444 0000041 0000041 00000003075 13135676423 020224 0 ustar www-data www-data module Minitest
module Parallel #:nodoc:
##
# The engine used to run multiple tests in parallel.
class Executor
##
# The size of the pool of workers.
attr_reader :size
##
# Create a parallel test executor of with +size+ workers.
def initialize size
@size = size
@queue = Queue.new
@pool = nil
end
##
# Start the executor
def start
@pool = size.times.map {
Thread.new(@queue) do |queue|
Thread.current.abort_on_exception = true
while (job = queue.pop)
klass, method, reporter = job
reporter.synchronize { reporter.prerecord klass, method }
result = Minitest.run_one_method klass, method
reporter.synchronize { reporter.record result }
end
end
}
end
##
# Add a job to the queue
def << work; @queue << work; end
##
# Shuts down the pool of workers by signalling them to quit and
# waiting for them all to finish what they're currently working
# on.
def shutdown
size.times { @queue << nil }
@pool.each(&:join)
end
end
module Test
def _synchronize; Minitest::Test.io_lock.synchronize { yield }; end # :nodoc:
module ClassMethods # :nodoc:
def run_one_method klass, method_name, reporter
Minitest.parallel_executor << [klass, method_name, reporter]
end
def test_order
:parallel
end
end
end
end
end
minitest-5.10.3/lib/minitest/assertions.rb 0000444 0000041 0000041 00000044571 13135676423 020630 0 ustar www-data www-data # encoding: UTF-8
require "rbconfig"
require "tempfile"
require "stringio"
module Minitest
##
# Minitest Assertions. All assertion methods accept a +msg+ which is
# printed if the assertion fails.
#
# Protocol: Nearly everything here boils up to +assert+, which
# expects to be able to increment an instance accessor named
# +assertions+. This is not provided by Assertions and must be
# provided by the thing including Assertions. See Minitest::Runnable
# for an example.
module Assertions
UNDEFINED = Object.new # :nodoc:
def UNDEFINED.inspect # :nodoc:
"UNDEFINED" # again with the rdoc bugs... :(
end
##
# Returns the diff command to use in #diff. Tries to intelligently
# figure out what diff to use.
def self.diff
@diff = if (RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ &&
system("diff.exe", __FILE__, __FILE__)) then
"diff.exe -u"
elsif Minitest::Test.maglev? then
"diff -u"
elsif system("gdiff", __FILE__, __FILE__)
"gdiff -u" # solaris and kin suck
elsif system("diff", __FILE__, __FILE__)
"diff -u"
else
nil
end unless defined? @diff
@diff
end
##
# Set the diff command to use in #diff.
def self.diff= o
@diff = o
end
##
# Returns a diff between +exp+ and +act+. If there is no known
# diff command or if it doesn't make sense to diff the output
# (single line, short output), then it simply returns a basic
# comparison between the two.
def diff exp, act
expect = mu_pp_for_diff exp
butwas = mu_pp_for_diff act
result = nil
need_to_diff =
(expect.include?("\n") ||
butwas.include?("\n") ||
expect.size > 30 ||
butwas.size > 30 ||
expect == butwas) &&
Minitest::Assertions.diff
return "Expected: #{mu_pp exp}\n Actual: #{mu_pp act}" unless
need_to_diff
Tempfile.open("expect") do |a|
a.puts expect
a.flush
Tempfile.open("butwas") do |b|
b.puts butwas
b.flush
result = `#{Minitest::Assertions.diff} #{a.path} #{b.path}`
result.sub!(/^\-\-\- .+/, "--- expected")
result.sub!(/^\+\+\+ .+/, "+++ actual")
if result.empty? then
klass = exp.class
result = [
"No visible difference in the #{klass}#inspect output.\n",
"You should look at the implementation of #== on ",
"#{klass} or its members.\n",
expect,
].join
end
end
end
result
end
##
# This returns a human-readable version of +obj+. By default
# #inspect is called. You can override this to use #pretty_print
# if you want.
def mu_pp obj
s = obj.inspect
if defined? Encoding then
s = s.encode Encoding.default_external
if String === obj && obj.encoding != Encoding.default_external then
s = "# encoding: #{obj.encoding}\n#{s}"
end
end
s
end
##
# This returns a diff-able human-readable version of +obj+. This
# differs from the regular mu_pp because it expands escaped
# newlines and makes hex-values generic (like object_ids). This
# uses mu_pp to do the first pass and then cleans it up.
def mu_pp_for_diff obj
mu_pp(obj).gsub(/\\n/, "\n").gsub(/:0x[a-fA-F0-9]{4,}/m, ":0xXXXXXX")
end
##
# Fails unless +test+ is truthy.
def assert test, msg = nil
self.assertions += 1
unless test then
msg ||= "Expected #{mu_pp test} to be truthy."
msg = msg.call if Proc === msg
raise Minitest::Assertion, msg
end
true
end
def _synchronize # :nodoc:
yield
end
##
# Fails unless +obj+ is empty.
def assert_empty obj, msg = nil
msg = message(msg) { "Expected #{mu_pp(obj)} to be empty" }
assert_respond_to obj, :empty?
assert obj.empty?, msg
end
E = "" # :nodoc:
##
# Fails unless exp == act printing the difference between
# the two, if possible.
#
# If there is no visible difference but the assertion fails, you
# should suspect that your #== is buggy, or your inspect output is
# missing crucial details. For nicer structural diffing, set
# Minitest::Test.make_my_diffs_pretty!
#
# For floats use assert_in_delta.
#
# See also: Minitest::Assertions.diff
def assert_equal exp, act, msg = nil
msg = message(msg, E) { diff exp, act }
result = assert exp == act, msg
if exp.nil? then
if Minitest::VERSION =~ /^6/ then
refute_nil exp, "Use assert_nil if expecting nil."
else
where = Minitest.filter_backtrace(caller).first
where = where.split(/:in /, 2).first # clean up noise
warn "DEPRECATED: Use assert_nil if expecting nil from #{where}. This will fail in Minitest 6."
end
end
result
end
##
# For comparing Floats. Fails unless +exp+ and +act+ are within +delta+
# of each other.
#
# assert_in_delta Math::PI, (22.0 / 7.0), 0.01
def assert_in_delta exp, act, delta = 0.001, msg = nil
n = (exp - act).abs
msg = message(msg) {
"Expected |#{exp} - #{act}| (#{n}) to be <= #{delta}"
}
assert delta >= n, msg
end
##
# For comparing Floats. Fails unless +exp+ and +act+ have a relative
# error less than +epsilon+.
def assert_in_epsilon a, b, epsilon = 0.001, msg = nil
assert_in_delta a, b, [a.abs, b.abs].min * epsilon, msg
end
##
# Fails unless +collection+ includes +obj+.
def assert_includes collection, obj, msg = nil
msg = message(msg) {
"Expected #{mu_pp(collection)} to include #{mu_pp(obj)}"
}
assert_respond_to collection, :include?
assert collection.include?(obj), msg
end
##
# Fails unless +obj+ is an instance of +cls+.
def assert_instance_of cls, obj, msg = nil
msg = message(msg) {
"Expected #{mu_pp(obj)} to be an instance of #{cls}, not #{obj.class}"
}
assert obj.instance_of?(cls), msg
end
##
# Fails unless +obj+ is a kind of +cls+.
def assert_kind_of cls, obj, msg = nil
msg = message(msg) {
"Expected #{mu_pp(obj)} to be a kind of #{cls}, not #{obj.class}" }
assert obj.kind_of?(cls), msg
end
##
# Fails unless +matcher+ =~ +obj+.
def assert_match matcher, obj, msg = nil
msg = message(msg) { "Expected #{mu_pp matcher} to match #{mu_pp obj}" }
assert_respond_to matcher, :"=~"
matcher = Regexp.new Regexp.escape matcher if String === matcher
assert matcher =~ obj, msg
end
##
# Fails unless +obj+ is nil
def assert_nil obj, msg = nil
msg = message(msg) { "Expected #{mu_pp(obj)} to be nil" }
assert obj.nil?, msg
end
##
# For testing with binary operators. Eg:
#
# assert_operator 5, :<=, 4
def assert_operator o1, op, o2 = UNDEFINED, msg = nil
return assert_predicate o1, op, msg if UNDEFINED == o2
msg = message(msg) { "Expected #{mu_pp(o1)} to be #{op} #{mu_pp(o2)}" }
assert o1.__send__(op, o2), msg
end
##
# Fails if stdout or stderr do not output the expected results.
# Pass in nil if you don't care about that streams output. Pass in
# "" if you require it to be silent. Pass in a regexp if you want
# to pattern match.
#
# assert_output(/hey/) { method_with_output }
#
# NOTE: this uses #capture_io, not #capture_subprocess_io.
#
# See also: #assert_silent
def assert_output stdout = nil, stderr = nil
out, err = capture_io do
yield
end
err_msg = Regexp === stderr ? :assert_match : :assert_equal if stderr
out_msg = Regexp === stdout ? :assert_match : :assert_equal if stdout
y = send err_msg, stderr, err, "In stderr" if err_msg
x = send out_msg, stdout, out, "In stdout" if out_msg
(!stdout || x) && (!stderr || y)
end
##
# For testing with predicates. Eg:
#
# assert_predicate str, :empty?
#
# This is really meant for specs and is front-ended by assert_operator:
#
# str.must_be :empty?
def assert_predicate o1, op, msg = nil
msg = message(msg) { "Expected #{mu_pp(o1)} to be #{op}" }
assert o1.__send__(op), msg
end
##
# Fails unless the block raises one of +exp+. Returns the
# exception matched so you can check the message, attributes, etc.
#
# +exp+ takes an optional message on the end to help explain
# failures and defaults to StandardError if no exception class is
# passed.
def assert_raises *exp
msg = "#{exp.pop}.\n" if String === exp.last
exp << StandardError if exp.empty?
begin
yield
rescue *exp => e
pass # count assertion
return e
rescue Minitest::Skip, Minitest::Assertion
# don't count assertion
raise
rescue SignalException, SystemExit
raise
rescue Exception => e
flunk proc {
exception_details(e, "#{msg}#{mu_pp(exp)} exception expected, not")
}
end
exp = exp.first if exp.size == 1
flunk "#{msg}#{mu_pp(exp)} expected but nothing was raised."
end
##
# Fails unless +obj+ responds to +meth+.
def assert_respond_to obj, meth, msg = nil
msg = message(msg) {
"Expected #{mu_pp(obj)} (#{obj.class}) to respond to ##{meth}"
}
assert obj.respond_to?(meth), msg
end
##
# Fails unless +exp+ and +act+ are #equal?
def assert_same exp, act, msg = nil
msg = message(msg) {
data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
"Expected %s (oid=%d) to be the same as %s (oid=%d)" % data
}
assert exp.equal?(act), msg
end
##
# +send_ary+ is a receiver, message and arguments.
#
# Fails unless the call returns a true value
def assert_send send_ary, m = nil
where = Minitest.filter_backtrace(caller).first
where = where.split(/:in /, 2).first # clean up noise
warn "DEPRECATED: assert_send. From #{where}"
recv, msg, *args = send_ary
m = message(m) {
"Expected #{mu_pp(recv)}.#{msg}(*#{mu_pp(args)}) to return true" }
assert recv.__send__(msg, *args), m
end
##
# Fails if the block outputs anything to stderr or stdout.
#
# See also: #assert_output
def assert_silent
assert_output "", "" do
yield
end
end
##
# Fails unless the block throws +sym+
def assert_throws sym, msg = nil
default = "Expected #{mu_pp(sym)} to have been thrown"
caught = true
catch(sym) do
begin
yield
rescue ThreadError => e # wtf?!? 1.8 + threads == suck
default += ", not \:#{e.message[/uncaught throw \`(\w+?)\'/, 1]}"
rescue ArgumentError => e # 1.9 exception
raise e unless e.message.include?("uncaught throw")
default += ", not #{e.message.split(/ /).last}"
rescue NameError => e # 1.8 exception
raise e unless e.name == sym
default += ", not #{e.name.inspect}"
end
caught = false
end
assert caught, message(msg) { default }
end
##
# Captures $stdout and $stderr into strings:
#
# out, err = capture_io do
# puts "Some info"
# warn "You did a bad thing"
# end
#
# assert_match %r%info%, out
# assert_match %r%bad%, err
#
# NOTE: For efficiency, this method uses StringIO and does not
# capture IO for subprocesses. Use #capture_subprocess_io for
# that.
def capture_io
_synchronize do
begin
captured_stdout, captured_stderr = StringIO.new, StringIO.new
orig_stdout, orig_stderr = $stdout, $stderr
$stdout, $stderr = captured_stdout, captured_stderr
yield
return captured_stdout.string, captured_stderr.string
ensure
$stdout = orig_stdout
$stderr = orig_stderr
end
end
end
##
# Captures $stdout and $stderr into strings, using Tempfile to
# ensure that subprocess IO is captured as well.
#
# out, err = capture_subprocess_io do
# system "echo Some info"
# system "echo You did a bad thing 1>&2"
# end
#
# assert_match %r%info%, out
# assert_match %r%bad%, err
#
# NOTE: This method is approximately 10x slower than #capture_io so
# only use it when you need to test the output of a subprocess.
def capture_subprocess_io
_synchronize do
begin
require "tempfile"
captured_stdout, captured_stderr = Tempfile.new("out"), Tempfile.new("err")
orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
$stdout.reopen captured_stdout
$stderr.reopen captured_stderr
yield
$stdout.rewind
$stderr.rewind
return captured_stdout.read, captured_stderr.read
ensure
captured_stdout.unlink
captured_stderr.unlink
$stdout.reopen orig_stdout
$stderr.reopen orig_stderr
end
end
end
##
# Returns details for exception +e+
def exception_details e, msg
[
"#{msg}",
"Class: <#{e.class}>",
"Message: <#{e.message.inspect}>",
"---Backtrace---",
"#{Minitest.filter_backtrace(e.backtrace).join("\n")}",
"---------------",
].join "\n"
end
##
# Fails with +msg+
def flunk msg = nil
msg ||= "Epic Fail!"
assert false, msg
end
##
# Returns a proc that will output +msg+ along with the default message.
def message msg = nil, ending = nil, &default
proc {
msg = msg.call.chomp(".") if Proc === msg
custom_message = "#{msg}.\n" unless msg.nil? or msg.to_s.empty?
"#{custom_message}#{default.call}#{ending || "."}"
}
end
##
# used for counting assertions
def pass _msg = nil
assert true
end
##
# Fails if +test+ is truthy.
def refute test, msg = nil
msg ||= message { "Expected #{mu_pp(test)} to not be truthy" }
not assert !test, msg
end
##
# Fails if +obj+ is empty.
def refute_empty obj, msg = nil
msg = message(msg) { "Expected #{mu_pp(obj)} to not be empty" }
assert_respond_to obj, :empty?
refute obj.empty?, msg
end
##
# Fails if exp == act.
#
# For floats use refute_in_delta.
def refute_equal exp, act, msg = nil
msg = message(msg) {
"Expected #{mu_pp(act)} to not be equal to #{mu_pp(exp)}"
}
refute exp == act, msg
end
##
# For comparing Floats. Fails if +exp+ is within +delta+ of +act+.
#
# refute_in_delta Math::PI, (22.0 / 7.0)
def refute_in_delta exp, act, delta = 0.001, msg = nil
n = (exp - act).abs
msg = message(msg) {
"Expected |#{exp} - #{act}| (#{n}) to not be <= #{delta}"
}
refute delta >= n, msg
end
##
# For comparing Floats. Fails if +exp+ and +act+ have a relative error
# less than +epsilon+.
def refute_in_epsilon a, b, epsilon = 0.001, msg = nil
refute_in_delta a, b, a * epsilon, msg
end
##
# Fails if +collection+ includes +obj+.
def refute_includes collection, obj, msg = nil
msg = message(msg) {
"Expected #{mu_pp(collection)} to not include #{mu_pp(obj)}"
}
assert_respond_to collection, :include?
refute collection.include?(obj), msg
end
##
# Fails if +obj+ is an instance of +cls+.
def refute_instance_of cls, obj, msg = nil
msg = message(msg) {
"Expected #{mu_pp(obj)} to not be an instance of #{cls}"
}
refute obj.instance_of?(cls), msg
end
##
# Fails if +obj+ is a kind of +cls+.
def refute_kind_of cls, obj, msg = nil
msg = message(msg) { "Expected #{mu_pp(obj)} to not be a kind of #{cls}" }
refute obj.kind_of?(cls), msg
end
##
# Fails if +matcher+ =~ +obj+.
def refute_match matcher, obj, msg = nil
msg = message(msg) { "Expected #{mu_pp matcher} to not match #{mu_pp obj}" }
assert_respond_to matcher, :"=~"
matcher = Regexp.new Regexp.escape matcher if String === matcher
refute matcher =~ obj, msg
end
##
# Fails if +obj+ is nil.
def refute_nil obj, msg = nil
msg = message(msg) { "Expected #{mu_pp(obj)} to not be nil" }
refute obj.nil?, msg
end
##
# Fails if +o1+ is not +op+ +o2+. Eg:
#
# refute_operator 1, :>, 2 #=> pass
# refute_operator 1, :<, 2 #=> fail
def refute_operator o1, op, o2 = UNDEFINED, msg = nil
return refute_predicate o1, op, msg if UNDEFINED == o2
msg = message(msg) { "Expected #{mu_pp(o1)} to not be #{op} #{mu_pp(o2)}" }
refute o1.__send__(op, o2), msg
end
##
# For testing with predicates.
#
# refute_predicate str, :empty?
#
# This is really meant for specs and is front-ended by refute_operator:
#
# str.wont_be :empty?
def refute_predicate o1, op, msg = nil
msg = message(msg) { "Expected #{mu_pp(o1)} to not be #{op}" }
refute o1.__send__(op), msg
end
##
# Fails if +obj+ responds to the message +meth+.
def refute_respond_to obj, meth, msg = nil
msg = message(msg) { "Expected #{mu_pp(obj)} to not respond to #{meth}" }
refute obj.respond_to?(meth), msg
end
##
# Fails if +exp+ is the same (by object identity) as +act+.
def refute_same exp, act, msg = nil
msg = message(msg) {
data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
"Expected %s (oid=%d) to not be the same as %s (oid=%d)" % data
}
refute exp.equal?(act), msg
end
##
# Skips the current run. If run in verbose-mode, the skipped run
# gets listed at the end of the run but doesn't cause a failure
# exit code.
def skip msg = nil, bt = caller
msg ||= "Skipped, no message given"
@skip = true
raise Minitest::Skip, msg, bt
end
##
# Was this testcase skipped? Meant for #teardown.
def skipped?
defined?(@skip) and @skip
end
end
end
minitest-5.10.3/minitest.gemspec 0000644 0000041 0000041 00000012514 13135676423 016702 0 ustar www-data www-data #########################################################
# This file has been automatically generated by gem2tgz #
#########################################################
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "minitest"
s.version = "5.10.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Ryan Davis"]
s.cert_chain = ["-----BEGIN CERTIFICATE-----\nMIIDijCCAnKgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu\nZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB\nGRYDY29tMB4XDTE2MDkyNjAxNTczNVoXDTE3MDkyNjAxNTczNVowRTETMBEGA1UE\nAwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS\nJomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda\nb9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx\ntaCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx5JxgJxUjmGa7xhcT\noOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh\nGiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt\nqhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV\ngBEfoTEGr7Zii72cx+sCAwEAAaOBhDCBgTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIE\nsDAdBgNVHQ4EFgQUR8V72Z3+v+2P9abCnL4wjx32T+EwIwYDVR0RBBwwGoEYcnlh\nbmQtcnVieUB6ZW5zcGlkZXIuY29tMCMGA1UdEgQcMBqBGHJ5YW5kLXJ1YnlAemVu\nc3BpZGVyLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEAIGzgp0aZ2W9+v96ujmBcQHoC\nbuy0iU68MVj2VlxMyfr1KPZIh1OyhU4UO4zrkREcH8ML70v9cYHNvOd9oynRHnvC\nl2tj/fD3YJ0AEkJxGrYwRWQmvMfC4bJ02bC1+rVOUIXXKp3+cUmiN4sTniof8VFo\nbo/YYP4c7erpERa+9hrqygg6WQbJlk2YRlH3JXPFjmu869i2dcbR5ZLOAeEy+axH\nE4oJcnPkJAr0rw504JGtlZtONZQblwmRJOIdXzolaE3NRGUzGVOUSptZppAKiavY\nfO6tdKQc/5RfA8oQEkg8hrxA5PQSz4TOFJGLpFvIapEk6tMruQ0bHgkhr9auXg==\n-----END CERTIFICATE-----\n"]
s.date = "2017-07-21"
s.description = "minitest provides a complete suite of testing facilities supporting\nTDD, BDD, mocking, and benchmarking.\n\n \"I had a class with Jim Weirich on testing last week and we were\n allowed to choose our testing frameworks. Kirk Haines and I were\n paired up and we cracked open the code for a few test\n frameworks...\n\n I MUST say that minitest is *very* readable / understandable\n compared to the 'other two' options we looked at. Nicely done and\n thank you for helping us keep our mental sanity.\"\n\n -- Wayne E. Seguin\n\nminitest/test is a small and incredibly fast unit testing framework.\nIt provides a rich set of assertions to make your tests clean and\nreadable.\n\nminitest/spec is a functionally complete spec engine. It hooks onto\nminitest/test and seamlessly bridges test assertions over to spec\nexpectations.\n\nminitest/benchmark is an awesome way to assert the performance of your\nalgorithms in a repeatable manner. Now you can assert that your newb\nco-worker doesn't replace your linear algorithm with an exponential\none!\n\nminitest/mock by Steven Baker, is a beautifully tiny mock (and stub)\nobject framework.\n\nminitest/pride shows pride in testing and adds coloring to your test\noutput. I guess it is an example of how to write IO pipes too. :P\n\nminitest/test is meant to have a clean implementation for language\nimplementors that need a minimal set of methods to bootstrap a working\ntest suite. For example, there is no magic involved for test-case\ndiscovery.\n\n \"Again, I can't praise enough the idea of a testing/specing\n framework that I can actually read in full in one sitting!\"\n\n -- Piotr Szotkowski\n\nComparing to rspec:\n\n rspec is a testing DSL. minitest is ruby.\n\n -- Adam Hawkins, \"Bow Before MiniTest\"\n\nminitest doesn't reinvent anything that ruby already provides, like:\nclasses, modules, inheritance, methods. This means you only have to\nlearn ruby to use minitest and all of your regular OO practices like\nextract-method refactorings still apply."
s.email = ["ryand-ruby@zenspider.com"]
s.extra_rdoc_files = ["History.rdoc", "Manifest.txt", "README.rdoc"]
s.files = [".autotest", "History.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "design_rationale.rb", "lib/hoe/minitest.rb", "lib/minitest.rb", "lib/minitest/assertions.rb", "lib/minitest/autorun.rb", "lib/minitest/benchmark.rb", "lib/minitest/expectations.rb", "lib/minitest/hell.rb", "lib/minitest/mock.rb", "lib/minitest/parallel.rb", "lib/minitest/pride.rb", "lib/minitest/pride_plugin.rb", "lib/minitest/spec.rb", "lib/minitest/test.rb", "lib/minitest/unit.rb", "test/minitest/metametameta.rb", "test/minitest/test_minitest_benchmark.rb", "test/minitest/test_minitest_mock.rb", "test/minitest/test_minitest_reporter.rb", "test/minitest/test_minitest_spec.rb", "test/minitest/test_minitest_test.rb"]
s.homepage = "https://github.com/seattlerb/minitest"
s.licenses = ["MIT"]
s.rdoc_options = ["--main", "README.rdoc"]
s.require_paths = ["lib"]
s.rubygems_version = "1.8.23"
s.summary = "minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking"
if s.respond_to? :specification_version then
s.specification_version = 4
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q, ["~> 3.16"])
s.add_development_dependency(%q, ["~> 4.0"])
else
s.add_dependency(%q, ["~> 3.16"])
s.add_dependency(%q, ["~> 4.0"])
end
else
s.add_dependency(%q, ["~> 3.16"])
s.add_dependency(%q, ["~> 4.0"])
end
end
minitest-5.10.3/test/ 0000755 0000041 0000041 00000000000 13135676423 014455 5 ustar www-data www-data minitest-5.10.3/test/minitest/ 0000755 0000041 0000041 00000000000 13135676423 016311 5 ustar www-data www-data minitest-5.10.3/test/minitest/test_minitest_mock.rb 0000444 0000041 0000041 00000024404 13135676423 022544 0 ustar www-data www-data require "minitest/autorun"
class TestMinitestMock < Minitest::Test
parallelize_me!
def setup
@mock = Minitest::Mock.new.expect(:foo, nil)
@mock.expect(:meaning_of_life, 42)
end
def test_create_stub_method
assert_nil @mock.foo
end
def test_allow_return_value_specification
assert_equal 42, @mock.meaning_of_life
end
def test_blow_up_if_not_called
@mock.foo
util_verify_bad "expected meaning_of_life() => 42"
end
def test_not_blow_up_if_everything_called
@mock.foo
@mock.meaning_of_life
assert_mock @mock
end
def test_allow_expectations_to_be_added_after_creation
@mock.expect(:bar, true)
assert @mock.bar
end
def test_not_verify_if_new_expected_method_is_not_called
@mock.foo
@mock.meaning_of_life
@mock.expect(:bar, true)
util_verify_bad "expected bar() => true"
end
def test_blow_up_on_wrong_number_of_arguments
@mock.foo
@mock.meaning_of_life
@mock.expect(:sum, 3, [1, 2])
e = assert_raises ArgumentError do
@mock.sum
end
assert_equal "mocked method :sum expects 2 arguments, got 0", e.message
end
def test_return_mock_does_not_raise
retval = Minitest::Mock.new
mock = Minitest::Mock.new
mock.expect(:foo, retval)
mock.foo
assert_mock mock
end
def test_mock_args_does_not_raise
skip "non-opaque use of ==" if maglev?
arg = Minitest::Mock.new
mock = Minitest::Mock.new
mock.expect(:foo, nil, [arg])
mock.foo(arg)
assert_mock mock
end
def test_set_expectation_on_special_methods
mock = Minitest::Mock.new
mock.expect :object_id, "received object_id"
assert_equal "received object_id", mock.object_id
mock.expect :respond_to_missing?, "received respond_to_missing?"
assert_equal "received respond_to_missing?", mock.respond_to_missing?
mock.expect :===, "received ==="
assert_equal "received ===", mock.===
mock.expect :inspect, "received inspect"
assert_equal "received inspect", mock.inspect
mock.expect :to_s, "received to_s"
assert_equal "received to_s", mock.to_s
mock.expect :public_send, "received public_send"
assert_equal "received public_send", mock.public_send
mock.expect :send, "received send"
assert_equal "received send", mock.send
assert_mock mock
end
def test_expectations_can_be_satisfied_via_send
@mock.send :foo
@mock.send :meaning_of_life
assert_mock @mock
end
def test_expectations_can_be_satisfied_via_public_send
skip "Doesn't run on 1.8" if RUBY_VERSION < "1.9"
@mock.public_send :foo
@mock.public_send :meaning_of_life
assert_mock @mock
end
def test_blow_up_on_wrong_arguments
@mock.foo
@mock.meaning_of_life
@mock.expect(:sum, 3, [1, 2])
e = assert_raises MockExpectationError do
@mock.sum(2, 4)
end
exp = "mocked method :sum called with unexpected arguments [2, 4]"
assert_equal exp, e.message
end
def test_expect_with_non_array_args
e = assert_raises ArgumentError do
@mock.expect :blah, 3, false
end
assert_equal "args must be an array", e.message
end
def test_respond_appropriately
assert @mock.respond_to?(:foo)
assert @mock.respond_to?(:foo, true)
assert @mock.respond_to?("foo")
assert !@mock.respond_to?(:bar)
end
def test_no_method_error_on_unexpected_methods
e = assert_raises NoMethodError do
@mock.bar
end
expected = "unmocked method :bar, expected one of [:foo, :meaning_of_life]"
assert_equal expected, e.message
end
def test_assign_per_mock_return_values
a = Minitest::Mock.new
b = Minitest::Mock.new
a.expect(:foo, :a)
b.expect(:foo, :b)
assert_equal :a, a.foo
assert_equal :b, b.foo
end
def test_do_not_create_stub_method_on_new_mocks
a = Minitest::Mock.new
a.expect(:foo, :a)
assert !Minitest::Mock.new.respond_to?(:foo)
end
def test_mock_is_a_blank_slate
@mock.expect :kind_of?, true, [String]
@mock.expect :==, true, [1]
assert @mock.kind_of?(String), "didn't mock :kind_of\?"
assert @mock == 1, "didn't mock :=="
end
def test_verify_allows_called_args_to_be_loosely_specified
mock = Minitest::Mock.new
mock.expect :loose_expectation, true, [Integer]
mock.loose_expectation 1
assert_mock mock
end
def test_verify_raises_with_strict_args
mock = Minitest::Mock.new
mock.expect :strict_expectation, true, [2]
e = assert_raises MockExpectationError do
mock.strict_expectation 1
end
exp = "mocked method :strict_expectation called with unexpected arguments [1]"
assert_equal exp, e.message
end
def test_method_missing_empty
mock = Minitest::Mock.new
mock.expect :a, nil
mock.a
e = assert_raises MockExpectationError do
mock.a
end
assert_equal "No more expects available for :a: []", e.message
end
def test_same_method_expects_are_verified_when_all_called
mock = Minitest::Mock.new
mock.expect :foo, nil, [:bar]
mock.expect :foo, nil, [:baz]
mock.foo :bar
mock.foo :baz
assert_mock mock
end
def test_same_method_expects_blow_up_when_not_all_called
mock = Minitest::Mock.new
mock.expect :foo, nil, [:bar]
mock.expect :foo, nil, [:baz]
mock.foo :bar
e = assert_raises(MockExpectationError) { mock.verify }
exp = "expected foo(:baz) => nil, got [foo(:bar) => nil]"
assert_equal exp, e.message
end
def test_same_method_expects_with_same_args_blow_up_when_not_all_called
mock = Minitest::Mock.new
mock.expect :foo, nil, [:bar]
mock.expect :foo, nil, [:bar]
mock.foo :bar
e = assert_raises(MockExpectationError) { mock.verify }
exp = "expected foo(:bar) => nil, got [foo(:bar) => nil]"
assert_equal exp, e.message
end
def test_verify_passes_when_mock_block_returns_true
mock = Minitest::Mock.new
mock.expect :foo, nil do
true
end
mock.foo
assert_mock mock
end
def test_mock_block_is_passed_function_params
arg1, arg2, arg3 = :bar, [1, 2, 3], { :a => "a" }
mock = Minitest::Mock.new
mock.expect :foo, nil do |a1, a2, a3|
a1 == arg1 && a2 == arg2 && a3 == arg3
end
mock.foo arg1, arg2, arg3
assert_mock mock
end
def test_mock_block_is_passed_function_block
mock = Minitest::Mock.new
block = proc { "bar" }
mock.expect :foo, nil do |arg, &blk|
arg == "foo" &&
blk == block
end
mock.foo "foo", &block
assert_mock mock
end
def test_verify_fails_when_mock_block_returns_false
mock = Minitest::Mock.new
mock.expect :foo, nil do
false
end
e = assert_raises(MockExpectationError) { mock.foo }
exp = "mocked method :foo failed block w/ []"
assert_equal exp, e.message
end
def test_mock_block_throws_if_args_passed
mock = Minitest::Mock.new
e = assert_raises(ArgumentError) do
mock.expect :foo, nil, [:a, :b, :c] do
true
end
end
exp = "args ignored when block given"
assert_equal exp, e.message
end
def test_mock_returns_retval_when_called_with_block
mock = Minitest::Mock.new
mock.expect(:foo, 32) do
true
end
rs = mock.foo
assert_equal rs, 32
end
def util_verify_bad exp
e = assert_raises MockExpectationError do
@mock.verify
end
assert_equal exp, e.message
end
def test_mock_called_via_send
mock = Minitest::Mock.new
mock.expect(:foo, true)
mock.send :foo
assert_mock mock
end
def test_mock_called_via___send__
mock = Minitest::Mock.new
mock.expect(:foo, true)
mock.__send__ :foo
assert_mock mock
end
def test_mock_called_via_send_with_args
mock = Minitest::Mock.new
mock.expect(:foo, true, [1, 2, 3])
mock.send(:foo, 1, 2, 3)
assert_mock mock
end
end
require "minitest/metametameta"
class TestMinitestStub < Minitest::Test
parallelize_me!
def setup
super
Minitest::Test.reset
@tc = Minitest::Test.new "fake tc"
@assertion_count = 1
end
def teardown
super
assert_equal @assertion_count, @tc.assertions
end
class Time
def self.now
24
end
end
def assert_stub val_or_callable
@assertion_count += 1
t = Time.now.to_i
Time.stub :now, val_or_callable do
@tc.assert_equal 42, Time.now
end
@tc.assert_operator Time.now.to_i, :>=, t
end
def test_stub_private_module_method
@assertion_count += 1
t0 = Time.now
self.stub :sleep, nil do
@tc.assert_nil sleep(10)
end
@tc.assert_operator Time.now - t0, :<=, 1
end
def test_stub_private_module_method_indirect
@assertion_count += 1
fail_clapper = Class.new do
def fail_clap
raise
:clap
end
end.new
fail_clapper.stub :raise, nil do |safe_clapper|
@tc.assert_equal :clap, safe_clapper.fail_clap # either form works
@tc.assert_equal :clap, fail_clapper.fail_clap # yay closures
end
end
def test_stub_public_module_method
Math.stub :log10, :stubbed do
@tc.assert_equal :stubbed, Math.log10(1000)
end
end
def test_stub_value
assert_stub 42
end
def test_stub_block
assert_stub lambda { 42 }
end
def test_stub_block_args
@assertion_count += 1
t = Time.now.to_i
Time.stub :now, lambda { |n| n * 2 } do
@tc.assert_equal 42, Time.now(21)
end
@tc.assert_operator Time.now.to_i, :>=, t
end
def test_stub_callable
obj = Object.new
def obj.call
42
end
assert_stub obj
end
def test_stub_yield_self
obj = "foo"
val = obj.stub :to_s, "bar" do |s|
s.to_s
end
@tc.assert_equal "bar", val
end
def test_dynamic_method
@assertion_count = 2
dynamic = Class.new do
def self.respond_to? meth
meth == :found
end
def self.method_missing meth, *args, &block
if meth == :found
false
else
super
end
end
end
val = dynamic.stub(:found, true) do |s|
s.found
end
@tc.assert_equal true, val
@tc.assert_equal false, dynamic.found
end
def test_mock_with_yield
mock = Minitest::Mock.new
mock.expect(:write, true) do
true
end
rs = nil
File.stub :open, true, mock do
File.open "foo.txt", "r" do |f|
rs = f.write
end
end
@tc.assert_equal true, rs
end
end
minitest-5.10.3/test/minitest/metametameta.rb 0000444 0000041 0000041 00000004201 13135676423 021275 0 ustar www-data www-data require "tempfile"
require "stringio"
require "minitest/autorun"
class Minitest::Test
def clean s
s.gsub(/^ {6}/, "")
end
end
class FakeNamedTest < Minitest::Test
@@count = 0
def self.name
@fake_name ||= begin
@@count += 1
"FakeNamedTest%02d" % @@count
end
end
end
class MetaMetaMetaTestCase < Minitest::Test
attr_accessor :reporter, :output, :tu
def run_tu_with_fresh_reporter flags = %w[--seed 42]
options = Minitest.process_args flags
@output = StringIO.new("".encode('UTF-8'))
self.reporter = Minitest::CompositeReporter.new
reporter << Minitest::SummaryReporter.new(@output, options)
reporter << Minitest::ProgressReporter.new(@output, options)
reporter.start
yield(reporter) if block_given?
@tus ||= [@tu]
@tus.each do |tu|
Minitest::Runnable.runnables.delete tu
tu.run reporter, options
end
reporter.report
end
def first_reporter
reporter.reporters.first
end
def assert_report expected, flags = %w[--seed 42], &block
header = clean <<-EOM
Run options: #{flags.map { |s| s =~ /\|/ ? s.inspect : s }.join " "}
# Running:
EOM
run_tu_with_fresh_reporter flags, &block
output = normalize_output @output.string.dup
assert_equal header + expected, output
end
def normalize_output output
output.sub!(/Finished in .*/, "Finished in 0.00")
output.sub!(/Loaded suite .*/, "Loaded suite blah")
output.gsub!(/ = \d+.\d\d s = /, " = 0.00 s = ")
output.gsub!(/0x[A-Fa-f0-9]+/, "0xXXX")
output.gsub!(/ +$/, "")
if windows? then
output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, "[FILE:LINE]")
output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in/, '\1FILE:LINE:in')
else
output.gsub!(/\[[^\]:]+:\d+\]/, "[FILE:LINE]")
output.gsub!(/^(\s+)[^:]+:\d+:in/, '\1FILE:LINE:in')
end
output
end
def restore_env
old_value = ENV["MT_NO_SKIP_MSG"]
ENV.delete "MT_NO_SKIP_MSG"
yield
ensure
ENV["MT_NO_SKIP_MSG"] = old_value
end
def setup
super
srand 42
Minitest::Test.reset
@tu = nil
end
end
minitest-5.10.3/test/minitest/test_minitest_benchmark.rb 0000444 0000041 0000041 00000006577 13135676423 023560 0 ustar www-data www-data require "minitest/autorun"
require "minitest/benchmark"
##
# Used to verify data:
# http://www.wolframalpha.com/examples/RegressionAnalysis.html
class TestMinitestBenchmark < Minitest::Test
def test_cls_bench_exp
assert_equal [2, 4, 8, 16, 32], Minitest::Benchmark.bench_exp(2, 32, 2)
end
def test_cls_bench_linear
assert_equal [2, 4, 6, 8, 10], Minitest::Benchmark.bench_linear(2, 10, 2)
end
def test_cls_runnable_methods
assert_equal [], Minitest::Benchmark.runnable_methods
c = Class.new(Minitest::Benchmark) do
def bench_blah
end
end
assert_equal ["bench_blah"], c.runnable_methods
end
def test_cls_bench_range
assert_equal [1, 10, 100, 1_000, 10_000], Minitest::Benchmark.bench_range
end
def test_fit_exponential_clean
x = [1.0, 2.0, 3.0, 4.0, 5.0]
y = x.map { |n| 1.1 * Math.exp(2.1 * n) }
assert_fit :exponential, x, y, 1.0, 1.1, 2.1
end
def test_fit_exponential_noisy
x = [1.0, 1.9, 2.6, 3.4, 5.0]
y = [12, 10, 8.2, 6.9, 5.9]
# verified with Numbers and R
assert_fit :exponential, x, y, 0.95, 13.81148, -0.1820
end
def test_fit_logarithmic_clean
x = [1.0, 2.0, 3.0, 4.0, 5.0]
y = x.map { |n| 1.1 + 2.1 * Math.log(n) }
assert_fit :logarithmic, x, y, 1.0, 1.1, 2.1
end
def test_fit_logarithmic_noisy
x = [1.0, 2.0, 3.0, 4.0, 5.0]
# Generated with
# y = x.map { |n| jitter = 0.999 + 0.002 * rand; (Math.log(n) ) * jitter }
y = [0.0, 0.6935, 1.0995, 1.3873, 1.6097]
assert_fit :logarithmic, x, y, 0.95, 0, 1
end
def test_fit_constant_clean
x = (1..5).to_a
y = [5.0, 5.0, 5.0, 5.0, 5.0]
assert_fit :linear, x, y, nil, 5.0, 0
end
def test_fit_constant_noisy
x = (1..5).to_a
y = [1.0, 1.2, 1.0, 0.8, 1.0]
# verified in numbers and R
assert_fit :linear, x, y, nil, 1.12, -0.04
end
def test_fit_linear_clean
# y = m * x + b where m = 2.2, b = 3.1
x = (1..5).to_a
y = x.map { |n| 2.2 * n + 3.1 }
assert_fit :linear, x, y, 1.0, 3.1, 2.2
end
def test_fit_linear_noisy
x = [ 60, 61, 62, 63, 65]
y = [3.1, 3.6, 3.8, 4.0, 4.1]
# verified in numbers and R
assert_fit :linear, x, y, 0.8315, -7.9635, 0.1878
end
def test_fit_power_clean
# y = A x ** B, where B = b and A = e ** a
# if, A = 1, B = 2, then
x = [1.0, 2.0, 3.0, 4.0, 5.0]
y = [1.0, 4.0, 9.0, 16.0, 25.0]
assert_fit :power, x, y, 1.0, 1.0, 2.0
end
def test_fit_power_noisy
# from www.engr.uidaho.edu/thompson/courses/ME330/lecture/least_squares.html
x = [10, 12, 15, 17, 20, 22, 25, 27, 30, 32, 35]
y = [95, 105, 125, 141, 173, 200, 253, 298, 385, 459, 602]
# verified in numbers
assert_fit :power, x, y, 0.90, 2.6217, 1.4556
# income to % of households below income amount
# http://library.wolfram.com/infocenter/Conferences/6461/PowerLaws.nb
x = [15_000, 25_000, 35_000, 50_000, 75_000, 100_000]
y = [0.154, 0.283, 0.402, 0.55, 0.733, 0.843]
# verified in numbers
assert_fit :power, x, y, 0.96, 3.119e-5, 0.8959
end
def assert_fit msg, x, y, fit, exp_a, exp_b
bench = Minitest::Benchmark.new :blah
a, b, rr = bench.send "fit_#{msg}", x, y
assert_operator rr, :>=, fit if fit
assert_in_delta exp_a, a
assert_in_delta exp_b, b
end
end
describe "my class Bench" do
klass = self
it "should provide bench methods" do
klass.must_respond_to :bench
end
end
minitest-5.10.3/test/minitest/test_minitest_spec.rb 0000444 0000041 0000041 00000062220 13135676423 022543 0 ustar www-data www-data # encoding: utf-8
require "minitest/autorun"
require "stringio"
class MiniSpecA < Minitest::Spec; end
class MiniSpecB < Minitest::Test; extend Minitest::Spec::DSL; end
class MiniSpecC < MiniSpecB; end
class NamedExampleA < MiniSpecA; end
class NamedExampleB < MiniSpecB; end
class NamedExampleC < MiniSpecC; end
class ExampleA; end
class ExampleB < ExampleA; end
describe Minitest::Spec do
# helps to deal with 2.4 deprecation of Fixnum for Integer
Int = 1.class
# do not parallelize this suite... it just can"t handle it.
def assert_triggered expected = "blah", klass = Minitest::Assertion
@assertion_count += 1
e = assert_raises(klass) do
yield
end
msg = e.message.sub(/(---Backtrace---).*/m, '\1')
msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
msg.gsub!(/@.+>/, "@PATH>")
msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
msg.gsub!(/:0x[a-fA-F0-9]{4,}/m, ":0xXXXXXX")
if expected
@assertion_count += 1
case expected
when String then
assert_equal expected, msg
when Regexp then
@assertion_count += 1
assert_match expected, msg
else
flunk "Unknown: #{expected.inspect}"
end
end
end
before do
@assertion_count = 4
end
after do
_(self.assertions).must_equal @assertion_count if passed? and not skipped?
end
it "needs to be able to catch a Minitest::Assertion exception" do
@assertion_count = 1
assert_triggered "Expected 1 to not be equal to 1." do
1.wont_equal 1
end
end
it "needs to be sensible about must_include order" do
@assertion_count += 3 # must_include is 2 assertions
[1, 2, 3].must_include(2).must_equal true
assert_triggered "Expected [1, 2, 3] to include 5." do
[1, 2, 3].must_include 5
end
assert_triggered "msg.\nExpected [1, 2, 3] to include 5." do
[1, 2, 3].must_include 5, "msg"
end
end
it "needs to be sensible about wont_include order" do
@assertion_count += 3 # wont_include is 2 assertions
[1, 2, 3].wont_include(5).must_equal false
assert_triggered "Expected [1, 2, 3] to not include 2." do
[1, 2, 3].wont_include 2
end
assert_triggered "msg.\nExpected [1, 2, 3] to not include 2." do
[1, 2, 3].wont_include 2, "msg"
end
end
it "needs to catch an expected exception" do
@assertion_count = 2
proc { raise "blah" }.must_raise RuntimeError
proc { raise Minitest::Assertion }.must_raise Minitest::Assertion
end
it "needs to catch an unexpected exception" do
@assertion_count -= 2 # no positive
msg = <<-EOM.gsub(/^ {6}/, "").chomp
[RuntimeError] exception expected, not
Class:
Message: <"woot">
---Backtrace---
EOM
assert_triggered msg do
proc { raise StandardError, "woot" }.must_raise RuntimeError
end
assert_triggered "msg.\n#{msg}" do
proc { raise StandardError, "woot" }.must_raise RuntimeError, "msg"
end
end
it "needs to ensure silence" do
@assertion_count -= 1 # no msg
@assertion_count += 2 # assert_output is 2 assertions
proc {}.must_be_silent.must_equal true
assert_triggered "In stdout.\nExpected: \"\"\n Actual: \"xxx\"" do
proc { print "xxx" }.must_be_silent
end
end
it "needs to have all methods named well" do
@assertion_count = 2
methods = Object.public_instance_methods.find_all { |n| n =~ /^must|^wont/ }
methods.map!(&:to_s) if Symbol === methods.first
musts, wonts = methods.sort.partition { |m| m =~ /^must/ }
expected_musts = %w[must_be
must_be_close_to
must_be_empty
must_be_instance_of
must_be_kind_of
must_be_nil
must_be_same_as
must_be_silent
must_be_within_delta
must_be_within_epsilon
must_equal
must_include
must_match
must_output
must_raise
must_respond_to
must_throw]
bad = %w[not raise throw send output be_silent]
expected_wonts = expected_musts.map { |m| m.sub(/^must/, "wont") }
expected_wonts.reject! { |m| m =~ /wont_#{Regexp.union(*bad)}/ }
musts.must_equal expected_musts
wonts.must_equal expected_wonts
end
it "needs to raise if an expected exception is not raised" do
@assertion_count -= 2 # no positive test
assert_triggered "RuntimeError expected but nothing was raised." do
proc { 42 }.must_raise RuntimeError
end
assert_triggered "msg.\nRuntimeError expected but nothing was raised." do
proc { 42 }.must_raise RuntimeError, "msg"
end
end
it "needs to verify binary messages" do
42.wont_be(:<, 24).must_equal false
assert_triggered "Expected 24 to not be < 42." do
24.wont_be :<, 42
end
assert_triggered "msg.\nExpected 24 to not be < 42." do
24.wont_be :<, 42, "msg"
end
end
it "needs to verify emptyness" do
@assertion_count += 3 # empty is 2 assertions
[].must_be_empty.must_equal true
assert_triggered "Expected [42] to be empty." do
[42].must_be_empty
end
assert_triggered "msg.\nExpected [42] to be empty." do
[42].must_be_empty "msg"
end
end
it "needs to verify equality" do
@assertion_count += 1
(6 * 7).must_equal(42).must_equal true
assert_triggered "Expected: 42\n Actual: 54" do
(6 * 9).must_equal 42
end
assert_triggered "msg.\nExpected: 42\n Actual: 54" do
(6 * 9).must_equal 42, "msg"
end
assert_triggered(/^-42\n\+#\n/) do
proc { 42 }.must_equal 42 # proc isn't called, so expectation fails
end
end
it "needs to warn on equality with nil" do
@assertion_count += 1 # extra test
out, err = capture_io do
nil.must_equal(nil).must_equal true
end
exp = "DEPRECATED: Use assert_nil if expecting nil from #{__FILE__}:#{__LINE__-3}. " \
"This will fail in Minitest 6.\n"
exp = "" if $-w.nil?
assert_empty out
assert_equal exp, err
end
it "needs to verify floats outside a delta" do
@assertion_count += 1 # extra test
24.wont_be_close_to(42).must_equal false
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 0.001." do
(6 * 7.0).wont_be_close_to 42
end
x = maglev? ? "1.0000000000000001e-05" : "1.0e-05"
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
(6 * 7.0).wont_be_close_to 42, 0.00001
end
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= #{x}." do
(6 * 7.0).wont_be_close_to 42, 0.00001, "msg"
end
end
it "needs to verify floats outside an epsilon" do
@assertion_count += 1 # extra test
24.wont_be_within_epsilon(42).must_equal false
x = maglev? ? "0.042000000000000003" : "0.042"
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
(6 * 7.0).wont_be_within_epsilon 42
end
x = maglev? ? "0.00042000000000000002" : "0.00042"
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
(6 * 7.0).wont_be_within_epsilon 42, 0.00001
end
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= #{x}." do
(6 * 7.0).wont_be_within_epsilon 42, 0.00001, "msg"
end
end
it "needs to verify floats within a delta" do
@assertion_count += 1 # extra test
(6.0 * 7).must_be_close_to(42.0).must_equal true
assert_triggered "Expected |0.0 - 0.01| (0.01) to be <= 0.001." do
(1.0 / 100).must_be_close_to 0.0
end
x = maglev? ? "9.9999999999999995e-07" : "1.0e-06"
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
(1.0 / 1000).must_be_close_to 0.0, 0.000001
end
assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be <= #{x}." do
(1.0 / 1000).must_be_close_to 0.0, 0.000001, "msg"
end
end
it "needs to verify floats within an epsilon" do
@assertion_count += 1 # extra test
(6.0 * 7).must_be_within_epsilon(42.0).must_equal true
assert_triggered "Expected |0.0 - 0.01| (0.01) to be <= 0.0." do
(1.0 / 100).must_be_within_epsilon 0.0
end
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= 0.0." do
(1.0 / 1000).must_be_within_epsilon 0.0, 0.000001
end
assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be <= 0.0." do
(1.0 / 1000).must_be_within_epsilon 0.0, 0.000001, "msg"
end
end
it "needs to verify identity" do
1.must_be_same_as(1).must_equal true
assert_triggered "Expected 1 (oid=N) to be the same as 2 (oid=N)." do
1.must_be_same_as 2
end
assert_triggered "msg.\nExpected 1 (oid=N) to be the same as 2 (oid=N)." do
1.must_be_same_as 2, "msg"
end
end
it "needs to verify inequality" do
@assertion_count += 2
42.wont_equal(6 * 9).must_equal false
proc {}.wont_equal(42).must_equal false
assert_triggered "Expected 1 to not be equal to 1." do
1.wont_equal 1
end
assert_triggered "msg.\nExpected 1 to not be equal to 1." do
1.wont_equal 1, "msg"
end
end
it "needs to verify instances of a class" do
42.wont_be_instance_of(String).must_equal false
assert_triggered "Expected 42 to not be a kind of #{Int.name}." do
42.wont_be_kind_of Int
end
assert_triggered "msg.\nExpected 42 to not be an instance of #{Int.name}." do
42.wont_be_instance_of Int, "msg"
end
end
it "needs to verify kinds of a class" do
@assertion_count += 2
42.wont_be_kind_of(String).must_equal false
proc {}.wont_be_kind_of(String).must_equal false
assert_triggered "Expected 42 to not be a kind of #{Int.name}." do
42.wont_be_kind_of Int
end
assert_triggered "msg.\nExpected 42 to not be a kind of #{Int.name}." do
42.wont_be_kind_of Int, "msg"
end
end
it "needs to verify kinds of objects" do
@assertion_count += 3 # extra test
(6 * 7).must_be_kind_of(Int).must_equal true
(6 * 7).must_be_kind_of(Numeric).must_equal true
assert_triggered "Expected 42 to be a kind of String, not #{Int.name}." do
(6 * 7).must_be_kind_of String
end
assert_triggered "msg.\nExpected 42 to be a kind of String, not #{Int.name}." do
(6 * 7).must_be_kind_of String, "msg"
end
exp = "Expected # to be a kind of String, not Proc."
assert_triggered exp do
proc {}.must_be_kind_of String
end
end
it "needs to verify mismatch" do
@assertion_count += 3 # match is 2
"blah".wont_match(/\d+/).must_equal false
assert_triggered "Expected /\\w+/ to not match \"blah\"." do
"blah".wont_match(/\w+/)
end
assert_triggered "msg.\nExpected /\\w+/ to not match \"blah\"." do
"blah".wont_match(/\w+/, "msg")
end
end
it "needs to verify nil" do
nil.must_be_nil.must_equal true
assert_triggered "Expected 42 to be nil." do
42.must_be_nil
end
assert_triggered "msg.\nExpected 42 to be nil." do
42.must_be_nil "msg"
end
end
it "needs to verify non-emptyness" do
@assertion_count += 3 # empty is 2 assertions
["some item"].wont_be_empty.must_equal false
assert_triggered "Expected [] to not be empty." do
[].wont_be_empty
end
assert_triggered "msg.\nExpected [] to not be empty." do
[].wont_be_empty "msg"
end
end
it "needs to verify non-identity" do
1.wont_be_same_as(2).must_equal false
assert_triggered "Expected 1 (oid=N) to not be the same as 1 (oid=N)." do
1.wont_be_same_as 1
end
assert_triggered "msg.\nExpected 1 (oid=N) to not be the same as 1 (oid=N)." do
1.wont_be_same_as 1, "msg"
end
end
it "needs to verify non-nil" do
42.wont_be_nil.must_equal false
assert_triggered "Expected nil to not be nil." do
nil.wont_be_nil
end
assert_triggered "msg.\nExpected nil to not be nil." do
nil.wont_be_nil "msg"
end
end
it "needs to verify objects not responding to a message" do
"".wont_respond_to(:woot!).must_equal false
assert_triggered "Expected \"\" to not respond to to_s." do
"".wont_respond_to :to_s
end
assert_triggered "msg.\nExpected \"\" to not respond to to_s." do
"".wont_respond_to :to_s, "msg"
end
end
it "needs to verify output in stderr" do
@assertion_count -= 1 # no msg
proc { $stderr.print "blah" }.must_output(nil, "blah").must_equal true
assert_triggered "In stderr.\nExpected: \"blah\"\n Actual: \"xxx\"" do
proc { $stderr.print "xxx" }.must_output(nil, "blah")
end
end
it "needs to verify output in stdout" do
@assertion_count -= 1 # no msg
proc { print "blah" }.must_output("blah").must_equal true
assert_triggered "In stdout.\nExpected: \"blah\"\n Actual: \"xxx\"" do
proc { print "xxx" }.must_output("blah")
end
end
it "needs to verify regexp matches" do
@assertion_count += 3 # must_match is 2 assertions
"blah".must_match(/\w+/).must_equal true
assert_triggered "Expected /\\d+/ to match \"blah\"." do
"blah".must_match(/\d+/)
end
assert_triggered "msg.\nExpected /\\d+/ to match \"blah\"." do
"blah".must_match(/\d+/, "msg")
end
end
describe "expect" do
before do
@assertion_count -= 3
end
it "can use expect" do
_(1 + 1).must_equal 2
end
it "can use expect with a lambda" do
_ { raise "blah" }.must_raise RuntimeError
end
it "can use expect in a thread" do
Thread.new { _(1 + 1).must_equal 2 }.join
end
it "can NOT use must_equal in a thread. It must use expect in a thread" do
assert_raises NoMethodError do
Thread.new { (1 + 1).must_equal 2 }.join
end
end
end
it "needs to verify throw" do
@assertion_count += 2 # 2 extra tests
proc { throw :blah }.must_throw(:blah).must_equal true
assert_triggered "Expected :blah to have been thrown." do
proc {}.must_throw :blah
end
assert_triggered "Expected :blah to have been thrown, not :xxx." do
proc { throw :xxx }.must_throw :blah
end
assert_triggered "msg.\nExpected :blah to have been thrown." do
proc {}.must_throw :blah, "msg"
end
assert_triggered "msg.\nExpected :blah to have been thrown, not :xxx." do
proc { throw :xxx }.must_throw :blah, "msg"
end
end
it "needs to verify types of objects" do
(6 * 7).must_be_instance_of(Int).must_equal true
exp = "Expected 42 to be an instance of String, not #{Int.name}."
assert_triggered exp do
(6 * 7).must_be_instance_of String
end
assert_triggered "msg.\n#{exp}" do
(6 * 7).must_be_instance_of String, "msg"
end
end
it "needs to verify using any (negative) predicate" do
@assertion_count -= 1 # doesn"t take a message
"blah".wont_be(:empty?).must_equal false
assert_triggered "Expected \"\" to not be empty?." do
"".wont_be :empty?
end
end
it "needs to verify using any binary operator" do
@assertion_count -= 1 # no msg
41.must_be(:<, 42).must_equal true
assert_triggered "Expected 42 to be < 41." do
42.must_be(:<, 41)
end
end
it "needs to verify using any predicate" do
@assertion_count -= 1 # no msg
"".must_be(:empty?).must_equal true
assert_triggered "Expected \"blah\" to be empty?." do
"blah".must_be :empty?
end
end
it "needs to verify using respond_to" do
42.must_respond_to(:+).must_equal true
assert_triggered "Expected 42 (#{Int.name}) to respond to #clear." do
42.must_respond_to :clear
end
assert_triggered "msg.\nExpected 42 (#{Int.name}) to respond to #clear." do
42.must_respond_to :clear, "msg"
end
end
end
describe Minitest::Spec, :let do
i_suck_and_my_tests_are_order_dependent!
def _count
$let_count ||= 0
end
let :count do
$let_count += 1
$let_count
end
it "is evaluated once per example" do
_count.must_equal 0
count.must_equal 1
count.must_equal 1
_count.must_equal 1
end
it "is REALLY evaluated once per example" do
_count.must_equal 1
count.must_equal 2
count.must_equal 2
_count.must_equal 2
end
it 'raises an error if the name begins with "test"' do
proc { self.class.let(:test_value) { true } }.must_raise ArgumentError
end
it "raises an error if the name shadows a normal instance method" do
proc { self.class.let(:message) { true } }.must_raise ArgumentError
end
it "doesn't raise an error if it is just another let" do
proc do
describe :outer do
let(:bar)
describe :inner do
let(:bar)
end
end
:good
end.call.must_equal :good
end
it "procs come after dont_flip" do
p = proc {}
assert_respond_to p, :call
p.must_respond_to :call
end
end
describe Minitest::Spec, :subject do
attr_reader :subject_evaluation_count
subject do
@subject_evaluation_count ||= 0
@subject_evaluation_count += 1
@subject_evaluation_count
end
it "is evaluated once per example" do
subject.must_equal 1
subject.must_equal 1
subject_evaluation_count.must_equal 1
end
end
class TestMetaStatic < Minitest::Test
def test_children
Minitest::Spec.children.clear # prevents parallel run
y = z = nil
x = describe "top-level thingy" do
y = describe "first thingy" do end
it "top-level-it" do end
z = describe "second thingy" do end
end
assert_equal [x], Minitest::Spec.children
assert_equal [y, z], x.children
assert_equal [], y.children
assert_equal [], z.children
end
def test_it_wont_remove_existing_child_test_methods
Minitest::Spec.children.clear # prevents parallel run
inner = nil
outer = describe "outer" do
inner = describe "inner" do
it do
assert true
end
end
it do
assert true
end
end
assert_equal 1, outer.public_instance_methods.grep(/^test_/).count
assert_equal 1, inner.public_instance_methods.grep(/^test_/).count
end
def test_it_wont_add_test_methods_to_children
Minitest::Spec.children.clear # prevents parallel run
inner = nil
outer = describe "outer" do
inner = describe "inner" do end
it do
assert true
end
end
assert_equal 1, outer.public_instance_methods.grep(/^test_/).count
assert_equal 0, inner.public_instance_methods.grep(/^test_/).count
end
end
require "minitest/metametameta"
class TestMeta < MetaMetaMetaTestCase
parallelize_me!
def util_structure
y = z = nil
before_list = []
after_list = []
x = describe "top-level thingy" do
before { before_list << 1 }
after { after_list << 1 }
it "top-level-it" do end
y = describe "inner thingy" do
before { before_list << 2 }
after { after_list << 2 }
it "inner-it" do end
z = describe "very inner thingy" do
before { before_list << 3 }
after { after_list << 3 }
it "inner-it" do end
it { } # ignore me
specify { } # anonymous it
end
end
end
return x, y, z, before_list, after_list
end
def test_register_spec_type
original_types = Minitest::Spec::TYPES.dup
assert_includes Minitest::Spec::TYPES, [//, Minitest::Spec]
Minitest::Spec.register_spec_type(/woot/, TestMeta)
p = lambda do |_| true end
Minitest::Spec.register_spec_type TestMeta, &p
keys = Minitest::Spec::TYPES.map(&:first)
assert_includes keys, /woot/
assert_includes keys, p
ensure
Minitest::Spec::TYPES.replace original_types
end
def test_spec_type
original_types = Minitest::Spec::TYPES.dup
Minitest::Spec.register_spec_type(/A$/, MiniSpecA)
Minitest::Spec.register_spec_type MiniSpecB do |desc|
desc.superclass == ExampleA
end
Minitest::Spec.register_spec_type MiniSpecC do |_desc, *addl|
addl.include? :woot
end
assert_equal MiniSpecA, Minitest::Spec.spec_type(ExampleA)
assert_equal MiniSpecB, Minitest::Spec.spec_type(ExampleB)
assert_equal MiniSpecC, Minitest::Spec.spec_type(ExampleB, :woot)
ensure
Minitest::Spec::TYPES.replace original_types
end
def test_bug_dsl_expectations
spec_class = Class.new MiniSpecB do
it "should work" do
0.must_equal 0
end
end
test_name = spec_class.instance_methods.sort.grep(/test/).first
spec = spec_class.new test_name
result = spec.run
assert spec.passed?
assert result.passed?
assert_equal 1, result.assertions
end
def test_name
spec_a = describe ExampleA do; end
spec_b = describe ExampleB, :random_method do; end
spec_c = describe ExampleB, :random_method, :addl_context do; end
assert_equal "ExampleA", spec_a.name
assert_equal "ExampleB::random_method", spec_b.name
assert_equal "ExampleB::random_method::addl_context", spec_c.name
end
def test_name2
assert_equal "NamedExampleA", NamedExampleA.name
assert_equal "NamedExampleB", NamedExampleB.name
assert_equal "NamedExampleC", NamedExampleC.name
spec_a = describe ExampleA do; end
spec_b = describe ExampleB, :random_method do; end
assert_equal "ExampleA", spec_a.name
assert_equal "ExampleB::random_method", spec_b.name
end
def test_structure
x, y, z, * = util_structure
assert_equal "top-level thingy", x.to_s
assert_equal "top-level thingy::inner thingy", y.to_s
assert_equal "top-level thingy::inner thingy::very inner thingy", z.to_s
assert_equal "top-level thingy", x.desc
assert_equal "inner thingy", y.desc
assert_equal "very inner thingy", z.desc
top_methods = %w[setup teardown test_0001_top-level-it]
inner_methods1 = %w[setup teardown test_0001_inner-it]
inner_methods2 = inner_methods1 +
%w[test_0002_anonymous test_0003_anonymous]
assert_equal top_methods, x.instance_methods(false).sort.map(&:to_s)
assert_equal inner_methods1, y.instance_methods(false).sort.map(&:to_s)
assert_equal inner_methods2, z.instance_methods(false).sort.map(&:to_s)
end
def test_structure_postfix_it
z = nil
y = describe "outer" do
# NOT here, below the inner-describe!
# it "inner-it" do end
z = describe "inner" do
it "inner-it" do end
end
# defined AFTER inner describe means we'll try to wipe out the inner-it
it "inner-it" do end
end
assert_equal %w[test_0001_inner-it], y.instance_methods(false).map(&:to_s)
assert_equal %w[test_0001_inner-it], z.instance_methods(false).map(&:to_s)
end
def test_setup_teardown_behavior
_, _, z, before_list, after_list = util_structure
@tu = z
run_tu_with_fresh_reporter
size = z.runnable_methods.size
assert_equal [1, 2, 3] * size, before_list
assert_equal [3, 2, 1] * size, after_list
end
def test_describe_first_structure
x1 = x2 = y = z = nil
x = describe "top-level thingy" do
y = describe "first thingy" do end
x1 = it "top level it" do end
x2 = it "не латинские &いった α, β, γ, δ, ε hello!!! world" do end
z = describe "second thingy" do end
end
test_methods = ["test_0001_top level it",
"test_0002_не латинские &いった α, β, γ, δ, ε hello!!! world",
].sort
assert_equal test_methods, [x1, x2]
assert_equal test_methods, x.instance_methods.grep(/^test/).map(&:to_s).sort
assert_equal [], y.instance_methods.grep(/^test/)
assert_equal [], z.instance_methods.grep(/^test/)
end
def test_structure_subclasses
z = nil
x = Class.new Minitest::Spec do
def xyz; end
end
y = Class.new x do
z = describe("inner") { }
end
assert_respond_to x.new(nil), "xyz"
assert_respond_to y.new(nil), "xyz"
assert_respond_to z.new(nil), "xyz"
end
end
class TestSpecInTestCase < MetaMetaMetaTestCase
def setup
super
Thread.current[:current_spec] = self
@tc = self
@assertion_count = 2
end
def assert_triggered expected, klass = Minitest::Assertion
@assertion_count += 1
e = assert_raises klass do
yield
end
msg = e.message.sub(/(---Backtrace---).*/m, "\1")
msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
assert_equal expected, msg
end
def teardown
msg = "expected #{@assertion_count} assertions, not #{@tc.assertions}"
assert_equal @assertion_count, @tc.assertions, msg
end
def test_expectation
@tc.assert_equal true, 1.must_equal(1)
end
def test_expectation_triggered
assert_triggered "Expected: 2\n Actual: 1" do
1.must_equal 2
end
end
def test_expectation_with_a_message
assert_triggered "woot.\nExpected: 2\n Actual: 1" do
1.must_equal 2, "woot"
end
end
end
class ValueMonadTest < Minitest::Test
attr_accessor :struct
def setup
@struct = { :_ => "a", :value => "b", :expect => "c" }
def @struct.method_missing k # think openstruct
self[k]
end
end
def test_value_monad_method
assert_equal "a", struct._
end
def test_value_monad_value_alias
assert_equal "b", struct.value
end
def test_value_monad_expect_alias
assert_equal "c", struct.expect
end
end
minitest-5.10.3/test/minitest/test_minitest_reporter.rb 0000444 0000041 0000041 00000012051 13135676423 023450 0 ustar www-data www-data require "minitest/autorun"
require "minitest/metametameta"
class TestMinitestReporter < MetaMetaMetaTestCase
attr_accessor :r, :io
def new_composite_reporter
reporter = Minitest::CompositeReporter.new
reporter << Minitest::SummaryReporter.new(self.io)
reporter << Minitest::ProgressReporter.new(self.io)
def reporter.first
reporters.first
end
def reporter.results
first.results
end
def reporter.count
first.count
end
def reporter.assertions
first.assertions
end
reporter
end
def setup
self.io = StringIO.new("")
self.r = new_composite_reporter
end
def error_test
unless defined? @et then
@et = Minitest::Test.new(:woot)
@et.failures << Minitest::UnexpectedError.new(begin
raise "no"
rescue => e
e
end)
end
@et
end
def fail_test
unless defined? @ft then
@ft = Minitest::Test.new(:woot)
@ft.failures << begin
raise Minitest::Assertion, "boo"
rescue Minitest::Assertion => e
e
end
end
@ft
end
def passing_test
@pt ||= Minitest::Test.new(:woot)
end
def skip_test
unless defined? @st then
@st = Minitest::Test.new(:woot)
@st.failures << begin
raise Minitest::Skip
rescue Minitest::Assertion => e
e
end
end
@st
end
def test_to_s
r.record passing_test
r.record fail_test
assert_match "woot", r.first.to_s
end
def test_passed_eh_empty
assert r.passed?
end
def test_passed_eh_failure
r.results << fail_test
refute r.passed?
end
SKIP_MSG = "\n\nYou have skipped tests. Run with --verbose for details."
def test_passed_eh_error
r.start
r.results << error_test
refute r.passed?
r.report
refute_match SKIP_MSG, io.string
end
def test_passed_eh_skipped
r.start
r.results << skip_test
assert r.passed?
restore_env do
r.report
end
assert_match SKIP_MSG, io.string
end
def test_passed_eh_skipped_verbose
r.first.options[:verbose] = true
r.start
r.results << skip_test
assert r.passed?
r.report
refute_match SKIP_MSG, io.string
end
def test_start
r.start
exp = "Run options: \n\n# Running:\n\n"
assert_equal exp, io.string
end
def test_record_pass
r.record passing_test
assert_equal ".", io.string
assert_empty r.results
assert_equal 1, r.count
assert_equal 0, r.assertions
end
def test_record_fail
r.record fail_test
assert_equal "F", io.string
assert_equal [fail_test], r.results
assert_equal 1, r.count
assert_equal 0, r.assertions
end
def test_record_error
r.record error_test
assert_equal "E", io.string
assert_equal [error_test], r.results
assert_equal 1, r.count
assert_equal 0, r.assertions
end
def test_record_skip
r.record skip_test
assert_equal "S", io.string
assert_equal [skip_test], r.results
assert_equal 1, r.count
assert_equal 0, r.assertions
end
def test_report_empty
r.start
r.report
exp = clean <<-EOM
Run options:
# Running:
Finished in 0.00
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_equal exp, normalize_output(io.string)
end
def test_report_passing
r.start
r.record passing_test
r.report
exp = clean <<-EOM
Run options:
# Running:
.
Finished in 0.00
1 runs, 0 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_equal exp, normalize_output(io.string)
end
def test_report_failure
r.start
r.record fail_test
r.report
exp = clean <<-EOM
Run options:
# Running:
F
Finished in 0.00
1) Failure:
Minitest::Test#woot [FILE:LINE]:
boo
1 runs, 0 assertions, 1 failures, 0 errors, 0 skips
EOM
assert_equal exp, normalize_output(io.string)
end
def test_report_error
r.start
r.record error_test
r.report
exp = clean <<-EOM
Run options:
# Running:
E
Finished in 0.00
1) Error:
Minitest::Test#woot:
RuntimeError: no
FILE:LINE:in `error_test'
FILE:LINE:in `test_report_error'
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
EOM
assert_equal exp, normalize_output(io.string)
end
def test_report_skipped
r.start
r.record skip_test
restore_env do
r.report
end
exp = clean <<-EOM
Run options:
# Running:
S
Finished in 0.00
1 runs, 0 assertions, 0 failures, 0 errors, 1 skips
You have skipped tests. Run with --verbose for details.
EOM
assert_equal exp, normalize_output(io.string)
end
end
minitest-5.10.3/test/minitest/test_minitest_test.rb 0000444 0000041 0000041 00000134642 13135676423 022600 0 ustar www-data www-data # encoding: UTF-8
require "pathname"
require "minitest/metametameta"
if defined? Encoding then
e = Encoding.default_external
if e != Encoding::UTF_8 then
warn ""
warn ""
warn "NOTE: External encoding #{e} is not UTF-8. Tests WILL fail."
warn " Run tests with `RUBYOPT=-Eutf-8 rake` to avoid errors."
warn ""
warn ""
end
end
module MyModule; end
class AnError < StandardError; include MyModule; end
class ImmutableString < String; def inspect; super.freeze; end; end
SomeError = Class.new Exception
class TestMinitestUnit < MetaMetaMetaTestCase
parallelize_me!
pwd = Pathname.new File.expand_path Dir.pwd
basedir = Pathname.new(File.expand_path "lib/minitest") + "mini"
basedir = basedir.relative_path_from(pwd).to_s
MINITEST_BASE_DIR = basedir[/\A\./] ? basedir : "./#{basedir}"
BT_MIDDLE = ["#{MINITEST_BASE_DIR}/test.rb:161:in `each'",
"#{MINITEST_BASE_DIR}/test.rb:158:in `each'",
"#{MINITEST_BASE_DIR}/test.rb:139:in `run'",
"#{MINITEST_BASE_DIR}/test.rb:106:in `run'"]
def test_filter_backtrace
# this is a semi-lame mix of relative paths.
# I cheated by making the autotest parts not have ./
bt = (["lib/autotest.rb:571:in `add_exception'",
"test/test_autotest.rb:62:in `test_add_exception'",
"#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
BT_MIDDLE +
["#{MINITEST_BASE_DIR}/test.rb:29",
"test/test_autotest.rb:422"])
bt = util_expand_bt bt
ex = ["lib/autotest.rb:571:in `add_exception'",
"test/test_autotest.rb:62:in `test_add_exception'"]
ex = util_expand_bt ex
fu = Minitest.filter_backtrace(bt)
assert_equal ex, fu
end
def test_filter_backtrace_all_unit
bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
BT_MIDDLE +
["#{MINITEST_BASE_DIR}/test.rb:29"])
ex = bt.clone
fu = Minitest.filter_backtrace(bt)
assert_equal ex, fu
end
def test_filter_backtrace_unit_starts
bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
BT_MIDDLE +
["#{MINITEST_BASE_DIR}/mini/test.rb:29",
"-e:1"])
bt = util_expand_bt bt
ex = ["-e:1"]
fu = Minitest.filter_backtrace bt
assert_equal ex, fu
end
# def test_default_runner_is_minitest_unit
# assert_instance_of Minitest::Unit, Minitest::Unit.runner
# end
def test_infectious_binary_encoding
@tu = Class.new Minitest::Test do
def test_this_is_not_ascii_assertion
assert_equal "ЁЁЁ", "ёёё"
end
def test_this_is_non_ascii_failure_message
fail 'ЁЁЁ'.force_encoding('ASCII-8BIT')
end
end
expected = clean <<-EOM
EF
Finished in 0.00
1) Error:
##test_this_is_non_ascii_failure_message:
RuntimeError: ЁЁЁ
FILE:LINE:in `test_this_is_non_ascii_failure_message'
2) Failure:
##test_this_is_not_ascii_assertion [FILE:LINE]:
Expected: \"ЁЁЁ\"
Actual: \"ёёё\"
2 runs, 1 assertions, 1 failures, 1 errors, 0 skips
EOM
assert_report expected
end
def test_passed_eh_teardown_good
test_class = Class.new FakeNamedTest do
def teardown; assert true; end
def test_omg; assert true; end
end
test = test_class.new :test_omg
test.run
assert test.passed?
end
def test_passed_eh_teardown_skipped
test_class = Class.new FakeNamedTest do
def teardown; assert true; end
def test_omg; skip "bork"; end
end
test = test_class.new :test_omg
test.run
assert test.skipped?
refute test.passed?
end
def test_passed_eh_teardown_flunked
test_class = Class.new FakeNamedTest do
def teardown; flunk; end
def test_omg; assert true; end
end
test = test_class.new :test_omg
test.run
refute test.passed?
end
def util_expand_bt bt
if RUBY_VERSION >= "1.9.0" then
bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
else
bt
end
end
end
class TestMinitestUnitInherited < MetaMetaMetaTestCase
def with_overridden_include
Class.class_eval do
def inherited_with_hacks _klass
throw :inherited_hook
end
alias inherited_without_hacks inherited
alias inherited inherited_with_hacks
alias IGNORE_ME! inherited # 1.8 bug. god I love venture bros
end
yield
ensure
Class.class_eval do
alias inherited inherited_without_hacks
undef_method :inherited_with_hacks
undef_method :inherited_without_hacks
end
refute_respond_to Class, :inherited_with_hacks
refute_respond_to Class, :inherited_without_hacks
end
def test_inherited_hook_plays_nice_with_others
with_overridden_include do
assert_throws :inherited_hook do
Class.new FakeNamedTest
end
end
end
end
class TestMinitestRunner < MetaMetaMetaTestCase
# do not parallelize this suite... it just can't handle it.
def test_class_runnables
@assertion_count = 0
tc = Class.new(Minitest::Test)
assert_equal 1, Minitest::Test.runnables.size
assert_equal [tc], Minitest::Test.runnables
end
def test_run_test
@tu =
Class.new FakeNamedTest do
attr_reader :foo
def run
@foo = "hi mom!"
super
@foo = "okay"
self # per contract
end
def test_something
assert_equal "hi mom!", foo
end
end
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_report expected
end
def test_run_error
@tu =
Class.new FakeNamedTest do
def test_something
assert true
end
def test_error
raise "unhandled exception"
end
end
expected = clean <<-EOM
E.
Finished in 0.00
1) Error:
##test_error:
RuntimeError: unhandled exception
FILE:LINE:in \`test_error\'
2 runs, 1 assertions, 0 failures, 1 errors, 0 skips
EOM
assert_report expected
end
def test_run_error_teardown
@tu =
Class.new FakeNamedTest do
def test_something
assert true
end
def teardown
raise "unhandled exception"
end
end
expected = clean <<-EOM
E
Finished in 0.00
1) Error:
##test_something:
RuntimeError: unhandled exception
FILE:LINE:in \`teardown\'
1 runs, 1 assertions, 0 failures, 1 errors, 0 skips
EOM
assert_report expected
end
def test_run_failing
setup_basic_tu
expected = clean <<-EOM
F.
Finished in 0.00
1) Failure:
##test_failure [FILE:LINE]:
Expected false to be truthy.
2 runs, 2 assertions, 1 failures, 0 errors, 0 skips
EOM
assert_report expected
end
def setup_basic_tu
@tu =
Class.new FakeNamedTest do
def test_something
assert true
end
def test_failure
assert false
end
end
end
def test_run_failing_filtered
setup_basic_tu
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_report expected, %w[--name /some|thing/ --seed 42]
end
def assert_filtering filter, name, expected, a = false
args = %W[--#{filter} #{name} --seed 42]
alpha = Class.new FakeNamedTest do
define_method :test_something do
assert a
end
end
Object.const_set(:Alpha, alpha)
beta = Class.new FakeNamedTest do
define_method :test_something do
assert true
end
end
Object.const_set(:Beta, beta)
@tus = [alpha, beta]
assert_report expected, args
ensure
Object.send :remove_const, :Alpha
Object.send :remove_const, :Beta
end
def test_run_filtered_including_suite_name
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_filtering "name", "/Beta#test_something/", expected
end
def test_run_filtered_including_suite_name_string
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_filtering "name", "Beta#test_something", expected
end
def test_run_filtered_string_method_only
expected = clean <<-EOM
..
Finished in 0.00
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_filtering "name", "test_something", expected, :pass
end
def test_run_failing_excluded
setup_basic_tu
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_report expected, %w[--exclude /failure/ --seed 42]
end
def test_run_filtered_excluding_suite_name
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_filtering "exclude", "/Alpha#test_something/", expected
end
def test_run_filtered_excluding_suite_name_string
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_filtering "exclude", "Alpha#test_something", expected
end
def test_run_filtered_excluding_string_method_only
expected = clean <<-EOM
Finished in 0.00
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_filtering "exclude", "test_something", expected, :pass
end
def test_run_passing
@tu =
Class.new FakeNamedTest do
def test_something
assert true
end
end
expected = clean <<-EOM
.
Finished in 0.00
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_report expected
end
def test_run_skip
@tu =
Class.new FakeNamedTest do
def test_something
assert true
end
def test_skip
skip "not yet"
end
end
expected = clean <<-EOM
S.
Finished in 0.00
2 runs, 1 assertions, 0 failures, 0 errors, 1 skips
You have skipped tests. Run with --verbose for details.
EOM
restore_env do
assert_report expected
end
end
def test_run_skip_verbose
@tu =
Class.new FakeNamedTest do
def test_something
assert true
end
def test_skip
skip "not yet"
end
end
expected = clean <<-EOM
##test_skip = 0.00 s = S
##test_something = 0.00 s = .
Finished in 0.00
1) Skipped:
##test_skip [FILE:LINE]:
not yet
2 runs, 1 assertions, 0 failures, 0 errors, 1 skips
EOM
assert_report expected, %w[--seed 42 --verbose]
end
def test_run_with_other_runner
@tu =
Class.new FakeNamedTest do
def self.run reporter, options = {}
@reporter = reporter
before_my_suite
super
end
def self.name; "wacky!" end
def self.before_my_suite
@reporter.io.puts "Running #{self.name} tests"
@@foo = 1
end
def test_something
assert_equal 1, @@foo
end
def test_something_else
assert_equal 1, @@foo
end
end
expected = clean <<-EOM
Running wacky! tests
..
Finished in 0.00
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_report expected
end
require "monitor"
class Latch
def initialize count = 1
@count = count
@lock = Monitor.new
@cv = @lock.new_cond
end
def release
@lock.synchronize do
@count -= 1 if @count > 0
@cv.broadcast if @count == 0
end
end
def await
@lock.synchronize { @cv.wait_while { @count > 0 } }
end
end
def test_run_parallel
skip "I don't have ParallelEach debugged yet" if maglev?
test_count = 2
test_latch = Latch.new test_count
wait_latch = Latch.new test_count
main_latch = Latch.new
thread = Thread.new {
Thread.current.abort_on_exception = true
# This latch waits until both test latches have been released. Both
# latches can't be released unless done in separate threads because
# `main_latch` keeps the test method from finishing.
test_latch.await
main_latch.release
}
@tu =
Class.new FakeNamedTest do
parallelize_me!
test_count.times do |i|
define_method :"test_wait_on_main_thread_#{i}" do
test_latch.release
# This latch blocks until the "main thread" releases it. The main
# thread can't release this latch until both test latches have
# been released. This forces the latches to be released in separate
# threads.
main_latch.await
assert true
end
end
end
expected = clean <<-EOM
..
Finished in 0.00
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
EOM
assert_report(expected) do |reporter|
reporter.extend(Module.new {
define_method("record") do |result|
super(result)
wait_latch.release
end
define_method("report") do
wait_latch.await
super()
end
})
end
assert thread.join
end
end
class TestMinitestUnitOrder < MetaMetaMetaTestCase
# do not parallelize this suite... it just can't handle it.
def test_before_setup
call_order = []
@tu =
Class.new FakeNamedTest do
define_method :setup do
super()
call_order << :setup
end
define_method :before_setup do
call_order << :before_setup
end
def test_omg; assert true; end
end
run_tu_with_fresh_reporter
expected = [:before_setup, :setup]
assert_equal expected, call_order
end
def test_after_teardown
call_order = []
@tu =
Class.new FakeNamedTest do
define_method :teardown do
super()
call_order << :teardown
end
define_method :after_teardown do
call_order << :after_teardown
end
def test_omg; assert true; end
end
run_tu_with_fresh_reporter
expected = [:teardown, :after_teardown]
assert_equal expected, call_order
end
def test_all_teardowns_are_guaranteed_to_run
call_order = []
@tu =
Class.new FakeNamedTest do
define_method :after_teardown do
super()
call_order << :after_teardown
raise
end
define_method :teardown do
super()
call_order << :teardown
raise
end
define_method :before_teardown do
super()
call_order << :before_teardown
raise
end
def test_omg; assert true; end
end
run_tu_with_fresh_reporter
expected = [:before_teardown, :teardown, :after_teardown]
assert_equal expected, call_order
end
def test_setup_and_teardown_survive_inheritance
call_order = []
@tu = Class.new FakeNamedTest do
define_method :setup do
call_order << :setup_method
end
define_method :teardown do
call_order << :teardown_method
end
define_method :test_something do
call_order << :test
end
end
run_tu_with_fresh_reporter
@tu = Class.new @tu
run_tu_with_fresh_reporter
# Once for the parent class, once for the child
expected = [:setup_method, :test, :teardown_method] * 2
assert_equal expected, call_order
end
end
class TestMinitestRunnable < Minitest::Test
def setup_marshal klass
tc = klass.new "whatever"
tc.assertions = 42
tc.failures << "a failure"
yield tc if block_given?
def tc.setup
@blah = "blah"
end
tc.setup
@tc = tc
end
def assert_marshal expected_ivars
new_tc = Marshal.load Marshal.dump @tc
ivars = new_tc.instance_variables.map(&:to_s).sort
assert_equal expected_ivars, ivars
assert_equal "whatever", new_tc.name
assert_equal 42, new_tc.assertions
assert_equal ["a failure"], new_tc.failures
yield new_tc if block_given?
end
def test_marshal
setup_marshal Minitest::Runnable
assert_marshal %w[@NAME @assertions @failures]
end
end
class TestMinitestTest < TestMinitestRunnable
def test_dup
setup_marshal Minitest::Test do |tc|
tc.time = 3.14
end
assert_marshal %w[@NAME @assertions @failures @time] do |new_tc|
assert_in_epsilon 3.14, new_tc.time
end
end
end
class TestMinitestUnitTestCase < Minitest::Test
# do not call parallelize_me! - teardown accesses @tc._assertions
# which is not threadsafe. Nearly every method in here is an
# assertion test so it isn't worth splitting it out further.
RUBY18 = !defined? Encoding
def setup
super
Minitest::Test.reset
@tc = Minitest::Test.new "fake tc"
@zomg = "zomg ponies!"
@assertion_count = 1
end
def teardown
assert_equal(@assertion_count, @tc.assertions,
"expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}") if @tc.passed?
end
def non_verbose
orig_verbose = $VERBOSE
$VERBOSE = false
yield
ensure
$VERBOSE = orig_verbose
end
def test_assert
@assertion_count = 2
@tc.assert_equal true, @tc.assert(true), "returns true on success"
end
def test_assert__triggered
assert_triggered "Expected false to be truthy." do
@tc.assert false
end
end
def test_assert__triggered_message
assert_triggered @zomg do
@tc.assert false, @zomg
end
end
def test_assert_empty
@assertion_count = 2
@tc.assert_empty []
end
def test_assert_empty_triggered
@assertion_count = 2
assert_triggered "Expected [1] to be empty." do
@tc.assert_empty [1]
end
end
def test_assert_equal
@tc.assert_equal 1, 1
end
def test_assert_equal_different_collection_array_hex_invisible
object1 = Object.new
object2 = Object.new
msg = "No visible difference in the Array#inspect output.
You should look at the implementation of #== on Array or its members.
[#]".gsub(/^ +/, "")
assert_triggered msg do
@tc.assert_equal [object1], [object2]
end
end
def test_assert_equal_different_collection_hash_hex_invisible
h1, h2 = {}, {}
h1[1] = Object.new
h2[1] = Object.new
msg = "No visible difference in the Hash#inspect output.
You should look at the implementation of #== on Hash or its members.
{1=>#}".gsub(/^ +/, "")
assert_triggered msg do
@tc.assert_equal h1, h2
end
end
def test_assert_equal_string_encodings
msg = <<-EOM.gsub(/^ {10}/, "")
--- expected
+++ actual
@@ -1 +1,2 @@
+# encoding: ASCII-8BIT
"bad-utf8-\\xF1.txt"
EOM
assert_triggered msg do
x = "bad-utf8-\xF1.txt"
y = x.dup.force_encoding "binary" # TODO: switch to .b when 1.9 dropped
@tc.assert_equal x, y
end
end unless RUBY18
def test_assert_equal_string_encodings_both_different
msg = <<-EOM.gsub(/^ {10}/, "")
--- expected
+++ actual
@@ -1,2 +1,2 @@
-# encoding: US-ASCII
+# encoding: ASCII-8BIT
"bad-utf8-\\xF1.txt"
EOM
assert_triggered msg do
x = "bad-utf8-\xF1.txt".force_encoding "ASCII"
y = x.dup.force_encoding "binary" # TODO: switch to .b when 1.9 dropped
@tc.assert_equal x, y
end
end unless RUBY18
def test_assert_equal_different_diff_deactivated
skip "https://github.com/MagLev/maglev/issues/209" if maglev?
without_diff do
assert_triggered util_msg("haha" * 10, "blah" * 10) do
o1 = "haha" * 10
o2 = "blah" * 10
@tc.assert_equal o1, o2
end
end
end
def test_assert_equal_different_hex
c = Class.new do
def initialize s; @name = s; end
end
o1 = c.new "a"
o2 = c.new "b"
msg = "--- expected
+++ actual
@@ -1 +1 @@
-#<#:0xXXXXXX @name=\"a\">
+#<#:0xXXXXXX @name=\"b\">
".gsub(/^ +/, "")
assert_triggered msg do
@tc.assert_equal o1, o2
end
end
def test_assert_equal_different_hex_invisible
o1 = Object.new
o2 = Object.new
msg = "No visible difference in the Object#inspect output.
You should look at the implementation of #== on Object or its members.
#".gsub(/^ +/, "")
assert_triggered msg do
@tc.assert_equal o1, o2
end
end
def test_assert_equal_different_long
msg = "--- expected
+++ actual
@@ -1 +1 @@
-\"hahahahahahahahahahahahahahahahahahahaha\"
+\"blahblahblahblahblahblahblahblahblahblah\"
".gsub(/^ +/, "")
assert_triggered msg do
o1 = "haha" * 10
o2 = "blah" * 10
@tc.assert_equal o1, o2
end
end
def test_assert_equal_different_long_invisible
msg = "No visible difference in the String#inspect output.
You should look at the implementation of #== on String or its members.
\"blahblahblahblahblahblahblahblahblahblah\"".gsub(/^ +/, "")
assert_triggered msg do
o1 = "blah" * 10
o2 = "blah" * 10
def o1.== _
false
end
@tc.assert_equal o1, o2
end
end
def test_assert_equal_different_long_msg
msg = "message.
--- expected
+++ actual
@@ -1 +1 @@
-\"hahahahahahahahahahahahahahahahahahahaha\"
+\"blahblahblahblahblahblahblahblahblahblah\"
".gsub(/^ +/, "")
assert_triggered msg do
o1 = "haha" * 10
o2 = "blah" * 10
@tc.assert_equal o1, o2, "message"
end
end
def test_assert_equal_different_short
assert_triggered util_msg(1, 2) do
@tc.assert_equal 1, 2
end
end
def test_assert_equal_different_short_msg
assert_triggered util_msg(1, 2, "message") do
@tc.assert_equal 1, 2, "message"
end
end
def test_assert_equal_different_short_multiline
msg = "--- expected\n+++ actual\n@@ -1,2 +1,2 @@\n \"a\n-b\"\n+c\"\n"
assert_triggered msg do
@tc.assert_equal "a\nb", "a\nc"
end
end
def test_assert_equal_does_not_allow_lhs_nil
if Minitest::VERSION =~ /^6/ then
warn "Time to strip the MT5 test"
@assertion_count += 1
assert_triggered(/Use assert_nil if expecting nil/) do
@tc.assert_equal nil, nil
end
else
err_re = /Use assert_nil if expecting nil from .*test_minitest_test.rb/
err_re = "" if $-w.nil?
assert_output "", err_re do
@tc.assert_equal nil, nil
end
end
end
def test_assert_equal_does_not_allow_lhs_nil_triggered
assert_triggered "Expected: nil\n Actual: false" do
@tc.assert_equal nil, false
end
end
def test_assert_in_delta
@tc.assert_in_delta 0.0, 1.0 / 1000, 0.1
end
def test_delta_consistency
@assertion_count = 2
@tc.assert_in_delta 0, 1, 1
assert_triggered "Expected |0 - 1| (1) to not be <= 1." do
@tc.refute_in_delta 0, 1, 1
end
end
def test_assert_in_delta_triggered
x = maglev? ? "9.999999xxxe-07" : "1.0e-06"
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
@tc.assert_in_delta 0.0, 1.0 / 1000, 0.000001
end
end
def test_assert_in_epsilon
@assertion_count = 10
@tc.assert_in_epsilon 10_000, 9991
@tc.assert_in_epsilon 9991, 10_000
@tc.assert_in_epsilon 1.0, 1.001
@tc.assert_in_epsilon 1.001, 1.0
@tc.assert_in_epsilon 10_000, 9999.1, 0.0001
@tc.assert_in_epsilon 9999.1, 10_000, 0.0001
@tc.assert_in_epsilon 1.0, 1.0001, 0.0001
@tc.assert_in_epsilon 1.0001, 1.0, 0.0001
@tc.assert_in_epsilon(-1, -1)
@tc.assert_in_epsilon(-10_000, -9991)
end
def test_epsilon_consistency
@assertion_count = 2
@tc.assert_in_epsilon 1.0, 1.001
msg = "Expected |1.0 - 1.001| (0.000999xxx) to not be <= 0.001."
assert_triggered msg do
@tc.refute_in_epsilon 1.0, 1.001
end
end
def test_assert_in_epsilon_triggered
assert_triggered "Expected |10000 - 9990| (10) to be <= 9.99." do
@tc.assert_in_epsilon 10_000, 9990
end
end
def test_assert_in_epsilon_triggered_negative_case
x = (RUBY18 and not maglev?) ? "0.1" : "0.100000xxx"
y = maglev? ? "0.100000xxx" : "0.1"
assert_triggered "Expected |-1.1 - -1| (#{x}) to be <= #{y}." do
@tc.assert_in_epsilon(-1.1, -1, 0.1)
end
end
def test_assert_includes
@assertion_count = 2
@tc.assert_includes [true], true
end
def test_assert_includes_triggered
@assertion_count = 3
e = @tc.assert_raises Minitest::Assertion do
@tc.assert_includes [true], false
end
expected = "Expected [true] to include false."
assert_equal expected, e.message
end
def test_assert_instance_of
@tc.assert_instance_of String, "blah"
end
def test_assert_instance_of_triggered
assert_triggered 'Expected "blah" to be an instance of Array, not String.' do
@tc.assert_instance_of Array, "blah"
end
end
def test_assert_kind_of
@tc.assert_kind_of String, "blah"
end
def test_assert_kind_of_triggered
assert_triggered 'Expected "blah" to be a kind of Array, not String.' do
@tc.assert_kind_of Array, "blah"
end
end
def test_assert_match
@assertion_count = 2
@tc.assert_match(/\w+/, "blah blah blah")
end
def test_assert_match_matcher_object
@assertion_count = 2
pattern = Object.new
def pattern.=~ _; true end
@tc.assert_match pattern, 5
end
def test_assert_match_matchee_to_str
@assertion_count = 2
obj = Object.new
def obj.to_str; "blah" end
@tc.assert_match "blah", obj
end
def test_assert_match_object_triggered
@assertion_count = 2
pattern = Object.new
def pattern.=~ _; false end
def pattern.inspect; "[Object]" end
assert_triggered "Expected [Object] to match 5." do
@tc.assert_match pattern, 5
end
end
def test_assert_match_triggered
@assertion_count = 2
assert_triggered 'Expected /\d+/ to match "blah blah blah".' do
@tc.assert_match(/\d+/, "blah blah blah")
end
end
def test_assert_nil
@tc.assert_nil nil
end
def test_assert_nil_triggered
assert_triggered "Expected 42 to be nil." do
@tc.assert_nil 42
end
end
def test_assert_operator
@tc.assert_operator 2, :>, 1
end
def test_assert_operator_bad_object
bad = Object.new
def bad.== _; true end
@tc.assert_operator bad, :equal?, bad
end
def test_assert_operator_triggered
assert_triggered "Expected 2 to be < 1." do
@tc.assert_operator 2, :<, 1
end
end
def test_assert_output_both
@assertion_count = 2
@tc.assert_output "yay", "blah" do
print "yay"
$stderr.print "blah"
end
end
def test_assert_output_both_regexps
@assertion_count = 4
@tc.assert_output(/y.y/, /bl.h/) do
print "yay"
$stderr.print "blah"
end
end
def test_assert_output_err
@tc.assert_output nil, "blah" do
$stderr.print "blah"
end
end
def test_assert_output_neither
@assertion_count = 0
@tc.assert_output do
# do nothing
end
end
def test_assert_output_out
@tc.assert_output "blah" do
print "blah"
end
end
def test_assert_output_triggered_both
assert_triggered util_msg("blah", "blah blah", "In stderr") do
@tc.assert_output "yay", "blah" do
print "boo"
$stderr.print "blah blah"
end
end
end
def test_assert_output_triggered_err
assert_triggered util_msg("blah", "blah blah", "In stderr") do
@tc.assert_output nil, "blah" do
$stderr.print "blah blah"
end
end
end
def test_assert_output_triggered_out
assert_triggered util_msg("blah", "blah blah", "In stdout") do
@tc.assert_output "blah" do
print "blah blah"
end
end
end
def test_assert_predicate
@tc.assert_predicate "", :empty?
end
def test_assert_predicate_triggered
assert_triggered 'Expected "blah" to be empty?.' do
@tc.assert_predicate "blah", :empty?
end
end
def test_assert_raises
@tc.assert_raises RuntimeError do
raise "blah"
end
end
def test_assert_raises_default
@tc.assert_raises do
raise StandardError, "blah"
end
end
def test_assert_raises_default_triggered
e = assert_raises Minitest::Assertion do
@tc.assert_raises do
raise SomeError, "blah"
end
end
expected = clean <<-EOM.chomp
[StandardError] exception expected, not
Class:
Message: <\"blah\">
---Backtrace---
FILE:LINE:in \`test_assert_raises_default_triggered\'
---------------
EOM
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
assert_equal expected, actual
end
def test_assert_raises_module
@tc.assert_raises MyModule do
raise AnError
end
end
##
# *sigh* This is quite an odd scenario, but it is from real (albeit
# ugly) test code in ruby-core:
#
# http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29259
def test_assert_raises_skip
@assertion_count = 0
assert_triggered "skipped", Minitest::Skip do
@tc.assert_raises ArgumentError do
begin
raise "blah"
rescue
skip "skipped"
end
end
end
end
def test_assert_raises_triggered_different
e = assert_raises Minitest::Assertion do
@tc.assert_raises RuntimeError do
raise SyntaxError, "icky"
end
end
expected = clean <<-EOM.chomp
[RuntimeError] exception expected, not
Class:
Message: <\"icky\">
---Backtrace---
FILE:LINE:in \`test_assert_raises_triggered_different\'
---------------
EOM
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
assert_equal expected, actual
end
def test_assert_raises_triggered_different_msg
e = assert_raises Minitest::Assertion do
@tc.assert_raises RuntimeError, "XXX" do
raise SyntaxError, "icky"
end
end
expected = clean <<-EOM
XXX.
[RuntimeError] exception expected, not
Class:
Message: <\"icky\">
---Backtrace---
FILE:LINE:in \`test_assert_raises_triggered_different_msg\'
---------------
EOM
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
assert_equal expected.chomp, actual
end
def test_assert_raises_triggered_none
e = assert_raises Minitest::Assertion do
@tc.assert_raises Minitest::Assertion do
# do nothing
end
end
expected = "Minitest::Assertion expected but nothing was raised."
assert_equal expected, e.message
end
def test_assert_raises_triggered_none_msg
e = assert_raises Minitest::Assertion do
@tc.assert_raises Minitest::Assertion, "XXX" do
# do nothing
end
end
expected = "XXX.\nMinitest::Assertion expected but nothing was raised."
assert_equal expected, e.message
end
def test_assert_raises_subclass
@tc.assert_raises StandardError do
raise AnError
end
end
def test_assert_raises_subclass_triggered
e = assert_raises Minitest::Assertion do
@tc.assert_raises SomeError do
raise AnError, "some message"
end
end
expected = clean <<-EOM
[SomeError] exception expected, not
Class:
Message: <\"some message\">
---Backtrace---
FILE:LINE:in \`test_assert_raises_subclass_triggered\'
---------------
EOM
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
actual.gsub!(/block \(\d+ levels\) in /, "") if RUBY_VERSION >= "1.9.0"
assert_equal expected.chomp, actual
end
def test_assert_raises_exit
@tc.assert_raises SystemExit do
exit 1
end
end
def test_assert_raises_signals
@tc.assert_raises SignalException do
raise SignalException, :INT
end
end
def test_assert_respond_to
@tc.assert_respond_to "blah", :empty?
end
def test_assert_respond_to_triggered
assert_triggered 'Expected "blah" (String) to respond to #rawr!.' do
@tc.assert_respond_to "blah", :rawr!
end
end
def test_assert_same
@assertion_count = 3
o = "blah"
@tc.assert_same 1, 1
@tc.assert_same :blah, :blah
@tc.assert_same o, o
end
def test_assert_same_triggered
@assertion_count = 2
assert_triggered "Expected 2 (oid=N) to be the same as 1 (oid=N)." do
@tc.assert_same 1, 2
end
s1 = "blah"
s2 = "blah"
assert_triggered 'Expected "blah" (oid=N) to be the same as "blah" (oid=N).' do
@tc.assert_same s1, s2
end
end
def assert_deprecated name
dep = /DEPRECATED: #{name}. From #{__FILE__}:\d+(?::.*)?/
dep = "" if $-w.nil?
assert_output nil, dep do
yield
end
end
def test_assert_send
assert_deprecated :assert_send do
@tc.assert_send [1, :<, 2]
end
end
def test_assert_send_bad
assert_deprecated :assert_send do
assert_triggered "Expected 1.>(*[2]) to return true." do
@tc.assert_send [1, :>, 2]
end
end
end
def test_assert_silent
@assertion_count = 2
@tc.assert_silent do
# do nothing
end
end
def test_assert_silent_triggered_err
assert_triggered util_msg("", "blah blah", "In stderr") do
@tc.assert_silent do
$stderr.print "blah blah"
end
end
end
def test_assert_silent_triggered_out
@assertion_count = 2
assert_triggered util_msg("", "blah blah", "In stdout") do
@tc.assert_silent do
print "blah blah"
end
end
end
def test_assert_throws
@tc.assert_throws :blah do
throw :blah
end
end
def test_assert_throws_name_error
@tc.assert_raises NameError do
@tc.assert_throws :blah do
raise NameError
end
end
end
def test_assert_throws_argument_exception
@tc.assert_raises ArgumentError do
@tc.assert_throws :blah do
raise ArgumentError
end
end
end
def test_assert_throws_different
assert_triggered "Expected :blah to have been thrown, not :not_blah." do
@tc.assert_throws :blah do
throw :not_blah
end
end
end
def test_assert_throws_unthrown
assert_triggered "Expected :blah to have been thrown." do
@tc.assert_throws :blah do
# do nothing
end
end
end
def test_capture_io
@assertion_count = 0
non_verbose do
out, err = capture_io do
puts "hi"
$stderr.puts "bye!"
end
assert_equal "hi\n", out
assert_equal "bye!\n", err
end
end
def test_capture_subprocess_io
@assertion_count = 0
non_verbose do
out, err = capture_subprocess_io do
system("echo hi")
system("echo bye! 1>&2")
end
assert_equal "hi\n", out
assert_equal "bye!", err.strip
end
end
def test_class_asserts_match_refutes
@assertion_count = 0
methods = Minitest::Assertions.public_instance_methods
methods.map!(&:to_s) if Symbol === methods.first
# These don't have corresponding refutes _on purpose_. They're
# useless and will never be added, so don't bother.
ignores = %w[assert_output assert_raises assert_send
assert_silent assert_throws assert_mock]
# These are test/unit methods. I'm not actually sure why they're still here
ignores += %w[assert_no_match assert_not_equal assert_not_nil
assert_not_same assert_nothing_raised
assert_nothing_thrown assert_raise]
asserts = methods.grep(/^assert/).sort - ignores
refutes = methods.grep(/^refute/).sort - ignores
assert_empty refutes.map { |n| n.sub(/^refute/, "assert") } - asserts
assert_empty asserts.map { |n| n.sub(/^assert/, "refute") } - refutes
end
def test_flunk
assert_triggered "Epic Fail!" do
@tc.flunk
end
end
def test_flunk_message
assert_triggered @zomg do
@tc.flunk @zomg
end
end
def test_message
@assertion_count = 0
assert_equal "blah2.", @tc.message { "blah2" }.call
assert_equal "blah2.", @tc.message("") { "blah2" }.call
assert_equal "blah1.\nblah2.", @tc.message(:blah1) { "blah2" }.call
assert_equal "blah1.\nblah2.", @tc.message("blah1") { "blah2" }.call
message = proc { "blah1" }
assert_equal "blah1.\nblah2.", @tc.message(message) { "blah2" }.call
message = @tc.message { "blah1" }
assert_equal "blah1.\nblah2.", @tc.message(message) { "blah2" }.call
end
def test_message_message
assert_triggered "whoops.\nExpected: 1\n Actual: 2" do
@tc.assert_equal 1, 2, message { "whoops" }
end
end
def test_message_lambda
assert_triggered "whoops.\nExpected: 1\n Actual: 2" do
@tc.assert_equal 1, 2, lambda { "whoops" }
end
end
def test_message_deferred
@assertion_count, var = 0, nil
msg = message { var = "blah" }
assert_nil var
msg.call
assert_equal "blah", var
end
def test_pass
@tc.pass
end
def test_prints
printer = Class.new { extend Minitest::Assertions }
@tc.assert_equal '"test"', printer.mu_pp(ImmutableString.new "test")
end
def test_refute
@assertion_count = 2
@tc.assert_equal false, @tc.refute(false), "returns false on success"
end
def test_refute_empty
@assertion_count = 2
@tc.refute_empty [1]
end
def test_refute_empty_triggered
@assertion_count = 2
assert_triggered "Expected [] to not be empty." do
@tc.refute_empty []
end
end
def test_refute_equal
@tc.refute_equal "blah", "yay"
end
def test_refute_equal_triggered
assert_triggered 'Expected "blah" to not be equal to "blah".' do
@tc.refute_equal "blah", "blah"
end
end
def test_refute_in_delta
@tc.refute_in_delta 0.0, 1.0 / 1000, 0.000001
end
def test_refute_in_delta_triggered
x = maglev? ? "0.100000xxx" : "0.1"
assert_triggered "Expected |0.0 - 0.001| (0.001) to not be <= #{x}." do
@tc.refute_in_delta 0.0, 1.0 / 1000, 0.1
end
end
def test_refute_in_epsilon
@tc.refute_in_epsilon 10_000, 9990-1
end
def test_refute_in_epsilon_triggered
assert_triggered "Expected |10000 - 9990| (10) to not be <= 10.0." do
@tc.refute_in_epsilon 10_000, 9990
flunk
end
end
def test_refute_includes
@assertion_count = 2
@tc.refute_includes [true], false
end
def test_refute_includes_triggered
@assertion_count = 3
e = @tc.assert_raises Minitest::Assertion do
@tc.refute_includes [true], true
end
expected = "Expected [true] to not include true."
assert_equal expected, e.message
end
def test_refute_instance_of
@tc.refute_instance_of Array, "blah"
end
def test_refute_instance_of_triggered
assert_triggered 'Expected "blah" to not be an instance of String.' do
@tc.refute_instance_of String, "blah"
end
end
def test_refute_kind_of
@tc.refute_kind_of Array, "blah"
end
def test_refute_kind_of_triggered
assert_triggered 'Expected "blah" to not be a kind of String.' do
@tc.refute_kind_of String, "blah"
end
end
def test_refute_match
@assertion_count = 2
@tc.refute_match(/\d+/, "blah blah blah")
end
def test_refute_match_matcher_object
@assertion_count = 2
@tc.refute_match Object.new, 5 # default #=~ returns false
end
def test_refute_match_object_triggered
@assertion_count = 2
pattern = Object.new
def pattern.=~ _; true end
def pattern.inspect; "[Object]" end
assert_triggered "Expected [Object] to not match 5." do
@tc.refute_match pattern, 5
end
end
def test_refute_match_triggered
@assertion_count = 2
assert_triggered 'Expected /\w+/ to not match "blah blah blah".' do
@tc.refute_match(/\w+/, "blah blah blah")
end
end
def test_refute_nil
@tc.refute_nil 42
end
def test_refute_nil_triggered
assert_triggered "Expected nil to not be nil." do
@tc.refute_nil nil
end
end
def test_refute_predicate
@tc.refute_predicate "42", :empty?
end
def test_refute_predicate_triggered
assert_triggered 'Expected "" to not be empty?.' do
@tc.refute_predicate "", :empty?
end
end
def test_refute_operator
@tc.refute_operator 2, :<, 1
end
def test_refute_operator_bad_object
bad = Object.new
def bad.== _; true end
@tc.refute_operator true, :equal?, bad
end
def test_refute_operator_triggered
assert_triggered "Expected 2 to not be > 1." do
@tc.refute_operator 2, :>, 1
end
end
def test_refute_respond_to
@tc.refute_respond_to "blah", :rawr!
end
def test_refute_respond_to_triggered
assert_triggered 'Expected "blah" to not respond to empty?.' do
@tc.refute_respond_to "blah", :empty?
end
end
def test_refute_same
@tc.refute_same 1, 2
end
def test_refute_same_triggered
assert_triggered "Expected 1 (oid=N) to not be the same as 1 (oid=N)." do
@tc.refute_same 1, 1
end
end
def test_skip
@assertion_count = 0
assert_triggered "haha!", Minitest::Skip do
@tc.skip "haha!"
end
end
def test_runnable_methods_random
@assertion_count = 0
sample_test_case = Class.new FakeNamedTest do
def self.test_order; :random; end
def test_test1; assert "does not matter" end
def test_test2; assert "does not matter" end
def test_test3; assert "does not matter" end
end
srand 42
expected = case
when maglev? then
%w[test_test2 test_test3 test_test1]
else
%w[test_test2 test_test1 test_test3]
end
assert_equal expected, sample_test_case.runnable_methods
end
def test_runnable_methods_sorted
@assertion_count = 0
sample_test_case = Class.new FakeNamedTest do
def self.test_order; :sorted end
def test_test3; assert "does not matter" end
def test_test2; assert "does not matter" end
def test_test1; assert "does not matter" end
end
expected = %w[test_test1 test_test2 test_test3]
assert_equal expected, sample_test_case.runnable_methods
end
def test_i_suck_and_my_tests_are_order_dependent_bang_sets_test_order_alpha
@assertion_count = 0
shitty_test_case = Class.new FakeNamedTest
shitty_test_case.i_suck_and_my_tests_are_order_dependent!
assert_equal :alpha, shitty_test_case.test_order
end
def test_i_suck_and_my_tests_are_order_dependent_bang_does_not_warn
@assertion_count = 0
shitty_test_case = Class.new FakeNamedTest
def shitty_test_case.test_order; :lol end
assert_silent do
shitty_test_case.i_suck_and_my_tests_are_order_dependent!
end
end
def assert_triggered expected, klass = Minitest::Assertion
e = assert_raises klass do
yield
end
msg = e.message.sub(/(---Backtrace---).*/m, '\1')
msg.gsub!(/\(oid=[-0-9]+\)/, "(oid=N)")
msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
assert_msg = Regexp === expected ? :assert_match : :assert_equal
self.send assert_msg, expected, msg
end
def util_msg exp, act, msg = nil
s = "Expected: #{exp.inspect}\n Actual: #{act.inspect}"
s = "#{msg}.\n#{s}" if msg
s
end
def without_diff
old_diff = Minitest::Assertions.diff
Minitest::Assertions.diff = nil
yield
ensure
Minitest::Assertions.diff = old_diff
end
end
class TestMinitestGuard < Minitest::Test
parallelize_me!
def test_mri_eh
assert self.class.mri? "ruby blah"
assert self.mri? "ruby blah"
end
def test_jruby_eh
assert self.class.jruby? "java"
assert self.jruby? "java"
end
def test_rubinius_eh
assert self.class.rubinius? "rbx"
assert self.rubinius? "rbx"
end
def test_windows_eh
assert self.class.windows? "mswin"
assert self.windows? "mswin"
end
end
class TestMinitestUnitRecording < MetaMetaMetaTestCase
# do not parallelize this suite... it just can't handle it.
def assert_run_record *expected, &block
@tu = Class.new FakeNamedTest, &block
run_tu_with_fresh_reporter
recorded = first_reporter.results.map(&:failures).flatten.map { |f| f.error.class }
assert_equal expected, recorded
end
def test_run_with_bogus_reporter
# https://github.com/seattlerb/minitest/issues/659
# TODO: remove test for minitest 6
@tu = Class.new FakeNamedTest do
def test_method
assert true
end
end
bogus_reporter = Class.new do # doesn't subclass AbstractReporter
def start; @success = false; end
# def prerecord klass, name; end # doesn't define full API
def record result; @success = true; end
def report; end
def passed?; end
def results; end
def success?; @success; end
end.new
self.reporter = Minitest::CompositeReporter.new
reporter << bogus_reporter
Minitest::Runnable.runnables.delete @tu
@tu.run reporter, {}
assert_predicate bogus_reporter, :success?
end
def test_record_passing
assert_run_record do
def test_method
assert true
end
end
end
def test_record_failing
assert_run_record Minitest::Assertion do
def test_method
assert false
end
end
end
def test_record_error
assert_run_record RuntimeError do
def test_method
raise "unhandled exception"
end
end
end
def test_record_error_teardown
assert_run_record RuntimeError do
def test_method
assert true
end
def teardown
raise "unhandled exception"
end
end
end
def test_record_error_in_test_and_teardown
assert_run_record AnError, RuntimeError do
def test_method
raise AnError
end
def teardown
raise "unhandled exception"
end
end
end
def test_to_s_error_in_test_and_teardown
@tu = Class.new FakeNamedTest do
def test_method
raise AnError
end
def teardown
raise "unhandled exception"
end
end
run_tu_with_fresh_reporter
exp = clean "
Error:
##test_method:
AnError: AnError
FILE:LINE:in `test_method'
Error:
##test_method:
RuntimeError: unhandled exception
FILE:LINE:in `teardown'
"
assert_equal exp.strip, normalize_output(first_reporter.results.first.to_s).strip
end
def test_record_skip
assert_run_record Minitest::Skip do
def test_method
skip "not yet"
end
end
end
end
minitest-5.10.3/checksums.yaml.gz.sig 0000444 0000041 0000041 00000000400 13135676423 017537 0 ustar www-data www-data w5ښWW?^+KO3ڧQ)1ᙝr:Z8
cGçЫ%6
vvށd,ft_i\=[=BEj