jferris-mocha 0.9.7.20090911190113 → 0.9.8.20100526112143

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/README +3 -1
  2. data/RELEASE +7 -0
  3. data/Rakefile +3 -3
  4. data/lib/mocha/configuration.rb +29 -10
  5. data/lib/mocha/expectation.rb +5 -1
  6. data/lib/mocha/integration/mini_test.rb +27 -2
  7. data/lib/mocha/integration/mini_test/exception_translation.rb +20 -0
  8. data/lib/mocha/integration/mini_test/version_13.rb +44 -0
  9. data/lib/mocha/integration/mini_test/{version_131_and_above.rb → version_140.rb} +7 -12
  10. data/lib/mocha/integration/mini_test/version_141.rb +56 -0
  11. data/lib/mocha/integration/mini_test/version_142_and_above.rb +56 -0
  12. data/lib/mocha/integration/test_unit.rb +20 -7
  13. data/lib/mocha/integration/test_unit/gem_version_200.rb +3 -0
  14. data/lib/mocha/integration/test_unit/{gem_version_201_and_above.rb → gem_version_201_to_202.rb} +4 -1
  15. data/lib/mocha/integration/test_unit/gem_version_203_to_207.rb +52 -0
  16. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +3 -0
  17. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +3 -0
  18. data/lib/mocha/mock.rb +0 -1
  19. data/lib/mocha/module_method.rb +1 -1
  20. data/lib/mocha/parameter_matchers/base.rb +50 -2
  21. data/lib/mocha/parameter_matchers/has_key.rb +1 -0
  22. data/lib/mocha/parameter_matchers/has_value.rb +1 -0
  23. data/lib/mocha/parameter_matchers/includes.rb +1 -0
  24. data/lib/mocha/parameter_matchers/regexp_matches.rb +1 -0
  25. data/test/acceptance/acceptance_test_helper.rb +1 -1
  26. data/test/acceptance/api_test.rb +1 -1
  27. data/test/acceptance/bug_18914_test.rb +1 -1
  28. data/test/acceptance/bug_21465_test.rb +1 -1
  29. data/test/acceptance/bug_21563_test.rb +1 -1
  30. data/test/acceptance/expected_invocation_count_test.rb +1 -1
  31. data/test/acceptance/failure_messages_test.rb +1 -1
  32. data/test/acceptance/minitest_test.rb +128 -124
  33. data/test/acceptance/mocha_example_test.rb +1 -1
  34. data/test/acceptance/mocha_test_result_test.rb +1 -1
  35. data/test/acceptance/mock_test.rb +1 -1
  36. data/test/acceptance/mock_with_initializer_block_test.rb +1 -1
  37. data/test/acceptance/mocked_methods_dispatch_test.rb +1 -1
  38. data/test/acceptance/optional_parameters_test.rb +1 -1
  39. data/test/acceptance/parameter_matcher_test.rb +38 -1
  40. data/test/acceptance/partial_mocks_test.rb +1 -1
  41. data/test/acceptance/return_value_test.rb +1 -1
  42. data/test/acceptance/sequence_test.rb +1 -1
  43. data/test/acceptance/states_test.rb +1 -1
  44. data/test/acceptance/stub_any_instance_method_test.rb +5 -2
  45. data/test/acceptance/stub_class_method_test.rb +5 -2
  46. data/test/acceptance/stub_everything_test.rb +1 -1
  47. data/test/acceptance/stub_instance_method_test.rb +5 -2
  48. data/test/acceptance/stub_module_method_test.rb +3 -3
  49. data/test/acceptance/stub_test.rb +1 -1
  50. data/test/acceptance/stubba_example_test.rb +1 -1
  51. data/test/acceptance/stubba_test.rb +1 -1
  52. data/test/acceptance/stubba_test_result_test.rb +1 -1
  53. data/test/acceptance/stubbing_error_backtrace_test.rb +1 -1
  54. data/test/acceptance/stubbing_method_unnecessarily_test.rb +1 -1
  55. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +5 -5
  56. data/test/acceptance/stubbing_non_existent_class_method_test.rb +5 -5
  57. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +5 -5
  58. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +9 -9
  59. data/test/acceptance/stubbing_non_public_class_method_test.rb +9 -9
  60. data/test/acceptance/stubbing_non_public_instance_method_test.rb +9 -9
  61. data/test/acceptance/stubbing_on_non_mock_object_test.rb +5 -5
  62. data/test/mini_test_result.rb +74 -0
  63. data/test/test_helper.rb +1 -0
  64. data/test/test_runner.rb +25 -11
  65. data/test/unit/any_instance_method_test.rb +1 -1
  66. data/test/unit/array_inspect_test.rb +1 -1
  67. data/test/unit/backtrace_filter_test.rb +1 -1
  68. data/test/unit/cardinality_test.rb +1 -1
  69. data/test/unit/central_test.rb +1 -1
  70. data/test/unit/change_state_side_effect_test.rb +1 -1
  71. data/test/unit/class_method_test.rb +1 -1
  72. data/test/unit/configuration_test.rb +38 -0
  73. data/test/unit/date_time_inspect_test.rb +1 -1
  74. data/test/unit/exception_raiser_test.rb +1 -1
  75. data/test/unit/expectation_list_test.rb +1 -1
  76. data/test/unit/expectation_test.rb +1 -1
  77. data/test/unit/hash_inspect_test.rb +1 -1
  78. data/test/unit/in_state_ordering_constraint_test.rb +1 -1
  79. data/test/unit/metaclass_test.rb +1 -1
  80. data/test/unit/method_matcher_test.rb +1 -1
  81. data/test/unit/mock_test.rb +1 -1
  82. data/test/unit/mockery_test.rb +1 -1
  83. data/test/unit/multiple_yields_test.rb +1 -1
  84. data/test/unit/no_yields_test.rb +1 -1
  85. data/test/unit/object_inspect_test.rb +9 -8
  86. data/test/unit/object_test.rb +1 -1
  87. data/test/unit/parameter_matchers/all_of_test.rb +1 -1
  88. data/test/unit/parameter_matchers/any_of_test.rb +1 -1
  89. data/test/unit/parameter_matchers/anything_test.rb +1 -1
  90. data/test/unit/parameter_matchers/equals_test.rb +1 -1
  91. data/test/unit/parameter_matchers/has_entries_test.rb +1 -1
  92. data/test/unit/parameter_matchers/has_entry_test.rb +1 -1
  93. data/test/unit/parameter_matchers/has_key_test.rb +20 -1
  94. data/test/unit/parameter_matchers/has_value_test.rb +21 -1
  95. data/test/unit/parameter_matchers/includes_test.rb +21 -2
  96. data/test/unit/parameter_matchers/instance_of_test.rb +1 -1
  97. data/test/unit/parameter_matchers/is_a_test.rb +1 -1
  98. data/test/unit/parameter_matchers/kind_of_test.rb +1 -1
  99. data/test/unit/parameter_matchers/not_test.rb +1 -1
  100. data/test/unit/parameter_matchers/regexp_matches_test.rb +22 -1
  101. data/test/unit/parameter_matchers/responds_with_test.rb +1 -1
  102. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +1 -1
  103. data/test/unit/parameters_matcher_test.rb +1 -1
  104. data/test/unit/return_values_test.rb +1 -1
  105. data/test/unit/sequence_test.rb +1 -1
  106. data/test/unit/single_return_value_test.rb +1 -1
  107. data/test/unit/single_yield_test.rb +1 -1
  108. data/test/unit/state_machine_test.rb +1 -1
  109. data/test/unit/string_inspect_test.rb +1 -1
  110. data/test/unit/yield_parameters_test.rb +1 -1
  111. metadata +39 -13
@@ -9,6 +9,9 @@ module Mocha
9
9
  module TestUnit
10
10
 
11
11
  module GemVersion200
12
+ def self.included(mod)
13
+ warn "Monkey patching Test::Unit gem v2.0.0"
14
+ end
12
15
  def run(result)
13
16
  assertion_counter = AssertionCounter.new(result)
14
17
  begin
@@ -8,7 +8,10 @@ module Mocha
8
8
 
9
9
  module TestUnit
10
10
 
11
- module GemVersion201AndAbove
11
+ module GemVersion201To202
12
+ def self.included(mod)
13
+ warn "Monkey patching Test::Unit gem >= v2.0.1 and <= v2.0.2"
14
+ end
12
15
  def run(result)
13
16
  assertion_counter = AssertionCounter.new(result)
14
17
  begin
@@ -0,0 +1,52 @@
1
+ require 'test/unit/testcase'
2
+ require 'mocha/integration/test_unit/assertion_counter'
3
+ require 'mocha/expectation_error'
4
+
5
+ module Mocha
6
+
7
+ module Integration
8
+
9
+ module TestUnit
10
+
11
+ module GemVersion203To207
12
+ def self.included(mod)
13
+ warn "Monkey patching Test::Unit gem >= v2.0.3 and <= v2.0.7"
14
+ end
15
+ def run(result)
16
+ assertion_counter = AssertionCounter.new(result)
17
+ begin
18
+ @_result = result
19
+ yield(Test::Unit::TestCase::STARTED, name)
20
+ begin
21
+ begin
22
+ run_setup
23
+ run_test
24
+ mocha_verify(assertion_counter)
25
+ rescue Mocha::ExpectationError => e
26
+ add_failure(e.message, e.backtrace)
27
+ rescue Exception
28
+ @interrupted = true
29
+ raise unless handle_exception($!)
30
+ ensure
31
+ begin
32
+ run_teardown
33
+ rescue Exception
34
+ raise unless handle_exception($!)
35
+ end
36
+ end
37
+ ensure
38
+ mocha_teardown
39
+ end
40
+ result.add_run
41
+ yield(Test::Unit::TestCase::FINISHED, name)
42
+ ensure
43
+ # @_result = nil # For test-spec's after_all :<
44
+ end
45
+ end
46
+ end
47
+
48
+ end
49
+
50
+ end
51
+
52
+ end
@@ -9,6 +9,9 @@ module Mocha
9
9
  module TestUnit
10
10
 
11
11
  module RubyVersion185AndBelow
12
+ def self.included(mod)
13
+ warn "Monkey patching Test::Unit for Ruby <= v1.8.5"
14
+ end
12
15
  def run(result)
13
16
  assertion_counter = AssertionCounter.new(result)
14
17
  yield(Test::Unit::TestCase::STARTED, name)
@@ -9,6 +9,9 @@ module Mocha
9
9
  module TestUnit
10
10
 
11
11
  module RubyVersion186AndAbove
12
+ def self.included(mod)
13
+ warn "Monkey patching Test::Unit for Ruby >= v1.8.6"
14
+ end
12
15
  def run(result)
13
16
  assertion_counter = AssertionCounter.new(result)
14
17
  yield(Test::Unit::TestCase::STARTED, name)
@@ -2,7 +2,6 @@ require 'mocha/expectation'
2
2
  require 'mocha/expectation_list'
3
3
  require 'mocha/metaclass'
4
4
  require 'mocha/names'
5
- require 'mocha/mockery'
6
5
  require 'mocha/method_matcher'
7
6
  require 'mocha/parameters_matcher'
8
7
  require 'mocha/unexpected_invocation'
@@ -1,4 +1,4 @@
1
- require 'mocha/module_method'
1
+ require 'mocha/class_method'
2
2
 
3
3
  module Mocha
4
4
 
@@ -2,12 +2,60 @@ module Mocha
2
2
 
3
3
  module ParameterMatchers
4
4
 
5
- class Base # :nodoc:
5
+ class Base
6
6
 
7
- def to_matcher
7
+ def to_matcher # :nodoc:
8
8
  self
9
9
  end
10
10
 
11
+ # :call-seq: &(matcher) -> parameter_matcher
12
+ #
13
+ # A short hand way of specifying multiple matchers that should
14
+ # all match.
15
+ #
16
+ # Returns a new +AllOf+ parameter matcher combining the
17
+ # given matcher and the receiver.
18
+ #
19
+ # The following statements are equivalent:
20
+ # object = mock()
21
+ # object.expects(:run).with(all_of(has_key(:foo), has_key(:bar)))
22
+ # object.run(:foo => 'foovalue', :bar => 'barvalue')
23
+ #
24
+ # # with the shorthand
25
+ # object.expects(:run).with(has_key(:foo) & has_key(:bar))
26
+ # object.run(:foo => 'foovalue', :bar => 'barvalue)
27
+ def &(matcher)
28
+ AllOf.new(self, matcher)
29
+ end
30
+
31
+ # :call-seq: |(matcher) -> parameter_matcher
32
+ #
33
+ # A short hand way of specifying multiple matchers, only at least
34
+ # one of which should pass.
35
+ #
36
+ # Returns a new +AnyOf+ parameter matcher combining the
37
+ # given matcher and the receiver.
38
+ #
39
+ # The following statements are equivalent:
40
+ # object = mock()
41
+ # object.expects(:run).with(any_of(has_key(:foo), has_key(:bar)))
42
+ # object.run(:foo => 'foovalue')
43
+ #
44
+ # # with the shorthand
45
+ # object.expects(:run).with(has_key(:foo) | has_key(:bar))
46
+ # object.run(:foo => 'foovalue')
47
+ #
48
+ # This shorthand will not work with an implicit equals match. Instead,
49
+ # an explicit equals matcher should be used:
50
+ #
51
+ # object.expects(:run).with(equals(1) | equals(2))
52
+ # object.run(1) # passes
53
+ # object.run(2) # passes
54
+ # object.run(3) # fails
55
+ def |(matcher)
56
+ AnyOf.new(self, matcher)
57
+ end
58
+
11
59
  end
12
60
 
13
61
  end
@@ -28,6 +28,7 @@ module Mocha
28
28
 
29
29
  def matches?(available_parameters)
30
30
  parameter = available_parameters.shift
31
+ return false unless parameter.respond_to?(:keys)
31
32
  parameter.keys.any? { |key| @key.to_matcher.matches?([key]) }
32
33
  end
33
34
 
@@ -28,6 +28,7 @@ module Mocha
28
28
 
29
29
  def matches?(available_parameters)
30
30
  parameter = available_parameters.shift
31
+ return false unless parameter.respond_to?(:values)
31
32
  parameter.values.any? { |value| @value.to_matcher.matches?([value]) }
32
33
  end
33
34
 
@@ -26,6 +26,7 @@ module Mocha
26
26
 
27
27
  def matches?(available_parameters)
28
28
  parameter = available_parameters.shift
29
+ return false unless parameter.respond_to?(:include?)
29
30
  return parameter.include?(@item)
30
31
  end
31
32
 
@@ -29,6 +29,7 @@ module Mocha
29
29
 
30
30
  def matches?(available_parameters)
31
31
  parameter = available_parameters.shift
32
+ return false unless parameter.respond_to?(:=~)
32
33
  parameter =~ @regexp
33
34
  end
34
35
 
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), "..", "test_helper")
1
+ require File.expand_path('../../test_helper', __FILE__)
2
2
  require 'test_runner'
3
3
  require 'mocha/configuration'
4
4
 
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), "acceptance_test_helper")
1
+ require File.expand_path('../acceptance_test_helper', __FILE__)
2
2
  require 'mocha_standalone'
3
3
  require 'simple_counter'
4
4
 
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), "acceptance_test_helper")
1
+ require File.expand_path('../acceptance_test_helper', __FILE__)
2
2
  require 'mocha'
3
3
 
4
4
  class Bug18914Test < Test::Unit::TestCase
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), "acceptance_test_helper")
1
+ require File.expand_path('../acceptance_test_helper', __FILE__)
2
2
  require 'mocha'
3
3
 
4
4
  class Bug21465Test < Test::Unit::TestCase
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), "acceptance_test_helper")
1
+ require File.expand_path('../acceptance_test_helper', __FILE__)
2
2
  require 'mocha'
3
3
 
4
4
  class Bug21563Test < Test::Unit::TestCase
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), "acceptance_test_helper")
1
+ require File.expand_path('../acceptance_test_helper', __FILE__)
2
2
  require 'mocha'
3
3
 
4
4
  class ExpectedInvocationCountTest < Test::Unit::TestCase
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), "acceptance_test_helper")
1
+ require File.expand_path('../acceptance_test_helper', __FILE__)
2
2
  require 'mocha'
3
3
 
4
4
  class FailureMessagesTest < Test::Unit::TestCase
@@ -1,153 +1,157 @@
1
- require File.join(File.dirname(__FILE__), "acceptance_test_helper")
1
+ require File.expand_path('../acceptance_test_helper', __FILE__)
2
2
 
3
- begin
4
- require 'rubygems'
5
- gem 'minitest'
6
- rescue Gem::LoadError
7
- # MiniTest gem not available
8
- end
3
+ if defined?(MiniTest)
4
+ warn "TODO: Running suite with MiniTest, running the MiniTestAdapterTest results in an error so skipping it for now."
5
+ else
6
+ begin
7
+ require 'rubygems'
8
+ gem 'minitest'
9
+ rescue Gem::LoadError
10
+ # MiniTest gem not available
11
+ end
9
12
 
10
- begin
11
- require 'minitest/unit'
12
- rescue LoadError
13
- # MiniTest not available
14
- end
13
+ begin
14
+ require 'minitest/unit'
15
+ rescue LoadError
16
+ # MiniTest not available
17
+ end
15
18
 
16
- if defined?(MiniTest)
19
+ if defined?(MiniTest)
17
20
 
18
- # monkey-patch MiniTest now that it has hopefully been loaded
19
- require 'mocha/integration/mini_test'
21
+ # monkey-patch MiniTest now that it has hopefully been loaded
22
+ require 'mocha/integration/mini_test'
20
23
 
21
- class MiniTestSampleTest < MiniTest::Unit::TestCase
22
-
23
- def test_mocha_with_fulfilled_expectation
24
- mockee = mock()
25
- mockee.expects(:blah)
26
- mockee.blah
27
- end
28
-
29
- def test_mocha_with_unfulfilled_expectation
30
- mockee = mock()
31
- mockee.expects(:blah)
32
- end
24
+ class MiniTestSampleTest < MiniTest::Unit::TestCase
25
+
26
+ def test_mocha_with_fulfilled_expectation
27
+ mockee = mock()
28
+ mockee.expects(:blah)
29
+ mockee.blah
30
+ end
31
+
32
+ def test_mocha_with_unfulfilled_expectation
33
+ mockee = mock()
34
+ mockee.expects(:blah)
35
+ end
36
+
37
+ def test_mocha_with_unexpected_invocation
38
+ mockee = mock()
39
+ mockee.blah
40
+ end
41
+
42
+ def test_stubba_with_fulfilled_expectation
43
+ stubbee = Class.new { define_method(:blah) {} }.new
44
+ stubbee.expects(:blah)
45
+ stubbee.blah
46
+ end
47
+
48
+ def test_stubba_with_unfulfilled_expectation
49
+ stubbee = Class.new { define_method(:blah) {} }.new
50
+ stubbee.expects(:blah)
51
+ end
52
+
53
+ def test_mocha_with_matching_parameter
54
+ mockee = mock()
55
+ mockee.expects(:blah).with(has_key(:wibble))
56
+ mockee.blah(:wibble => 1)
57
+ end
58
+
59
+ def test_mocha_with_non_matching_parameter
60
+ mockee = mock()
61
+ mockee.expects(:blah).with(has_key(:wibble))
62
+ mockee.blah(:wobble => 2)
63
+ end
33
64
 
34
- def test_mocha_with_unexpected_invocation
35
- mockee = mock()
36
- mockee.blah
37
65
  end
38
-
39
- def test_stubba_with_fulfilled_expectation
40
- stubbee = Class.new { define_method(:blah) {} }.new
41
- stubbee.expects(:blah)
42
- stubbee.blah
43
- end
44
-
45
- def test_stubba_with_unfulfilled_expectation
46
- stubbee = Class.new { define_method(:blah) {} }.new
47
- stubbee.expects(:blah)
48
- end
49
-
50
- def test_mocha_with_matching_parameter
51
- mockee = mock()
52
- mockee.expects(:blah).with(has_key(:wibble))
53
- mockee.blah(:wibble => 1)
54
- end
55
-
56
- def test_mocha_with_non_matching_parameter
57
- mockee = mock()
58
- mockee.expects(:blah).with(has_key(:wibble))
59
- mockee.blah(:wobble => 2)
60
- end
61
-
62
- end
63
66
 
64
- class MiniTestTest < Test::Unit::TestCase
67
+ class MiniTestTest < Test::Unit::TestCase
65
68
 
66
- def setup
67
- @output = StringIO.new
68
- MiniTest::Unit.output = @output
69
- @runner = MiniTest::Unit.new
70
- end
69
+ def setup
70
+ @output = StringIO.new
71
+ MiniTest::Unit.output = @output
72
+ @runner = MiniTest::Unit.new
73
+ end
71
74
 
72
- attr_reader :runner
75
+ attr_reader :runner
73
76
 
74
- def test_should_pass_mocha_test
75
- runner.run(%w(-n test_mocha_with_fulfilled_expectation))
77
+ def test_should_pass_mocha_test
78
+ runner.run(%w(-n test_mocha_with_fulfilled_expectation))
76
79
 
77
- assert_equal 0, runner.failures
78
- assert_equal 0, runner.errors
79
- assert_equal 1, runner.assertion_count
80
- end
80
+ assert_equal 0, runner.failures
81
+ assert_equal 0, runner.errors
82
+ assert_equal 1, runner.assertion_count
83
+ end
81
84
 
82
- def test_should_fail_mocha_test_due_to_unfulfilled_expectation
83
- runner.run(%w(-n test_mocha_with_unfulfilled_expectation))
85
+ def test_should_fail_mocha_test_due_to_unfulfilled_expectation
86
+ runner.run(%w(-n test_mocha_with_unfulfilled_expectation))
84
87
 
85
- assert_equal 1, runner.failures
86
- assert_equal 0, runner.errors
87
- assert_equal 1, runner.assertion_count
88
- assert_not_all_expectation_were_satisfied
89
- end
90
-
91
- def test_should_fail_mocha_test_due_to_unexpected_invocation
92
- runner.run(%w(-n test_mocha_with_unexpected_invocation))
88
+ assert_equal 1, runner.failures
89
+ assert_equal 0, runner.errors
90
+ assert_equal 1, runner.assertion_count
91
+ assert_not_all_expectation_were_satisfied
92
+ end
93
+
94
+ def test_should_fail_mocha_test_due_to_unexpected_invocation
95
+ runner.run(%w(-n test_mocha_with_unexpected_invocation))
93
96
 
94
- assert_equal 1, runner.failures
95
- assert_equal 0, runner.errors
96
- assert_equal 0, runner.assertion_count
97
- assert_unexpected_invocation
98
- end
99
-
100
- def test_should_pass_stubba_test
101
- runner.run(%w(-n test_stubba_with_fulfilled_expectation))
97
+ assert_equal 1, runner.failures
98
+ assert_equal 0, runner.errors
99
+ assert_equal 0, runner.assertion_count
100
+ assert_unexpected_invocation
101
+ end
102
+
103
+ def test_should_pass_stubba_test
104
+ runner.run(%w(-n test_stubba_with_fulfilled_expectation))
102
105
 
103
- assert_equal 0, runner.failures
104
- assert_equal 0, runner.errors
105
- assert_equal 1, runner.assertion_count
106
- end
106
+ assert_equal 0, runner.failures
107
+ assert_equal 0, runner.errors
108
+ assert_equal 1, runner.assertion_count
109
+ end
107
110
 
108
- def test_should_fail_stubba_test_due_to_unfulfilled_expectation
109
- runner.run(%w(-n test_stubba_with_unfulfilled_expectation))
111
+ def test_should_fail_stubba_test_due_to_unfulfilled_expectation
112
+ runner.run(%w(-n test_stubba_with_unfulfilled_expectation))
110
113
 
111
- assert_equal 1, runner.failures
112
- assert_equal 0, runner.errors
113
- assert_equal 1, runner.assertion_count
114
- assert_not_all_expectation_were_satisfied
115
- end
116
-
117
- def test_should_pass_mocha_test_with_matching_parameter
118
- runner.run(%w(-n test_mocha_with_matching_parameter))
114
+ assert_equal 1, runner.failures
115
+ assert_equal 0, runner.errors
116
+ assert_equal 1, runner.assertion_count
117
+ assert_not_all_expectation_were_satisfied
118
+ end
119
+
120
+ def test_should_pass_mocha_test_with_matching_parameter
121
+ runner.run(%w(-n test_mocha_with_matching_parameter))
119
122
 
120
- assert_equal 0, runner.failures
121
- assert_equal 0, runner.errors
122
- assert_equal 1, runner.assertion_count
123
- end
123
+ assert_equal 0, runner.failures
124
+ assert_equal 0, runner.errors
125
+ assert_equal 1, runner.assertion_count
126
+ end
124
127
 
125
- def test_should_fail_mocha_test_with_non_matching_parameter
126
- runner.run(%w(-n test_mocha_with_non_matching_parameter))
128
+ def test_should_fail_mocha_test_with_non_matching_parameter
129
+ runner.run(%w(-n test_mocha_with_non_matching_parameter))
127
130
 
128
- assert_equal 1, runner.failures
129
- assert_equal 0, runner.errors
130
- assert_equal 0, runner.assertion_count # unexpected invocation occurs before expectation is verified
131
- assert_unexpected_invocation
132
- end
131
+ assert_equal 1, runner.failures
132
+ assert_equal 0, runner.errors
133
+ assert_equal 0, runner.assertion_count # unexpected invocation occurs before expectation is verified
134
+ assert_unexpected_invocation
135
+ end
133
136
 
134
- private
137
+ private
135
138
 
136
- def output
137
- @output.rewind
138
- @output.read
139
- end
139
+ def output
140
+ @output.rewind
141
+ @output.read
142
+ end
140
143
 
141
- def assert_unexpected_invocation
142
- assert_match Regexp.new('unexpected invocation'), output, "MiniTest output:\n#{output}"
143
- end
144
+ def assert_unexpected_invocation
145
+ assert_match Regexp.new('unexpected invocation'), output, "MiniTest output:\n#{output}"
146
+ end
147
+
148
+ def assert_not_all_expectation_were_satisfied
149
+ assert_match Regexp.new('not all expectations were satisfied'), output, "MiniTest output:\n#{output}"
150
+ end
144
151
 
145
- def assert_not_all_expectation_were_satisfied
146
- assert_match Regexp.new('not all expectations were satisfied'), output, "MiniTest output:\n#{output}"
147
152
  end
148
153
 
154
+ else
155
+ warn "MiniTest is not available, so MiniTestAdapterTest has not been run."
149
156
  end
150
-
151
- else
152
- warn "MiniTest is not available, so MiniTestAdapterTest has not been run."
153
157
  end