mocha 0.9.5 → 0.9.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 (61) hide show
  1. data/RELEASE +17 -2
  2. data/Rakefile +10 -7
  3. data/examples/misc.rb +0 -1
  4. data/examples/mocha.rb +0 -1
  5. data/examples/stubba.rb +0 -1
  6. data/lib/mocha.rb +1 -47
  7. data/lib/mocha/any_instance_method.rb +5 -1
  8. data/lib/mocha/{standalone.rb → api.rb} +8 -1
  9. data/lib/mocha/class_method.rb +5 -1
  10. data/lib/mocha/expectation.rb +3 -3
  11. data/lib/mocha/integration.rb +38 -0
  12. data/lib/mocha/integration/mini_test.rb +21 -0
  13. data/lib/mocha/integration/mini_test/assertion_counter.rb +23 -0
  14. data/lib/mocha/integration/mini_test/version_131_and_above.rb +50 -0
  15. data/lib/mocha/integration/test_unit.rb +40 -0
  16. data/lib/mocha/integration/test_unit/assertion_counter.rb +23 -0
  17. data/lib/mocha/integration/test_unit/gem_version_200.rb +49 -0
  18. data/lib/mocha/integration/test_unit/gem_version_201_and_above.rb +49 -0
  19. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +48 -0
  20. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +50 -0
  21. data/lib/mocha/parameter_matchers/has_entry.rb +1 -0
  22. data/lib/mocha_standalone.rb +2 -2
  23. data/test/acceptance/{standalone_test.rb → api_test.rb} +2 -2
  24. data/test/acceptance/bug_21465_test.rb +2 -2
  25. data/test/acceptance/bug_21563_test.rb +1 -1
  26. data/test/acceptance/expected_invocation_count_test.rb +19 -19
  27. data/test/acceptance/failure_messages_test.rb +6 -6
  28. data/test/acceptance/minitest_test.rb +32 -9
  29. data/test/acceptance/mocha_test_result_test.rb +8 -8
  30. data/test/acceptance/mock_test.rb +10 -10
  31. data/test/acceptance/mock_with_initializer_block_test.rb +3 -3
  32. data/test/acceptance/mocked_methods_dispatch_test.rb +5 -5
  33. data/test/acceptance/optional_parameters_test.rb +6 -6
  34. data/test/acceptance/parameter_matcher_test.rb +20 -20
  35. data/test/acceptance/partial_mocks_test.rb +2 -2
  36. data/test/acceptance/return_value_test.rb +4 -4
  37. data/test/acceptance/sequence_test.rb +11 -11
  38. data/test/acceptance/states_test.rb +4 -4
  39. data/test/acceptance/stub_any_instance_method_test.rb +12 -12
  40. data/test/acceptance/stub_class_method_test.rb +12 -12
  41. data/test/acceptance/stub_everything_test.rb +4 -4
  42. data/test/acceptance/stub_instance_method_test.rb +13 -13
  43. data/test/acceptance/stub_module_method_test.rb +12 -12
  44. data/test/acceptance/stub_test.rb +4 -4
  45. data/test/acceptance/stubba_test.rb +1 -1
  46. data/test/acceptance/stubba_test_result_test.rb +6 -6
  47. data/test/acceptance/stubbing_error_backtrace_test.rb +4 -4
  48. data/test/acceptance/stubbing_method_unnecessarily_test.rb +5 -5
  49. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +10 -10
  50. data/test/acceptance/stubbing_non_existent_class_method_test.rb +11 -11
  51. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +11 -11
  52. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +9 -9
  53. data/test/acceptance/stubbing_non_public_class_method_test.rb +10 -10
  54. data/test/acceptance/stubbing_non_public_instance_method_test.rb +10 -10
  55. data/test/acceptance/stubbing_on_non_mock_object_test.rb +5 -5
  56. data/test/test_helper.rb +4 -0
  57. data/test/test_runner.rb +1 -1
  58. data/test/unit/parameter_matchers/has_entry_test.rb +20 -0
  59. metadata +14 -6
  60. data/lib/mocha/mini_test_adapter.rb +0 -50
  61. data/lib/mocha/test_case_adapter.rb +0 -103
@@ -0,0 +1,49 @@
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 GemVersion201AndAbove
12
+ def run(result)
13
+ assertion_counter = AssertionCounter.new(result)
14
+ begin
15
+ @_result = result
16
+ yield(Test::Unit::TestCase::STARTED, name)
17
+ begin
18
+ begin
19
+ run_setup
20
+ run_test
21
+ mocha_verify(assertion_counter)
22
+ rescue Mocha::ExpectationError => e
23
+ add_failure(e.message, e.backtrace)
24
+ rescue Exception
25
+ @interrupted = true
26
+ raise unless handle_exception($!)
27
+ ensure
28
+ begin
29
+ run_teardown
30
+ rescue Exception
31
+ raise unless handle_exception($!)
32
+ end
33
+ end
34
+ ensure
35
+ mocha_teardown
36
+ end
37
+ result.add_run
38
+ yield(Test::Unit::TestCase::FINISHED, name)
39
+ ensure
40
+ @_result = nil
41
+ end
42
+ end
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,48 @@
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 RubyVersion185AndBelow
12
+ def run(result)
13
+ assertion_counter = AssertionCounter.new(result)
14
+ yield(Test::Unit::TestCase::STARTED, name)
15
+ @_result = result
16
+ begin
17
+ begin
18
+ setup
19
+ __send__(@method_name)
20
+ mocha_verify(assertion_counter)
21
+ rescue Mocha::ExpectationError => e
22
+ add_failure(e.message, e.backtrace)
23
+ rescue Test::Unit::AssertionFailedError => e
24
+ add_failure(e.message, e.backtrace)
25
+ rescue StandardError, ScriptError
26
+ add_error($!)
27
+ ensure
28
+ begin
29
+ teardown
30
+ rescue Test::Unit::AssertionFailedError => e
31
+ add_failure(e.message, e.backtrace)
32
+ rescue StandardError, ScriptError
33
+ add_error($!)
34
+ end
35
+ end
36
+ ensure
37
+ mocha_teardown
38
+ end
39
+ result.add_run
40
+ yield(Test::Unit::TestCase::FINISHED, name)
41
+ end
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,50 @@
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 RubyVersion186AndAbove
12
+ def run(result)
13
+ assertion_counter = AssertionCounter.new(result)
14
+ yield(Test::Unit::TestCase::STARTED, name)
15
+ @_result = result
16
+ begin
17
+ begin
18
+ setup
19
+ __send__(@method_name)
20
+ mocha_verify(assertion_counter)
21
+ rescue Mocha::ExpectationError => e
22
+ add_failure(e.message, e.backtrace)
23
+ rescue Test::Unit::AssertionFailedError => e
24
+ add_failure(e.message, e.backtrace)
25
+ rescue Exception
26
+ raise if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? $!.class
27
+ add_error($!)
28
+ ensure
29
+ begin
30
+ teardown
31
+ rescue Test::Unit::AssertionFailedError => e
32
+ add_failure(e.message, e.backtrace)
33
+ rescue Exception
34
+ raise if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? $!.class
35
+ add_error($!)
36
+ end
37
+ end
38
+ ensure
39
+ mocha_teardown
40
+ end
41
+ result.add_run
42
+ yield(Test::Unit::TestCase::FINISHED, name)
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+ end
@@ -41,6 +41,7 @@ module Mocha
41
41
 
42
42
  def matches?(available_parameters)
43
43
  parameter = available_parameters.shift
44
+ return false unless parameter.respond_to?(:keys) && parameter.respond_to?(:[])
44
45
  matching_keys = parameter.keys.select { |key| @key.to_matcher.matches?([key]) }
45
46
  matching_keys.any? { |key| @value.to_matcher.matches?([parameter[key]]) }
46
47
  end
@@ -1,2 +1,2 @@
1
- require 'mocha/standalone'
2
- require 'mocha/object'
1
+ require 'mocha/api'
2
+ require 'mocha/object'
@@ -7,7 +7,7 @@ end
7
7
 
8
8
  class NotATestUnitTestCase
9
9
 
10
- include Mocha::Standalone
10
+ include Mocha::API
11
11
 
12
12
  attr_reader :assertion_counter
13
13
 
@@ -87,7 +87,7 @@ end
87
87
 
88
88
  require 'test/unit'
89
89
 
90
- class StandaloneTest < Test::Unit::TestCase
90
+ class APITest < Test::Unit::TestCase
91
91
 
92
92
  attr_reader :sample_test
93
93
 
@@ -14,7 +14,7 @@ class Bug21465Test < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  def test_should_allow_expected_method_name_to_be_a_string
17
- test_result = run_test do
17
+ test_result = run_as_test do
18
18
  mock = mock()
19
19
  mock.expects('wibble')
20
20
  mock.wibble
@@ -23,7 +23,7 @@ class Bug21465Test < Test::Unit::TestCase
23
23
  end
24
24
 
25
25
  def test_should_allow_stubbed_method_name_to_be_a_string
26
- test_result = run_test do
26
+ test_result = run_as_test do
27
27
  mock = mock()
28
28
  mock.stubs('wibble')
29
29
  mock.wibble
@@ -14,7 +14,7 @@ class Bug21563Test < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  def test_should_allow_stubbing_of_verified_method
17
- test_result = run_test do
17
+ test_result = run_as_test do
18
18
  object = Object.new
19
19
  object.stubs(:verified?).returns(false)
20
20
  assert !object.verified?
@@ -14,7 +14,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  def test_should_pass_if_method_is_never_expected_and_is_never_called
17
- test_result = run_test do
17
+ test_result = run_as_test do
18
18
  mock = mock('mock')
19
19
  mock.expects(:method).never
20
20
  0.times { mock.method }
@@ -23,7 +23,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
23
23
  end
24
24
 
25
25
  def test_should_fail_fast_if_method_is_never_expected_but_is_called_once
26
- test_result = run_test do
26
+ test_result = run_as_test do
27
27
  mock = mock('mock')
28
28
  mock.expects(:method).never
29
29
  1.times { mock.method }
@@ -33,7 +33,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
33
33
  end
34
34
 
35
35
  def test_should_pass_if_method_is_expected_twice_and_is_called_twice
36
- test_result = run_test do
36
+ test_result = run_as_test do
37
37
  mock = mock('mock')
38
38
  mock.expects(:method).twice
39
39
  2.times { mock.method }
@@ -42,7 +42,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
42
42
  end
43
43
 
44
44
  def test_should_fail_if_method_is_expected_twice_but_is_called_once
45
- test_result = run_test do
45
+ test_result = run_as_test do
46
46
  mock = mock('mock')
47
47
  mock.expects(:method).twice
48
48
  1.times { mock.method }
@@ -52,7 +52,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
52
52
  end
53
53
 
54
54
  def test_should_fail_fast_if_method_is_expected_twice_but_is_called_three_times
55
- test_result = run_test do
55
+ test_result = run_as_test do
56
56
  mock = mock('mock')
57
57
  mock.expects(:method).twice
58
58
  3.times { mock.method }
@@ -62,7 +62,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
62
62
  end
63
63
 
64
64
  def test_should_pass_if_method_is_expected_between_two_and_four_times_and_is_called_twice
65
- test_result = run_test do
65
+ test_result = run_as_test do
66
66
  mock = mock('mock')
67
67
  mock.expects(:method).times(2..4)
68
68
  2.times { mock.method }
@@ -71,7 +71,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
71
71
  end
72
72
 
73
73
  def test_should_pass_if_method_is_expected_between_two_and_four_times_and_is_called_three_times
74
- test_result = run_test do
74
+ test_result = run_as_test do
75
75
  mock = mock('mock')
76
76
  mock.expects(:method).times(2..4)
77
77
  3.times { mock.method }
@@ -80,7 +80,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
80
80
  end
81
81
 
82
82
  def test_should_pass_if_method_is_expected_between_two_and_four_times_and_is_called_four_times
83
- test_result = run_test do
83
+ test_result = run_as_test do
84
84
  mock = mock('mock')
85
85
  mock.expects(:method).times(2..4)
86
86
  4.times { mock.method }
@@ -89,7 +89,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
89
89
  end
90
90
 
91
91
  def test_should_fail_if_method_is_expected_between_two_and_four_times_and_is_called_once
92
- test_result = run_test do
92
+ test_result = run_as_test do
93
93
  mock = mock('mock')
94
94
  mock.expects(:method).times(2..4)
95
95
  1.times { mock.method }
@@ -99,7 +99,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
99
99
  end
100
100
 
101
101
  def test_should_fail_fast_if_method_is_expected_between_two_and_four_times_and_is_called_five_times
102
- test_result = run_test do
102
+ test_result = run_as_test do
103
103
  mock = mock('mock')
104
104
  mock.expects(:method).times(2..4)
105
105
  5.times { mock.method }
@@ -109,7 +109,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
109
109
  end
110
110
 
111
111
  def test_should_pass_if_method_is_expected_at_least_once_and_is_called_once
112
- test_result = run_test do
112
+ test_result = run_as_test do
113
113
  mock = mock('mock')
114
114
  mock.expects(:method).at_least_once
115
115
  1.times { mock.method }
@@ -118,7 +118,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
118
118
  end
119
119
 
120
120
  def test_should_pass_if_method_is_expected_at_least_once_and_is_called_twice
121
- test_result = run_test do
121
+ test_result = run_as_test do
122
122
  mock = mock('mock')
123
123
  mock.expects(:method).at_least_once
124
124
  2.times { mock.method }
@@ -127,7 +127,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
127
127
  end
128
128
 
129
129
  def test_should_fail_if_method_is_expected_at_least_once_but_is_never_called
130
- test_result = run_test do
130
+ test_result = run_as_test do
131
131
  mock = mock('mock')
132
132
  mock.expects(:method).at_least_once
133
133
  0.times { mock.method }
@@ -137,7 +137,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
137
137
  end
138
138
 
139
139
  def test_should_pass_if_method_is_expected_at_most_once_and_is_never_called
140
- test_result = run_test do
140
+ test_result = run_as_test do
141
141
  mock = mock('mock')
142
142
  mock.expects(:method).at_most_once
143
143
  0.times { mock.method }
@@ -146,7 +146,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
146
146
  end
147
147
 
148
148
  def test_should_pass_if_method_is_expected_at_most_once_and_called_once
149
- test_result = run_test do
149
+ test_result = run_as_test do
150
150
  mock = mock('mock')
151
151
  mock.expects(:method).at_most_once
152
152
  1.times { mock.method }
@@ -155,7 +155,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
155
155
  end
156
156
 
157
157
  def test_should_fail_fast_if_method_is_expected_at_most_once_but_is_called_twice
158
- test_result = run_test do
158
+ test_result = run_as_test do
159
159
  mock = mock('mock')
160
160
  mock.expects(:method).at_most_once
161
161
  2.times { mock.method }
@@ -165,7 +165,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
165
165
  end
166
166
 
167
167
  def test_should_pass_if_method_is_never_expected_and_is_never_called_even_if_everything_is_stubbed
168
- test_result = run_test do
168
+ test_result = run_as_test do
169
169
  stub = stub_everything('stub')
170
170
  stub.expects(:method).never
171
171
  0.times { stub.method }
@@ -174,7 +174,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
174
174
  end
175
175
 
176
176
  def test_should_fail_fast_if_method_is_never_expected_but_is_called_once_even_if_everything_is_stubbed
177
- test_result = run_test do
177
+ test_result = run_as_test do
178
178
  stub = stub_everything('stub')
179
179
  stub.expects(:method).never
180
180
  1.times { stub.method }
@@ -184,7 +184,7 @@ class ExpectedInvocationCountTest < Test::Unit::TestCase
184
184
  end
185
185
 
186
186
  def test_should_fail_fast_if_there_is_no_matching_expectation
187
- test_result = run_test do
187
+ test_result = run_as_test do
188
188
  mock = mock('mock')
189
189
  mock.expects(:method).with(1)
190
190
  1.times { mock.method }
@@ -18,28 +18,28 @@ class FailureMessagesTest < Test::Unit::TestCase
18
18
  class Foo; end
19
19
 
20
20
  def test_should_display_class_name_when_expectation_was_on_class
21
- test_result = run_test do
21
+ test_result = run_as_test do
22
22
  Foo.expects(:bar)
23
23
  end
24
24
  assert_match Regexp.new('FailureMessagesTest::Foo'), test_result.failures[0].message
25
25
  end
26
26
 
27
27
  def test_should_display_class_name_and_address_when_expectation_was_on_instance
28
- test_result = run_test do
28
+ test_result = run_as_test do
29
29
  Foo.new.expects(:bar)
30
30
  end
31
31
  assert_match Regexp.new("#<FailureMessagesTest::Foo:#{OBJECT_ADDRESS_PATTERN}>"), test_result.failures[0].message
32
32
  end
33
33
 
34
34
  def test_should_display_class_name_and_any_instance_prefix_when_expectation_was_on_any_instance
35
- test_result = run_test do
35
+ test_result = run_as_test do
36
36
  Foo.any_instance.expects(:bar)
37
37
  end
38
38
  assert_match Regexp.new('#<AnyInstance:FailureMessagesTest::Foo>'), test_result.failures[0].message
39
39
  end
40
40
 
41
41
  def test_should_display_mock_name_when_expectation_was_on_named_mock
42
- test_result = run_test do
42
+ test_result = run_as_test do
43
43
  foo = mock('foo')
44
44
  foo.expects(:bar)
45
45
  end
@@ -47,7 +47,7 @@ class FailureMessagesTest < Test::Unit::TestCase
47
47
  end
48
48
 
49
49
  def test_should_display_mock_address_when_expectation_was_on_unnamed_mock
50
- test_result = run_test do
50
+ test_result = run_as_test do
51
51
  foo = mock()
52
52
  foo.expects(:bar)
53
53
  end
@@ -55,7 +55,7 @@ class FailureMessagesTest < Test::Unit::TestCase
55
55
  end
56
56
 
57
57
  def test_should_display_string_when_expectation_was_on_string
58
- test_result = run_test do
58
+ test_result = run_as_test do
59
59
  'Foo'.expects(:bar)
60
60
  end
61
61
  assert_match Regexp.new("'Foo'"), test_result.failures[0].message
@@ -1,7 +1,22 @@
1
1
  require File.join(File.dirname(__FILE__), "acceptance_test_helper")
2
- require 'mocha'
2
+
3
+ begin
4
+ require 'rubygems'
5
+ gem 'minitest'
6
+ rescue Gem::LoadError
7
+ # MiniTest gem not available
8
+ end
9
+
10
+ begin
11
+ require 'minitest/unit'
12
+ rescue LoadError
13
+ # MiniTest not available
14
+ end
3
15
 
4
16
  if defined?(MiniTest)
17
+
18
+ # monkey-patch MiniTest now that it has hopefully been loaded
19
+ require 'mocha/integration/mini_test'
5
20
 
6
21
  class MiniTestSampleTest < MiniTest::Unit::TestCase
7
22
 
@@ -46,7 +61,7 @@ if defined?(MiniTest)
46
61
 
47
62
  end
48
63
 
49
- class MiniTestAdapterTest < Test::Unit::TestCase
64
+ class MiniTestTest < Test::Unit::TestCase
50
65
 
51
66
  def setup
52
67
  @output = StringIO.new
@@ -59,14 +74,16 @@ if defined?(MiniTest)
59
74
  def test_should_pass_mocha_test
60
75
  runner.run(%w(-n test_mocha_with_fulfilled_expectation))
61
76
 
77
+ assert_equal 0, runner.failures
62
78
  assert_equal 0, runner.errors
63
79
  assert_equal 1, runner.assertion_count
64
80
  end
65
81
 
66
82
  def test_should_fail_mocha_test_due_to_unfulfilled_expectation
67
83
  runner.run(%w(-n test_mocha_with_unfulfilled_expectation))
68
-
69
- assert_equal 1, runner.errors
84
+
85
+ assert_equal 1, runner.failures
86
+ assert_equal 0, runner.errors
70
87
  assert_equal 1, runner.assertion_count
71
88
  assert_not_all_expectation_were_satisfied
72
89
  end
@@ -74,7 +91,8 @@ if defined?(MiniTest)
74
91
  def test_should_fail_mocha_test_due_to_unexpected_invocation
75
92
  runner.run(%w(-n test_mocha_with_unexpected_invocation))
76
93
 
77
- assert_equal 1, runner.errors
94
+ assert_equal 1, runner.failures
95
+ assert_equal 0, runner.errors
78
96
  assert_equal 0, runner.assertion_count
79
97
  assert_unexpected_invocation
80
98
  end
@@ -82,6 +100,7 @@ if defined?(MiniTest)
82
100
  def test_should_pass_stubba_test
83
101
  runner.run(%w(-n test_stubba_with_fulfilled_expectation))
84
102
 
103
+ assert_equal 0, runner.failures
85
104
  assert_equal 0, runner.errors
86
105
  assert_equal 1, runner.assertion_count
87
106
  end
@@ -89,22 +108,26 @@ if defined?(MiniTest)
89
108
  def test_should_fail_stubba_test_due_to_unfulfilled_expectation
90
109
  runner.run(%w(-n test_stubba_with_unfulfilled_expectation))
91
110
 
92
- assert_equal 1, runner.errors
111
+ assert_equal 1, runner.failures
112
+ assert_equal 0, runner.errors
93
113
  assert_equal 1, runner.assertion_count
94
- assert_match Regexp.new('not all expectations were satisfied'), output
114
+ assert_not_all_expectation_were_satisfied
95
115
  end
96
116
 
97
117
  def test_should_pass_mocha_test_with_matching_parameter
98
118
  runner.run(%w(-n test_mocha_with_matching_parameter))
99
119
 
120
+ assert_equal 0, runner.failures
100
121
  assert_equal 0, runner.errors
101
122
  assert_equal 1, runner.assertion_count
102
123
  end
103
124
 
104
125
  def test_should_fail_mocha_test_with_non_matching_parameter
105
126
  runner.run(%w(-n test_mocha_with_non_matching_parameter))
106
-
107
- assert_equal 1, runner.errors
127
+
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
108
131
  assert_unexpected_invocation
109
132
  end
110
133