minitest 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -1,3 +1,19 @@
1
+ === 1.4.0 / 2009-06-18
2
+
3
+ * 5 minor enhancement:
4
+
5
+ * Added clarification doco.
6
+ * Added specs and mocks to autorun.
7
+ * Changed spec test class creation to be non-destructive.
8
+ * Updated rakefile for new hoe capabilities.
9
+ * describes are nestable (via subclass). before/after/def inherits, specs don't.
10
+
11
+ * 3 bug fixes:
12
+
13
+ * Fixed location on must/wont.
14
+ * Switched to __name__ to avoid common ivar name.
15
+ * Fixed indentation in test file (1.9).
16
+
1
17
  === 1.3.1 / 2009-01-20
2
18
 
3
19
  * 1 minor enhancement:
@@ -3,6 +3,7 @@ History.txt
3
3
  Manifest.txt
4
4
  README.txt
5
5
  Rakefile
6
+ design_rationale.rb
6
7
  lib/minitest/autorun.rb
7
8
  lib/minitest/mock.rb
8
9
  lib/minitest/spec.rb
data/README.txt CHANGED
@@ -22,6 +22,10 @@ mini/mock, by Steven Baker, is a beautifully tiny mock object framework.
22
22
  * Contains minitest/mock - a simple and clean mock system (35 lines!).
23
23
  * Incredibly small and fast runner, but no bells and whistles.
24
24
 
25
+ == RATIONALE:
26
+
27
+ See design_rationale.rb to see how specs and tests work in minitest.
28
+
25
29
  == REQUIREMENTS:
26
30
 
27
31
  + Ruby 1.8, maybe even 1.6 or lower. No magic is involved.
data/Rakefile CHANGED
@@ -4,46 +4,13 @@ $TESTING_MINIUNIT = true
4
4
 
5
5
  require 'rubygems'
6
6
  require 'hoe'
7
- require './lib/minitest/unit.rb'
8
7
 
9
- Hoe.new('minitest', MiniTest::Unit::VERSION) do |miniunit|
10
- miniunit.rubyforge_name = "bfts"
8
+ Hoe.plugin :seattlerb
11
9
 
12
- miniunit.developer('Ryan Davis', 'ryand-ruby@zenspider.com')
13
- end
14
-
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}"
20
-
21
- send :ruby, cmd
22
- end
23
- end
10
+ Hoe.spec 'minitest' do
11
+ developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
24
12
 
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
32
-
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
37
-
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
44
- end
45
- rescue LoadError
46
- # skip
13
+ self.rubyforge_name = "bfts"
47
14
  end
48
15
 
49
16
  def loc dir
@@ -0,0 +1,52 @@
1
+ # Specs: # Equivalent Unit Tests:
2
+ ###############################################################################
3
+ describe Thingy do # class TestThingy < MiniTest::Unit::TestCase
4
+ before do # def setup
5
+ do_some_setup # super
6
+ end # do_some_setup
7
+ # end
8
+ it "should do the first thing" do #
9
+ 1.must_equal 1 # def test_first_thing
10
+ end # assert_equal 1, 1
11
+ # end
12
+ describe SubThingy do # end
13
+ before do #
14
+ do_more_setup # class TestSubThingy < TestThingy
15
+ end # def setup
16
+ # super
17
+ it "should do the second thing" do # do_more_setup
18
+ 2.must_equal 2 # end
19
+ end #
20
+ end # def test_second_thing
21
+ end # assert_equal 2, 2
22
+ # end
23
+ # end
24
+ ###############################################################################
25
+ # runs 2 specs # runs 3 tests
26
+ ###############################################################################
27
+ # The specs generate:
28
+
29
+ class ThingySpec < MiniTest::Spec
30
+ def setup
31
+ super
32
+ do_some_setup
33
+ end
34
+
35
+ def test_should_do_the_first_thing
36
+ assert_equal 1, 1
37
+ end
38
+ end
39
+
40
+ class SubThingySpec < ThingySpec
41
+ def setup
42
+ super
43
+ do_more_setup
44
+ end
45
+
46
+ # because only setup/teardown is inherited, not specs
47
+ remove_method :test_should_do_the_first_thing
48
+
49
+ def test_should_do_the_second_thing
50
+ assert_equal 2, 2
51
+ end
52
+ end
@@ -1,3 +1,5 @@
1
1
  require 'minitest/unit'
2
+ require 'minitest/spec'
3
+ require 'minitest/mock'
2
4
 
3
5
  MiniTest::Unit.autorun
@@ -49,15 +49,25 @@ end
49
49
 
50
50
  module Kernel
51
51
  def describe desc, &block
52
- cls = Class.new(MiniTest::Spec)
53
- Object.const_set desc.to_s.split(/\W+/).map { |s| s.capitalize }.join, cls
52
+ stack = MiniTest::Spec.describe_stack
53
+ name = desc.to_s.split(/\W+/).map { |s| s.capitalize }.join + "Spec"
54
+ cls = Object.class_eval "class #{name} < #{stack.last}; end; #{name}"
54
55
 
56
+ cls.nuke_test_methods!
57
+
58
+ stack.push cls
55
59
  cls.class_eval(&block)
60
+ stack.pop
56
61
  end
57
62
  private :describe
58
63
  end
59
64
 
60
65
  class MiniTest::Spec < MiniTest::Unit::TestCase
66
+ @@describe_stack = [MiniTest::Spec]
67
+ def self.describe_stack
68
+ @@describe_stack
69
+ end
70
+
61
71
  def self.current
62
72
  @@current_spec
63
73
  end
@@ -67,14 +77,29 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
67
77
  @@current_spec = self
68
78
  end
69
79
 
80
+ def self.nuke_test_methods!
81
+ self.public_instance_methods.grep(/^test_/).each do |name|
82
+ send :remove_method, name rescue nil
83
+ end
84
+ end
85
+
86
+ def self.define_inheritable_method name, &block
87
+ super_method = self.superclass.instance_method name
88
+
89
+ define_method name do
90
+ super_method.bind(self).call if super_method # regular super() warns
91
+ instance_eval(&block)
92
+ end
93
+ end
94
+
70
95
  def self.before(type = :each, &block)
71
96
  raise "unsupported before type: #{type}" unless type == :each
72
- define_method :setup, &block
97
+ define_inheritable_method :setup, &block
73
98
  end
74
99
 
75
100
  def self.after(type = :each, &block)
76
101
  raise "unsupported after type: #{type}" unless type == :each
77
- define_method :teardown, &block
102
+ define_inheritable_method :teardown, &block
78
103
  end
79
104
 
80
105
  def self.it desc, &block
@@ -313,7 +313,7 @@ module MiniTest
313
313
  end
314
314
 
315
315
  class Unit
316
- VERSION = "1.3.1"
316
+ VERSION = "1.4.0"
317
317
 
318
318
  attr_accessor :report, :failures, :errors, :skips
319
319
  attr_accessor :test_count, :assertion_count
@@ -337,7 +337,7 @@ module MiniTest
337
337
  def location e
338
338
  last_before_assertion = ""
339
339
  e.backtrace.reverse_each do |s|
340
- break if s =~ /in .(assert|refute|flunk|pass|fail|raise)/
340
+ break if s =~ /in .(assert|refute|flunk|pass|fail|raise|must|wont)/
341
341
  last_before_assertion = s
342
342
  end
343
343
  last_before_assertion.sub(/:in .*$/, '')
@@ -424,30 +424,30 @@ module MiniTest
424
424
  end
425
425
 
426
426
  class TestCase
427
- attr_reader :name
427
+ attr_reader :__name__
428
428
 
429
429
  def run runner
430
430
  result = '.'
431
431
  begin
432
432
  @passed = nil
433
433
  self.setup
434
- self.__send__ self.name
434
+ self.__send__ self.__name__
435
435
  @passed = true
436
436
  rescue Exception => e
437
437
  @passed = false
438
- result = runner.puke(self.class, self.name, e)
438
+ result = runner.puke(self.class, self.__name__, e)
439
439
  ensure
440
440
  begin
441
441
  self.teardown
442
442
  rescue Exception => e
443
- result = runner.puke(self.class, self.name, e)
443
+ result = runner.puke(self.class, self.__name__, e)
444
444
  end
445
445
  end
446
446
  result
447
447
  end
448
448
 
449
449
  def initialize name
450
- @name = name
450
+ @__name__ = name
451
451
  @passed = nil
452
452
  end
453
453
 
@@ -319,7 +319,8 @@ Finished in 0.00
319
319
  output.sub!(/^(\s+)(?:#{Regexp.union(__FILE__, File.expand_path(__FILE__))}):\d+:/o, '\1FILE:LINE:')
320
320
  output.sub!(/\[(?:#{Regexp.union(__FILE__, File.expand_path(__FILE__))}):\d+\]/o, '[FILE:LINE]')
321
321
  assert_equal(expected, output)
322
- end
322
+ end
323
+
323
324
  def test_run_failing_filtered
324
325
  tc = Class.new(MiniTest::Unit::TestCase) do
325
326
  def test_something
metadata CHANGED
@@ -1,15 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
14
+ ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
+ GRYDY29tMB4XDTA5MDMwNjE4NTMxNVoXDTEwMDMwNjE4NTMxNVowRTETMBEGA1UE
16
+ AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
+ JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
+ b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
19
+ taCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx5JxgJxUjmGa7xhcT
20
+ oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh
21
+ GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
22
+ qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
+ gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
+ HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBBQUAA4IB
25
+ AQAY59gYvDxqSqgC92nAP9P8dnGgfZgLxP237xS6XxFGJSghdz/nI6pusfCWKM8m
26
+ vzjjH2wUMSSf3tNudQ3rCGLf2epkcU13/rguI88wO6MrE0wi4ZqLQX+eZQFskJb/
27
+ w6x9W1ur8eR01s397LSMexySDBrJOh34cm2AlfKr/jokKCTwcM0OvVZnAutaovC0
28
+ l1SVZ0ecg88bsWHA0Yhh7NFxK1utWoIhtB6AFC/+trM0FQEB/jZkIS8SaNzn96Rl
29
+ n0sZEf77FLf5peR8TP/PtmIg7Cyqz23sLM4mCOoTGIy5OcZ8TdyiyINUHtb5ej/T
30
+ FBHgymkyj/AOSqKRIpXPhjC6
31
+ -----END CERTIFICATE-----
11
32
 
12
- date: 2009-01-20 00:00:00 -08:00
33
+ date: 2009-06-18 00:00:00 -07:00
13
34
  default_executable:
14
35
  dependencies:
15
36
  - !ruby/object:Gem::Dependency
@@ -20,9 +41,19 @@ dependencies:
20
41
  requirements:
21
42
  - - ">="
22
43
  - !ruby/object:Gem::Version
23
- version: 1.8.2
44
+ version: 2.1.0
24
45
  version:
25
- description: minitest/unit is a small and fast replacement for ruby's huge and slow test/unit. This is meant to be clean and easy to use both as a regular test writer and for language implementors that need a minimal set of methods to bootstrap a working unit test suite. mini/spec is a functionally complete spec engine. mini/mock, by Steven Baker, is a beautifully tiny mock object framework. (This package was called miniunit once upon a time)
46
+ description: |-
47
+ minitest/unit is a small and fast replacement for ruby's huge and slow
48
+ test/unit. This is meant to be clean and easy to use both as a regular
49
+ test writer and for language implementors that need a minimal set of
50
+ methods to bootstrap a working unit test suite.
51
+
52
+ mini/spec is a functionally complete spec engine.
53
+
54
+ mini/mock, by Steven Baker, is a beautifully tiny mock object framework.
55
+
56
+ (This package was called miniunit once upon a time)
26
57
  email:
27
58
  - ryand-ruby@zenspider.com
28
59
  executables: []
@@ -39,6 +70,7 @@ files:
39
70
  - Manifest.txt
40
71
  - README.txt
41
72
  - Rakefile
73
+ - design_rationale.rb
42
74
  - lib/minitest/autorun.rb
43
75
  - lib/minitest/mock.rb
44
76
  - lib/minitest/spec.rb
@@ -48,6 +80,8 @@ files:
48
80
  - test/test_mini_test.rb
49
81
  has_rdoc: true
50
82
  homepage: http://rubyforge.org/projects/bfts
83
+ licenses: []
84
+
51
85
  post_install_message:
52
86
  rdoc_options:
53
87
  - --main
@@ -69,9 +103,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
103
  requirements: []
70
104
 
71
105
  rubyforge_project: bfts
72
- rubygems_version: 1.3.1
106
+ rubygems_version: 1.3.4
73
107
  signing_key:
74
- specification_version: 2
108
+ specification_version: 3
75
109
  summary: minitest/unit is a small and fast replacement for ruby's huge and slow test/unit
76
110
  test_files:
77
111
  - test/test_mini_mock.rb
Binary file