mocha 0.10.5 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. data/COPYING.rdoc +1 -1
  2. data/README.rdoc +6 -4
  3. data/RELEASE.rdoc +12 -0
  4. data/Rakefile +29 -60
  5. data/doc/Mocha.html +112 -0
  6. data/doc/Mocha/API.html +898 -0
  7. data/doc/Mocha/ClassMethods.html +246 -0
  8. data/doc/Mocha/Configuration.html +471 -0
  9. data/doc/Mocha/Expectation.html +2570 -0
  10. data/doc/Mocha/Mock.html +830 -0
  11. data/doc/Mocha/ObjectMethods.html +668 -0
  12. data/doc/Mocha/ParameterMatchers.html +2715 -0
  13. data/doc/Mocha/ParameterMatchers/AllOf.html +137 -0
  14. data/doc/Mocha/ParameterMatchers/AnyOf.html +137 -0
  15. data/doc/Mocha/ParameterMatchers/AnyParameters.html +136 -0
  16. data/doc/Mocha/ParameterMatchers/Anything.html +136 -0
  17. data/doc/Mocha/ParameterMatchers/Base.html +419 -0
  18. data/doc/Mocha/ParameterMatchers/Equals.html +137 -0
  19. data/doc/Mocha/ParameterMatchers/HasEntries.html +137 -0
  20. data/doc/Mocha/ParameterMatchers/HasEntry.html +137 -0
  21. data/doc/Mocha/ParameterMatchers/HasKey.html +137 -0
  22. data/doc/Mocha/ParameterMatchers/HasValue.html +137 -0
  23. data/doc/Mocha/ParameterMatchers/Includes.html +137 -0
  24. data/doc/Mocha/ParameterMatchers/InstanceOf.html +137 -0
  25. data/doc/Mocha/ParameterMatchers/IsA.html +136 -0
  26. data/doc/Mocha/ParameterMatchers/KindOf.html +137 -0
  27. data/doc/Mocha/ParameterMatchers/Not.html +137 -0
  28. data/doc/Mocha/ParameterMatchers/Optionally.html +136 -0
  29. data/doc/Mocha/ParameterMatchers/QueryStringMatches.html +136 -0
  30. data/doc/Mocha/ParameterMatchers/RegexpMatches.html +137 -0
  31. data/doc/Mocha/ParameterMatchers/RespondsWith.html +137 -0
  32. data/doc/Mocha/ParameterMatchers/YamlEquivalent.html +137 -0
  33. data/doc/Mocha/Sequence.html +133 -0
  34. data/doc/Mocha/StateMachine.html +510 -0
  35. data/doc/Mocha/StateMachine/State.html +125 -0
  36. data/doc/Mocha/StateMachine/StatePredicate.html +125 -0
  37. data/doc/Mocha/StubbingError.html +134 -0
  38. data/doc/Mocha/UnexpectedInvocation.html +124 -0
  39. data/doc/_index.html +481 -0
  40. data/doc/class_list.html +47 -0
  41. data/doc/css/common.css +1 -0
  42. data/doc/css/full_list.css +55 -0
  43. data/doc/css/style.css +322 -0
  44. data/doc/file.COPYING.html +72 -0
  45. data/doc/file.MIT-LICENSE.html +86 -0
  46. data/doc/file.README.html +153 -0
  47. data/doc/file.RELEASE.html +933 -0
  48. data/doc/file.misc.html +108 -0
  49. data/doc/file.mocha.html +90 -0
  50. data/doc/file.stubba.html +129 -0
  51. data/doc/file_list.html +67 -0
  52. data/doc/frames.html +13 -0
  53. data/doc/index.html +153 -0
  54. data/doc/js/app.js +205 -0
  55. data/doc/js/full_list.js +173 -0
  56. data/doc/js/jquery.js +16 -0
  57. data/doc/method_list.html +510 -0
  58. data/doc/top-level-namespace.html +105 -0
  59. data/lib/mocha/any_instance_method.rb +16 -11
  60. data/lib/mocha/api.rb +120 -106
  61. data/lib/mocha/argument_iterator.rb +6 -6
  62. data/lib/mocha/backtrace_filter.rb +1 -1
  63. data/lib/mocha/cardinality.rb +21 -21
  64. data/lib/mocha/central.rb +8 -8
  65. data/lib/mocha/change_state_side_effect.rb +5 -5
  66. data/lib/mocha/class_method.rb +14 -19
  67. data/lib/mocha/configuration.rb +47 -37
  68. data/lib/mocha/deprecation.rb +8 -8
  69. data/lib/mocha/exception_raiser.rb +7 -7
  70. data/lib/mocha/expectation.rb +173 -77
  71. data/lib/mocha/expectation_error.rb +2 -2
  72. data/lib/mocha/expectation_list.rb +11 -11
  73. data/lib/mocha/in_state_ordering_constraint.rb +5 -5
  74. data/lib/mocha/inspect.rb +8 -8
  75. data/lib/mocha/instance_method.rb +1 -17
  76. data/lib/mocha/integration.rb +9 -9
  77. data/lib/mocha/integration/mini_test/assertion_counter.rb +9 -9
  78. data/lib/mocha/integration/mini_test/exception_translation.rb +6 -6
  79. data/lib/mocha/integration/mini_test/version_13.rb +6 -6
  80. data/lib/mocha/integration/mini_test/version_140.rb +6 -6
  81. data/lib/mocha/integration/mini_test/version_141.rb +6 -6
  82. data/lib/mocha/integration/mini_test/version_142_to_172.rb +7 -7
  83. data/lib/mocha/integration/mini_test/version_200.rb +7 -7
  84. data/lib/mocha/integration/test_unit/assertion_counter.rb +10 -10
  85. data/lib/mocha/integration/test_unit/gem_version_200.rb +6 -6
  86. data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +6 -6
  87. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +6 -6
  88. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +6 -6
  89. data/lib/mocha/is_a.rb +1 -1
  90. data/lib/mocha/logger.rb +6 -6
  91. data/lib/mocha/method_matcher.rb +7 -7
  92. data/lib/mocha/mock.rb +85 -48
  93. data/lib/mocha/mockery.rb +47 -33
  94. data/lib/mocha/module_method.rb +2 -2
  95. data/lib/mocha/multiple_yields.rb +9 -9
  96. data/lib/mocha/names.rb +18 -18
  97. data/lib/mocha/no_yields.rb +7 -7
  98. data/lib/mocha/object.rb +104 -75
  99. data/lib/mocha/parameter_matchers.rb +3 -3
  100. data/lib/mocha/parameter_matchers/all_of.rb +22 -12
  101. data/lib/mocha/parameter_matchers/any_of.rb +23 -12
  102. data/lib/mocha/parameter_matchers/any_parameters.rb +15 -8
  103. data/lib/mocha/parameter_matchers/anything.rb +20 -11
  104. data/lib/mocha/parameter_matchers/base.rb +35 -27
  105. data/lib/mocha/parameter_matchers/equals.rb +23 -12
  106. data/lib/mocha/parameter_matchers/has_entries.rb +22 -12
  107. data/lib/mocha/parameter_matchers/has_entry.rb +31 -13
  108. data/lib/mocha/parameter_matchers/has_key.rb +21 -11
  109. data/lib/mocha/parameter_matchers/has_value.rb +21 -11
  110. data/lib/mocha/parameter_matchers/includes.rb +15 -5
  111. data/lib/mocha/parameter_matchers/instance_of.rb +23 -12
  112. data/lib/mocha/parameter_matchers/is_a.rb +23 -12
  113. data/lib/mocha/parameter_matchers/kind_of.rb +23 -12
  114. data/lib/mocha/parameter_matchers/not.rb +22 -12
  115. data/lib/mocha/parameter_matchers/object.rb +5 -3
  116. data/lib/mocha/parameter_matchers/optionally.rb +24 -12
  117. data/lib/mocha/parameter_matchers/query_string.rb +14 -3
  118. data/lib/mocha/parameter_matchers/regexp_matches.rb +21 -11
  119. data/lib/mocha/parameter_matchers/responds_with.rb +17 -6
  120. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +16 -6
  121. data/lib/mocha/parameters_matcher.rb +8 -8
  122. data/lib/mocha/pretty_parameters.rb +7 -7
  123. data/lib/mocha/return_values.rb +11 -11
  124. data/lib/mocha/sequence.rb +23 -14
  125. data/lib/mocha/single_return_value.rb +7 -7
  126. data/lib/mocha/single_yield.rb +9 -9
  127. data/lib/mocha/standalone.rb +1 -1
  128. data/lib/mocha/state_machine.rb +61 -46
  129. data/lib/mocha/stubbing_error.rb +8 -5
  130. data/lib/mocha/thrower.rb +2 -2
  131. data/lib/mocha/unexpected_invocation.rb +9 -6
  132. data/lib/mocha/version.rb +1 -1
  133. data/lib/mocha/yield_parameters.rb +10 -10
  134. data/lib/mocha_standalone.rb +1 -1
  135. data/mocha.gemspec +4 -7
  136. data/test/acceptance/acceptance_test_helper.rb +10 -10
  137. data/test/acceptance/api_test.rb +20 -20
  138. data/test/acceptance/bug_18914_test.rb +12 -12
  139. data/test/acceptance/bug_21465_test.rb +6 -6
  140. data/test/acceptance/bug_21563_test.rb +5 -5
  141. data/test/acceptance/exception_rescue_test.rb +1 -1
  142. data/test/acceptance/expected_invocation_count_test.rb +17 -17
  143. data/test/acceptance/failure_messages_test.rb +13 -13
  144. data/test/acceptance/minitest_test.rb +39 -39
  145. data/test/acceptance/mocha_example_test.rb +26 -26
  146. data/test/acceptance/mocha_test_result_test.rb +13 -13
  147. data/test/acceptance/mock_test.rb +5 -5
  148. data/test/acceptance/mock_with_initializer_block_test.rb +5 -5
  149. data/test/acceptance/mocked_methods_dispatch_test.rb +4 -4
  150. data/test/acceptance/multiple_expectations_failure_message_test.rb +2 -2
  151. data/test/acceptance/optional_parameters_test.rb +5 -5
  152. data/test/acceptance/parameter_matcher_test.rb +18 -18
  153. data/test/acceptance/partial_mocks_test.rb +9 -9
  154. data/test/acceptance/raise_exception_test.rb +1 -1
  155. data/test/acceptance/return_value_test.rb +5 -5
  156. data/test/acceptance/sequence_test.rb +29 -29
  157. data/test/acceptance/states_test.rb +17 -17
  158. data/test/acceptance/stub_any_instance_method_test.rb +13 -13
  159. data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +7 -7
  160. data/test/acceptance/stub_everything_test.rb +5 -5
  161. data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +1 -1
  162. data/test/acceptance/stub_module_method_test.rb +17 -17
  163. data/test/acceptance/stub_test.rb +5 -5
  164. data/test/acceptance/stubba_example_test.rb +24 -24
  165. data/test/acceptance/stubba_test_result_test.rb +11 -11
  166. data/test/acceptance/stubbing_error_backtrace_test.rb +6 -6
  167. data/test/acceptance/stubbing_frozen_object_test.rb +88 -0
  168. data/test/acceptance/stubbing_method_unnecessarily_test.rb +9 -9
  169. data/test/acceptance/stubbing_nil_test.rb +59 -0
  170. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +13 -13
  171. data/test/acceptance/stubbing_non_existent_class_method_test.rb +15 -15
  172. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +14 -14
  173. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +13 -13
  174. data/test/acceptance/stubbing_non_public_class_method_test.rb +12 -12
  175. data/test/acceptance/stubbing_non_public_instance_method_test.rb +12 -12
  176. data/test/acceptance/stubbing_on_non_mock_object_test.rb +9 -9
  177. data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +35 -0
  178. data/test/acceptance/throw_test.rb +1 -1
  179. data/test/deprecation_disabler.rb +1 -1
  180. data/test/execution_point.rb +7 -7
  181. data/test/method_definer.rb +1 -1
  182. data/test/mini_test_result.rb +21 -21
  183. data/test/simple_counter.rb +5 -5
  184. data/test/test_helper.rb +1 -1
  185. data/test/test_runner.rb +22 -24
  186. data/test/test_unit_result.rb +20 -0
  187. data/test/unit/any_instance_method_test.rb +28 -32
  188. data/test/unit/array_inspect_test.rb +3 -3
  189. data/test/unit/backtrace_filter_test.rb +3 -3
  190. data/test/unit/cardinality_test.rb +12 -12
  191. data/test/unit/central_test.rb +18 -18
  192. data/test/unit/change_state_side_effect_test.rb +12 -12
  193. data/test/unit/class_method_test.rb +33 -91
  194. data/test/unit/date_time_inspect_test.rb +4 -4
  195. data/test/unit/exception_raiser_test.rb +5 -5
  196. data/test/unit/expectation_list_test.rb +7 -7
  197. data/test/unit/expectation_test.rb +66 -66
  198. data/test/unit/hash_inspect_test.rb +4 -4
  199. data/test/unit/in_state_ordering_constraint_test.rb +13 -13
  200. data/test/unit/method_matcher_test.rb +3 -3
  201. data/test/unit/mock_test.rb +40 -40
  202. data/test/unit/mockery_test.rb +25 -25
  203. data/test/unit/multiple_yields_test.rb +2 -2
  204. data/test/unit/no_yields_test.rb +2 -2
  205. data/test/unit/object_inspect_test.rb +4 -4
  206. data/test/unit/object_test.rb +15 -15
  207. data/test/unit/parameter_matchers/all_of_test.rb +6 -6
  208. data/test/unit/parameter_matchers/any_of_test.rb +6 -6
  209. data/test/unit/parameter_matchers/anything_test.rb +5 -5
  210. data/test/unit/parameter_matchers/has_entries_test.rb +10 -10
  211. data/test/unit/parameter_matchers/has_entry_test.rb +13 -13
  212. data/test/unit/parameter_matchers/has_key_test.rb +11 -11
  213. data/test/unit/parameter_matchers/has_value_test.rb +12 -12
  214. data/test/unit/parameter_matchers/includes_test.rb +4 -4
  215. data/test/unit/parameter_matchers/not_test.rb +6 -6
  216. data/test/unit/parameter_matchers/regexp_matches_test.rb +9 -9
  217. data/test/unit/parameter_matchers/responds_with_test.rb +6 -6
  218. data/test/unit/parameter_matchers/stub_matcher.rb +4 -4
  219. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +6 -6
  220. data/test/unit/parameters_matcher_test.rb +16 -16
  221. data/test/unit/return_values_test.rb +5 -5
  222. data/test/unit/sequence_test.rb +10 -10
  223. data/test/unit/single_return_value_test.rb +3 -3
  224. data/test/unit/single_yield_test.rb +2 -2
  225. data/test/unit/state_machine_test.rb +19 -19
  226. data/test/unit/string_inspect_test.rb +2 -2
  227. data/test/unit/thrower_test.rb +1 -1
  228. data/test/unit/yield_parameters_test.rb +11 -11
  229. metadata +113 -101
@@ -2,7 +2,7 @@ require File.expand_path('../../test_helper', __FILE__)
2
2
  require 'mocha/method_matcher'
3
3
 
4
4
  class MethodMatcherTest < Test::Unit::TestCase
5
-
5
+
6
6
  include Mocha
7
7
 
8
8
  def test_should_match_if_actual_method_name_is_same_as_expected_method_name
@@ -14,10 +14,10 @@ class MethodMatcherTest < Test::Unit::TestCase
14
14
  method_matcher = MethodMatcher.new(:method_name)
15
15
  assert !method_matcher.match?(:different_method_name)
16
16
  end
17
-
17
+
18
18
  def test_should_describe_what_method_is_expected
19
19
  method_matcher = MethodMatcher.new(:method_name)
20
20
  assert_equal "method_name", method_matcher.mocha_inspect
21
21
  end
22
22
 
23
- end
23
+ end
@@ -5,16 +5,16 @@ require 'set'
5
5
  require 'simple_counter'
6
6
 
7
7
  class MockTest < Test::Unit::TestCase
8
-
8
+
9
9
  include Mocha
10
-
10
+
11
11
  def test_should_set_single_expectation
12
12
  mock = build_mock
13
13
  mock.expects(:method1).returns(1)
14
14
  assert_nothing_raised(ExpectationError) do
15
15
  assert_equal 1, mock.method1
16
16
  end
17
- end
17
+ end
18
18
 
19
19
  def test_should_build_and_store_expectations
20
20
  mock = build_mock
@@ -22,7 +22,7 @@ class MockTest < Test::Unit::TestCase
22
22
  assert_not_nil expectation
23
23
  assert_equal [expectation], mock.__expectations__.to_a
24
24
  end
25
-
25
+
26
26
  def test_should_not_stub_everything_by_default
27
27
  mock = build_mock
28
28
  assert_equal false, mock.everything_stubbed
@@ -33,71 +33,71 @@ class MockTest < Test::Unit::TestCase
33
33
  mock.stub_everything
34
34
  assert_equal true, mock.everything_stubbed
35
35
  end
36
-
36
+
37
37
  def test_should_be_able_to_extend_mock_object_with_module
38
38
  mock = build_mock
39
39
  assert_nothing_raised(ExpectationError) { mock.extend(Module.new) }
40
40
  end
41
-
41
+
42
42
  def test_should_be_equal
43
43
  mock = build_mock
44
44
  assert_equal true, mock.eql?(mock)
45
45
  end
46
-
46
+
47
47
  if RUBY_VERSION < '1.9'
48
48
  OBJECT_METHODS = STANDARD_OBJECT_PUBLIC_INSTANCE_METHODS.reject { |m| m =~ /^__.*__$/ }
49
49
  else
50
50
  OBJECT_METHODS = STANDARD_OBJECT_PUBLIC_INSTANCE_METHODS.reject { |m| m =~ /^__.*__$/ || m == :object_id }
51
51
  end
52
-
52
+
53
53
  def test_should_be_able_to_mock_standard_object_methods
54
54
  mock = build_mock
55
55
  OBJECT_METHODS.each { |method| mock.__expects__(method.to_sym).returns(method) }
56
56
  OBJECT_METHODS.each { |method| assert_equal method, mock.__send__(method.to_sym) }
57
57
  assert mock.__verified__?
58
58
  end
59
-
59
+
60
60
  def test_should_be_able_to_stub_standard_object_methods
61
61
  mock = build_mock
62
62
  OBJECT_METHODS.each { |method| mock.__stubs__(method.to_sym).returns(method) }
63
63
  OBJECT_METHODS.each { |method| assert_equal method, mock.__send__(method.to_sym) }
64
64
  end
65
-
65
+
66
66
  def test_should_create_and_add_expectations
67
67
  mock = build_mock
68
68
  expectation1 = mock.expects(:method1)
69
69
  expectation2 = mock.expects(:method2)
70
70
  assert_equal [expectation1, expectation2].to_set, mock.__expectations__.to_set
71
71
  end
72
-
72
+
73
73
  def test_should_pass_backtrace_into_expectation
74
74
  mock = build_mock
75
75
  backtrace = Object.new
76
76
  expectation = mock.expects(:method1, backtrace)
77
77
  assert_equal backtrace, expectation.backtrace
78
78
  end
79
-
79
+
80
80
  def test_should_pass_backtrace_into_stub
81
81
  mock = build_mock
82
82
  backtrace = Object.new
83
83
  stub = mock.stubs(:method1, backtrace)
84
84
  assert_equal backtrace, stub.backtrace
85
85
  end
86
-
86
+
87
87
  def test_should_create_and_add_stubs
88
88
  mock = build_mock
89
89
  stub1 = mock.stubs(:method1)
90
90
  stub2 = mock.stubs(:method2)
91
91
  assert_equal [stub1, stub2].to_set, mock.__expectations__.to_set
92
92
  end
93
-
93
+
94
94
  def test_should_invoke_expectation_and_return_result
95
95
  mock = build_mock
96
96
  mock.expects(:my_method).returns(:result)
97
97
  result = mock.my_method
98
98
  assert_equal :result, result
99
99
  end
100
-
100
+
101
101
  def test_should_not_raise_error_if_stubbing_everything
102
102
  mock = build_mock
103
103
  mock.stub_everything
@@ -107,7 +107,7 @@ class MockTest < Test::Unit::TestCase
107
107
  end
108
108
  assert_nil result
109
109
  end
110
-
110
+
111
111
  def test_should_raise_assertion_error_for_unexpected_method_call
112
112
  mock = build_mock
113
113
  error = assert_raise(ExpectationError) do
@@ -118,7 +118,7 @@ class MockTest < Test::Unit::TestCase
118
118
  assert_match(/argument1/, error.message)
119
119
  assert_match(/argument2/, error.message)
120
120
  end
121
-
121
+
122
122
  def test_should_not_verify_successfully_because_not_all_expectations_have_been_satisfied
123
123
  mock = build_mock
124
124
  mock.expects(:method1)
@@ -126,23 +126,23 @@ class MockTest < Test::Unit::TestCase
126
126
  mock.method1
127
127
  assert !mock.__verified__?
128
128
  end
129
-
129
+
130
130
  def test_should_increment_assertion_counter_for_every_verified_expectation
131
131
  mock = build_mock
132
-
132
+
133
133
  mock.expects(:method1)
134
134
  mock.method1
135
-
135
+
136
136
  mock.expects(:method2)
137
137
  mock.method2
138
-
138
+
139
139
  assertion_counter = SimpleCounter.new
140
-
140
+
141
141
  mock.__verified__?(assertion_counter)
142
-
142
+
143
143
  assert_equal 2, assertion_counter.count
144
144
  end
145
-
145
+
146
146
  def test_should_yield_supplied_parameters_to_block
147
147
  mock = build_mock
148
148
  parameters_for_yield = [1, 2, 3]
@@ -151,35 +151,35 @@ class MockTest < Test::Unit::TestCase
151
151
  mock.method1() { |*parameters| yielded_parameters = parameters }
152
152
  assert_equal parameters_for_yield, yielded_parameters
153
153
  end
154
-
154
+
155
155
  def test_should_set_up_multiple_expectations_with_return_values
156
156
  mock = build_mock
157
157
  mock.expects(:method1 => :result1, :method2 => :result2)
158
158
  assert_equal :result1, mock.method1
159
159
  assert_equal :result2, mock.method2
160
160
  end
161
-
161
+
162
162
  def test_should_set_up_multiple_stubs_with_return_values
163
163
  mock = build_mock
164
164
  mock.stubs(:method1 => :result1, :method2 => :result2)
165
165
  assert_equal :result1, mock.method1
166
166
  assert_equal :result2, mock.method2
167
167
  end
168
-
168
+
169
169
  def test_should_keep_returning_specified_value_for_stubs
170
170
  mock = build_mock
171
171
  mock.stubs(:method1).returns(1)
172
172
  assert_equal 1, mock.method1
173
173
  assert_equal 1, mock.method1
174
174
  end
175
-
175
+
176
176
  def test_should_keep_returning_specified_value_for_expects
177
177
  mock = build_mock
178
178
  mock.expects(:method1).times(2).returns(1)
179
179
  assert_equal 1, mock.method1
180
180
  assert_equal 1, mock.method1
181
181
  end
182
-
182
+
183
183
  def test_should_match_most_recent_call_to_expects
184
184
  mock = build_mock
185
185
  mock.expects(:method1).returns(0)
@@ -207,18 +207,18 @@ class MockTest < Test::Unit::TestCase
207
207
  mock.stubs(:method1).returns(1)
208
208
  assert_equal 1, mock.method1
209
209
  end
210
-
210
+
211
211
  def test_should_respond_to_expected_method
212
212
  mock = build_mock
213
213
  mock.expects(:method1)
214
214
  assert_equal true, mock.respond_to?(:method1)
215
215
  end
216
-
216
+
217
217
  def test_should_not_respond_to_unexpected_method
218
218
  mock = build_mock
219
219
  assert_equal false, mock.respond_to?(:method1)
220
220
  end
221
-
221
+
222
222
  def test_should_respond_to_methods_which_the_responder_does_responds_to
223
223
  instance = Class.new do
224
224
  define_method(:respond_to?) { |symbol| true }
@@ -227,7 +227,7 @@ class MockTest < Test::Unit::TestCase
227
227
  mock.responds_like(instance)
228
228
  assert_equal true, mock.respond_to?(:invoked_method)
229
229
  end
230
-
230
+
231
231
  def test_should_not_respond_to_methods_which_the_responder_does_not_responds_to
232
232
  instance = Class.new do
233
233
  define_method(:respond_to?) { |symbol| false }
@@ -236,18 +236,18 @@ class MockTest < Test::Unit::TestCase
236
236
  mock.responds_like(instance)
237
237
  assert_equal false, mock.respond_to?(:invoked_method)
238
238
  end
239
-
239
+
240
240
  def test_should_return_itself_to_allow_method_chaining
241
241
  mock = build_mock
242
242
  assert_same mock.responds_like(Object.new), mock
243
243
  end
244
-
244
+
245
245
  def test_should_not_raise_no_method_error_if_mock_is_not_restricted_to_respond_like_a_responder
246
246
  mock = build_mock
247
247
  mock.stubs(:invoked_method)
248
248
  assert_nothing_raised(NoMethodError) { mock.invoked_method }
249
249
  end
250
-
250
+
251
251
  def test_should_not_raise_no_method_error_if_responder_does_respond_to_invoked_method
252
252
  instance = Class.new do
253
253
  define_method(:respond_to?) { |symbol| true }
@@ -257,7 +257,7 @@ class MockTest < Test::Unit::TestCase
257
257
  mock.stubs(:invoked_method)
258
258
  assert_nothing_raised(NoMethodError) { mock.invoked_method }
259
259
  end
260
-
260
+
261
261
  def test_should_raise_no_method_error_if_responder_does_not_respond_to_invoked_method
262
262
  instance = Class.new do
263
263
  define_method(:respond_to?) { |symbol| false }
@@ -268,7 +268,7 @@ class MockTest < Test::Unit::TestCase
268
268
  mock.stubs(:invoked_method)
269
269
  assert_raises(NoMethodError) { mock.invoked_method }
270
270
  end
271
-
271
+
272
272
  def test_should_raise_no_method_error_with_message_indicating_that_mock_is_constrained_to_respond_like_responder
273
273
  instance = Class.new do
274
274
  define_method(:respond_to?) { |symbol| false }
@@ -283,12 +283,12 @@ class MockTest < Test::Unit::TestCase
283
283
  assert_match(/which responds like mocha_inspect/, e.message)
284
284
  end
285
285
  end
286
-
286
+
287
287
  def test_should_handle_respond_to_with_private_methods_param_without_error
288
288
  mock = build_mock
289
289
  assert_nothing_raised{ mock.respond_to?(:object_id, false) }
290
290
  end
291
-
291
+
292
292
  def test_should_respond_to_any_method_if_stubbing_everything
293
293
  mock = build_mock
294
294
  mock.stub_everything
@@ -3,28 +3,28 @@ require 'mocha/mockery'
3
3
  require 'mocha/state_machine'
4
4
 
5
5
  class MockeryTest < Test::Unit::TestCase
6
-
6
+
7
7
  include Mocha
8
-
8
+
9
9
  def test_should_build_instance_of_mockery
10
10
  mockery = Mockery.instance
11
11
  assert_not_nil mockery
12
12
  assert_kind_of Mockery, mockery
13
13
  end
14
-
14
+
15
15
  def test_should_cache_instance_of_mockery
16
16
  mockery_1 = Mockery.instance
17
17
  mockery_2 = Mockery.instance
18
18
  assert_same mockery_1, mockery_2
19
19
  end
20
-
20
+
21
21
  def test_should_expire_mockery_instance_cache
22
22
  mockery_1 = Mockery.instance
23
23
  Mockery.reset_instance
24
24
  mockery_2 = Mockery.instance
25
25
  assert_not_same mockery_1, mockery_2
26
26
  end
27
-
27
+
28
28
  def test_should_raise_expectation_error_because_not_all_expectations_are_satisfied
29
29
  mockery = Mockery.new
30
30
  mock_1 = mockery.named_mock('mock-1') { expects(:method_1) }
@@ -33,20 +33,20 @@ class MockeryTest < Test::Unit::TestCase
33
33
  0.times { mock_2.method_2 }
34
34
  assert_raises(ExpectationError) { mockery.verify }
35
35
  end
36
-
36
+
37
37
  def test_should_reset_list_of_mocks_on_teardown
38
38
  mockery = Mockery.new
39
39
  mockery.unnamed_mock { expects(:my_method) }
40
40
  mockery.teardown
41
41
  assert_nothing_raised(ExpectationError) { mockery.verify }
42
42
  end
43
-
43
+
44
44
  def test_should_build_instance_of_stubba_on_instantiation
45
45
  mockery = Mockery.new
46
46
  assert_not_nil mockery.stubba
47
47
  assert_kind_of Central, mockery.stubba
48
48
  end
49
-
49
+
50
50
  def test_should_build_new_instance_of_stubba_on_teardown
51
51
  mockery = Mockery.new
52
52
  stubba_1 = mockery.stubba
@@ -54,27 +54,27 @@ class MockeryTest < Test::Unit::TestCase
54
54
  stubba_2 = mockery.stubba
55
55
  assert_not_same stubba_1, stubba_2
56
56
  end
57
-
57
+
58
58
  def test_should_build_and_store_new_state_machine
59
59
  mockery = Mockery.new
60
60
  mockery.new_state_machine('state-machine-name')
61
61
  assert_equal 1, mockery.state_machines.length
62
62
  assert_kind_of StateMachine, mockery.state_machines[0]
63
63
  end
64
-
64
+
65
65
  def test_should_reset_list_of_state_machines_on_teardown
66
66
  mockery = Mockery.new
67
67
  mockery.new_state_machine('state-machine-name')
68
68
  mockery.teardown
69
69
  assert_equal 0, mockery.state_machines.length
70
70
  end
71
-
71
+
72
72
  class FakeMethod
73
73
  def stub; end
74
74
  def unstub; end
75
75
  def matches?(other); true; end
76
76
  end
77
-
77
+
78
78
  def test_should_unstub_all_methods_on_teardown
79
79
  mockery = Mockery.new
80
80
  stubba = mockery.stubba
@@ -82,69 +82,69 @@ class MockeryTest < Test::Unit::TestCase
82
82
  mockery.teardown
83
83
  assert stubba.stubba_methods.empty?
84
84
  end
85
-
85
+
86
86
  def test_should_display_object_id_for_mocha_inspect_if_mock_has_no_name
87
87
  mockery = Mockery.new
88
88
  mock = mockery.unnamed_mock
89
89
  assert_match Regexp.new("^#<Mock:0x[0-9A-Fa-f]{1,12}>$"), mock.mocha_inspect
90
90
  end
91
-
91
+
92
92
  def test_should_display_object_id_for_inspect_if_mock_has_no_name
93
93
  mockery = Mockery.new
94
94
  mock = mockery.unnamed_mock
95
95
  assert_match Regexp.new("^#<Mock:0x[0-9A-Fa-f]{1,12}>$"), mock.inspect
96
96
  end
97
-
97
+
98
98
  def test_should_display_name_for_mocha_inspect_if_mock_has_string_name
99
99
  mockery = Mockery.new
100
100
  mock = mockery.named_mock('named_mock')
101
101
  assert_equal "#<Mock:named_mock>", mock.mocha_inspect
102
102
  end
103
-
103
+
104
104
  def test_should_display_name_for_mocha_inspect_if_mock_has_symbol_name
105
105
  mockery = Mockery.new
106
106
  mock = mockery.named_mock(:named_mock)
107
107
  assert_equal "#<Mock:named_mock>", mock.mocha_inspect
108
108
  end
109
-
109
+
110
110
  def test_should_display_name_for_inspect_if_mock_has_string_name
111
111
  mockery = Mockery.new
112
112
  mock = mockery.named_mock('named_mock')
113
113
  assert_equal "#<Mock:named_mock>", mock.inspect
114
114
  end
115
-
115
+
116
116
  def test_should_display_name_for_inspect_if_mock_has_symbol_name
117
117
  mockery = Mockery.new
118
118
  mock = mockery.named_mock(:named_mock)
119
119
  assert_equal "#<Mock:named_mock>", mock.inspect
120
120
  end
121
-
121
+
122
122
  def test_should_display_impersonated_object_for_mocha_inspect
123
123
  mockery = Mockery.new
124
124
  instance = Object.new
125
125
  mock = mockery.mock_impersonating(instance)
126
126
  assert_equal "#{instance.mocha_inspect}", mock.mocha_inspect
127
127
  end
128
-
128
+
129
129
  def test_should_display_impersonated_object_for_inspect
130
130
  mockery = Mockery.new
131
131
  instance = Object.new
132
132
  mock = mockery.mock_impersonating(instance)
133
133
  assert_equal "#{instance.mocha_inspect}", mock.inspect
134
134
  end
135
-
135
+
136
136
  class FakeClass; end
137
-
137
+
138
138
  def test_should_display_any_instance_prefix_followed_by_class_whose_instances_are_being_impersonated_for_mocha_inspect
139
139
  mockery = Mockery.new
140
140
  mock = mockery.mock_impersonating_any_instance_of(FakeClass)
141
141
  assert_equal "#<AnyInstance:MockeryTest::FakeClass>", mock.mocha_inspect
142
142
  end
143
-
143
+
144
144
  def test_should_display_any_instance_prefix_followed_by_class_whose_instances_are_being_impersonated_for_inspect
145
145
  mockery = Mockery.new
146
146
  mock = mockery.mock_impersonating_any_instance_of(FakeClass)
147
147
  assert_equal "#<AnyInstance:MockeryTest::FakeClass>", mock.inspect
148
148
  end
149
-
150
- end
149
+
150
+ end