minitest 1.3.0 → 6.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +2 -0
  3. data/History.rdoc +1860 -0
  4. data/Manifest.txt +38 -8
  5. data/README.rdoc +763 -0
  6. data/Rakefile +70 -56
  7. data/bin/minitest +5 -0
  8. data/design_rationale.rb +54 -0
  9. data/lib/hoe/minitest.rb +30 -0
  10. data/lib/minitest/assertions.rb +821 -0
  11. data/lib/minitest/autorun.rb +5 -0
  12. data/lib/minitest/benchmark.rb +452 -0
  13. data/lib/minitest/bisect.rb +304 -0
  14. data/lib/minitest/complete.rb +56 -0
  15. data/lib/minitest/compress.rb +94 -0
  16. data/lib/minitest/error_on_warning.rb +11 -0
  17. data/lib/minitest/expectations.rb +321 -0
  18. data/lib/minitest/find_minimal_combination.rb +127 -0
  19. data/lib/minitest/hell.rb +11 -0
  20. data/lib/minitest/manual_plugins.rb +4 -0
  21. data/lib/minitest/parallel.rb +72 -0
  22. data/lib/minitest/path_expander.rb +432 -0
  23. data/lib/minitest/pride.rb +4 -0
  24. data/lib/minitest/pride_plugin.rb +135 -0
  25. data/lib/minitest/server.rb +49 -0
  26. data/lib/minitest/server_plugin.rb +88 -0
  27. data/lib/minitest/spec.rb +306 -64
  28. data/lib/minitest/sprint.rb +105 -0
  29. data/lib/minitest/sprint_plugin.rb +39 -0
  30. data/lib/minitest/test.rb +232 -0
  31. data/lib/minitest/test_task.rb +331 -0
  32. data/lib/minitest.rb +1232 -0
  33. data/test/minitest/metametameta.rb +150 -0
  34. data/test/minitest/test_bisect.rb +249 -0
  35. data/test/minitest/test_find_minimal_combination.rb +138 -0
  36. data/test/minitest/test_minitest_assertions.rb +1729 -0
  37. data/test/minitest/test_minitest_benchmark.rb +151 -0
  38. data/test/minitest/test_minitest_reporter.rb +437 -0
  39. data/test/minitest/test_minitest_spec.rb +1095 -0
  40. data/test/minitest/test_minitest_test.rb +1295 -0
  41. data/test/minitest/test_minitest_test_task.rb +57 -0
  42. data/test/minitest/test_path_expander.rb +229 -0
  43. data/test/minitest/test_server.rb +146 -0
  44. data.tar.gz.sig +1 -0
  45. metadata +235 -62
  46. metadata.gz.sig +0 -0
  47. data/.autotest +0 -15
  48. data/History.txt +0 -114
  49. data/README.txt +0 -56
  50. data/lib/minitest/mock.rb +0 -31
  51. data/lib/minitest/unit.rb +0 -482
  52. data/test/test_mini_mock.rb +0 -77
  53. data/test/test_mini_spec.rb +0 -149
  54. data/test/test_mini_test.rb +0 -829
data/Rakefile CHANGED
@@ -1,75 +1,89 @@
1
1
  # -*- ruby -*-
2
2
 
3
- $TESTING_MINIUNIT = true
3
+ require "hoe"
4
+ $:.unshift "lib" # to pick up lib/minitest/test_task.rb when minitest not installed
4
5
 
5
- require 'rubygems'
6
- require 'hoe'
7
- require './lib/minitest/unit.rb'
6
+ Hoe.plugin :seattlerb
7
+ Hoe.plugin :isolate
8
+ Hoe.plugin :rdoc
9
+ Hoe.plugin :cov
8
10
 
9
- Hoe.new('minitest', MiniTest::Unit::VERSION) do |miniunit|
10
- miniunit.rubyforge_name = "bfts"
11
+ Hoe.spec "minitest" do
12
+ developer "Ryan Davis", "ryand-ruby@zenspider.com"
11
13
 
12
- miniunit.developer('Ryan Davis', 'ryand-ruby@zenspider.com')
13
- end
14
+ license "MIT"
14
15
 
15
- class Hoe # TODO: fix - I shouldn't need this
16
- def run_tests(multi=false) # :nodoc:
17
- tests = test_globs.map { |g| Dir.glob(g) }.flatten
18
- tests.map! {|f| %Q(require "#{f}")}
19
- cmd = "#{RUBY_FLAGS} -e '#{tests.join("; ")}' #{FILTER}"
16
+ require_ruby_version ">= 3.2"
20
17
 
21
- send :ruby, cmd
22
- end
18
+ dependency "prism", "~> 1.5"
19
+ dependency "drb", "~> 2.0"
20
+
21
+ self.rdoc_locations << "l:/home/www/minite.st/html/docs"
22
+
23
+ self.cov_filter = %w[ tmp ]
23
24
  end
24
25
 
25
- begin
26
- require 'rcov/rcovtask'
27
- Rcov::RcovTask.new do |t|
28
- t.verbose = true
29
- t.rcov_opts << "--include-file lib/test"
30
- t.rcov_opts << "--no-color"
31
- end
26
+ desc "Find missing expectations"
27
+ task :specs do
28
+ $:.unshift "lib"
29
+ require "minitest/test"
30
+ require "minitest/spec"
32
31
 
33
- task :rcov_info do
34
- pattern = ENV['PATTERN'] || "test/test_*.rb"
35
- ruby "-Ilib -S rcov --text-report --include-file lib/test --save coverage.info #{pattern}"
36
- end
32
+ pos_prefix, neg_prefix = "must", "wont"
33
+ skip_re = /^(must|wont)$|wont_(throw)|must_(block|not?_|nothing|send|raise$)/x
34
+ dont_flip_re = /(must|wont)_(include|respond_to)/
35
+
36
+ map = {
37
+ /(must_throw)s/ => '\1',
38
+ /(?!not)_same/ => "_be_same_as",
39
+ /_in_/ => "_be_within_",
40
+ /_operator/ => "_be",
41
+ /_includes/ => "_include",
42
+ /(must|wont)_(.*_of|nil|silent|empty)/ => '\1_be_\2',
43
+ /must_raises/ => "must_raise",
44
+ /(must|wont)_pattern/ => '\1_pattern_match',
45
+ /(must|wont)_predicate/ => '\1_be',
46
+ /(must|wont)_path_exists/ => 'path_\1_exist',
47
+ }
37
48
 
38
- task :rcov_overlay do
39
- rcov, eol = Marshal.load(File.read("coverage.info")).last[ENV["FILE"]], 1
40
- puts rcov[:lines].zip(rcov[:coverage]).map { |line, coverage|
41
- bol, eol = eol, eol + line.length
42
- [bol, eol, "#ffcccc"] unless coverage
43
- }.compact.inspect
49
+ expectations = Minitest::Expectations.public_instance_methods.map(&:to_s)
50
+ assertions = Minitest::Assertions.public_instance_methods.map(&:to_s)
51
+
52
+ assertions.sort.each do |assertion|
53
+ expectation = case assertion
54
+ when /^assert/ then
55
+ assertion.sub(/^assert/, pos_prefix.to_s)
56
+ when /^refute/ then
57
+ assertion.sub(/^refute/, neg_prefix.to_s)
58
+ end
59
+
60
+ next unless expectation
61
+ next if expectation =~ skip_re
62
+
63
+ regexp, replacement = map.find { |re, _| expectation =~ re }
64
+ expectation.sub! regexp, replacement if replacement
65
+
66
+ next if expectations.include? expectation
67
+
68
+ args = [assertion, expectation].map(&:to_sym).map(&:inspect)
69
+ args << :reverse if expectation =~ dont_flip_re
70
+
71
+ puts
72
+ puts "##"
73
+ puts "# :method: #{expectation}"
74
+ puts "# See Minitest::Assertions##{assertion}"
75
+ puts
76
+ puts "infect_an_assertion #{args.join ", "}"
44
77
  end
45
- rescue LoadError
46
- # skip
47
78
  end
48
79
 
49
- def loc dir
50
- system "find #{dir} -name \\*.rb | xargs wc -l | tail -1"
80
+ task :bugs do
81
+ sh "for f in bug*.rb ; do echo $f; echo; #{Gem.ruby} -Ilib $f && rm $f ; done"
51
82
  end
52
83
 
53
- desc "stupid line count"
54
- task :dickwag do
55
- puts
56
- puts "miniunit"
57
- puts
58
- print " lib loc"; loc "lib"
59
- print " test loc"; loc "test"
60
- print " totl loc"; loc "lib test"
61
- print " flog = "; system "flog -s lib"
62
-
63
- puts
64
- puts "test/unit"
65
- puts
66
- Dir.chdir File.expand_path("~/Work/svn/ruby/ruby_1_8") do
67
- print " lib loc"; loc "lib/test"
68
- print " test loc"; loc "test/testunit"
69
- print " totl loc"; loc "lib/test test/testunit"
70
- print " flog = "; system "flog -s lib/test"
71
- end
72
- puts
84
+ Minitest::TestTask.create :testW0 do |t|
85
+ t.warning = false
86
+ t.test_prelude = "$-w = nil"
73
87
  end
74
88
 
75
89
  # vim: syntax=Ruby
data/bin/minitest ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env -S ruby
2
+
3
+ require_relative "../lib/minitest/sprint"
4
+
5
+ Minitest::Sprint.run
@@ -0,0 +1,54 @@
1
+ # Specs: # Equivalent Unit Tests:
2
+ ###############################################################################
3
+ describe Thingy do # class TestThingy < Minitest::Test
4
+ before do # def setup
5
+ # super
6
+ do_some_setup # do_some_setup
7
+ end # end
8
+ #
9
+ it "should do the first thing" do # def test_first_thing
10
+ _(1).must_equal 1 # assert_equal 1, 1
11
+ end # end
12
+ # end
13
+ #
14
+ describe SubThingy do # class TestSubThingy < TestThingy
15
+ before do # def setup
16
+ # super
17
+ do_more_setup # do_more_setup
18
+ end # end
19
+ #
20
+ it "should do the second thing" do # def test_second_thing
21
+ _(2).must_equal 2 # assert_equal 2, 2
22
+ end # end
23
+ end # end
24
+ end #
25
+ #
26
+ ###############################################################################
27
+ # runs 2 specs # runs 3 tests
28
+ ###############################################################################
29
+ # The specs generate:
30
+
31
+ class ThingySpec < Minitest::Spec
32
+ def setup
33
+ super
34
+ do_some_setup
35
+ end
36
+
37
+ def test_should_do_the_first_thing
38
+ _(1).must_equal 1
39
+ end
40
+ end
41
+
42
+ class SubThingySpec < ThingySpec
43
+ def setup
44
+ super
45
+ do_more_setup
46
+ end
47
+
48
+ # because only setup/teardown is inherited, not specs
49
+ remove_method :test_should_do_the_first_thing
50
+
51
+ def test_should_do_the_second_thing
52
+ _(2).must_equal 2
53
+ end
54
+ end
@@ -0,0 +1,30 @@
1
+ # :stopdoc:
2
+
3
+ class Hoe
4
+ # empty
5
+ end
6
+
7
+ module Hoe::Minitest
8
+ def minitest?
9
+ self.name == "minitest"
10
+ end
11
+
12
+ def initialize_minitest
13
+ unless minitest? then
14
+ dir = File.expand_path "../..", __FILE__
15
+
16
+ Hoe.add_include_dirs dir if File.directory? dir
17
+ end
18
+
19
+ gem "minitest"
20
+ require "minitest"
21
+ version = Minitest::VERSION.split(".").first(2).join "."
22
+
23
+ dependency "minitest", "~> #{version}", :development unless
24
+ minitest? or ENV["MT_NO_ISOLATE"]
25
+ end
26
+
27
+ def define_minitest_tasks
28
+ self.testlib = :minitest
29
+ end
30
+ end