mocha 0.12.8 → 0.13.0

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 (133) hide show
  1. data/.yardopts +22 -0
  2. data/COPYING.md +3 -0
  3. data/README.md +230 -0
  4. data/{RELEASE.rdoc → RELEASE.md} +61 -50
  5. data/Rakefile +45 -37
  6. data/build-matrix.rb +16 -4
  7. data/lib/mocha/api.rb +13 -16
  8. data/lib/mocha/class_method.rb +7 -3
  9. data/lib/mocha/class_methods.rb +63 -0
  10. data/lib/mocha/debug.rb +11 -0
  11. data/lib/mocha/deprecation.rb +1 -1
  12. data/lib/mocha/exception_raiser.rb +1 -1
  13. data/lib/mocha/expectation_error.rb +5 -0
  14. data/lib/mocha/expectation_error_factory.rb +19 -0
  15. data/lib/mocha/hooks.rb +43 -0
  16. data/lib/mocha/integration/assertion_counter.rb +13 -0
  17. data/lib/mocha/integration/mini_test/adapter.rb +54 -0
  18. data/lib/mocha/integration/mini_test/exception_translation.rb +0 -6
  19. data/lib/mocha/integration/mini_test/nothing.rb +19 -0
  20. data/lib/mocha/integration/mini_test/version_13.rb +32 -25
  21. data/lib/mocha/integration/mini_test/version_140.rb +32 -26
  22. data/lib/mocha/integration/mini_test/version_141.rb +40 -34
  23. data/lib/mocha/integration/mini_test/version_142_to_172.rb +40 -34
  24. data/lib/mocha/integration/mini_test/version_200.rb +41 -35
  25. data/lib/mocha/integration/mini_test/version_201_to_222.rb +41 -35
  26. data/lib/mocha/integration/mini_test/version_2110_to_2111.rb +49 -43
  27. data/lib/mocha/integration/mini_test/version_2112_to_320.rb +53 -47
  28. data/lib/mocha/integration/mini_test/version_230_to_2101.rb +43 -37
  29. data/lib/mocha/integration/mini_test.rb +42 -57
  30. data/lib/mocha/integration/monkey_patcher.rb +18 -0
  31. data/lib/mocha/integration/test_unit/adapter.rb +51 -0
  32. data/lib/mocha/integration/test_unit/gem_version_200.rb +36 -29
  33. data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +36 -29
  34. data/lib/mocha/integration/test_unit/gem_version_203_to_220.rb +36 -29
  35. data/lib/mocha/integration/test_unit/gem_version_230_to_250.rb +65 -0
  36. data/lib/mocha/integration/test_unit/nothing.rb +19 -0
  37. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +36 -29
  38. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +37 -30
  39. data/lib/mocha/integration/test_unit.rb +38 -45
  40. data/lib/mocha/integration.rb +6 -38
  41. data/lib/mocha/method_matcher.rb +1 -1
  42. data/lib/mocha/module_methods.rb +14 -0
  43. data/lib/mocha/{object.rb → object_methods.rb} +0 -83
  44. data/lib/mocha/setup.rb +10 -0
  45. data/lib/mocha/standalone.rb +3 -0
  46. data/lib/mocha/version.rb +1 -1
  47. data/lib/mocha.rb +6 -2
  48. data/lib/mocha_standalone.rb +3 -1
  49. data/mocha.gemspec +16 -9
  50. data/test/acceptance/bug_18914_test.rb +1 -1
  51. data/test/acceptance/bug_21465_test.rb +1 -1
  52. data/test/acceptance/bug_21563_test.rb +1 -1
  53. data/test/acceptance/exception_rescue_test.rb +1 -1
  54. data/test/acceptance/expectations_on_multiple_methods_test.rb +1 -1
  55. data/test/acceptance/expected_invocation_count_test.rb +1 -1
  56. data/test/acceptance/failure_messages_test.rb +1 -1
  57. data/test/acceptance/issue_65_test.rb +1 -1
  58. data/test/acceptance/issue_70_test.rb +1 -1
  59. data/test/acceptance/mocha_example_test.rb +1 -1
  60. data/test/acceptance/mocha_test_result_test.rb +1 -1
  61. data/test/acceptance/mock_test.rb +1 -1
  62. data/test/acceptance/mock_with_initializer_block_test.rb +1 -1
  63. data/test/acceptance/mocked_methods_dispatch_test.rb +1 -1
  64. data/test/acceptance/multiple_expectations_failure_message_test.rb +1 -1
  65. data/test/acceptance/optional_parameters_test.rb +1 -1
  66. data/test/acceptance/parameter_matcher_test.rb +1 -1
  67. data/test/acceptance/partial_mocks_test.rb +1 -1
  68. data/test/acceptance/raise_exception_test.rb +1 -1
  69. data/test/acceptance/return_value_test.rb +1 -1
  70. data/test/acceptance/sequence_test.rb +1 -1
  71. data/test/acceptance/states_test.rb +1 -1
  72. data/test/acceptance/stub_any_instance_method_test.rb +1 -1
  73. data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +1 -1
  74. data/test/acceptance/stub_class_method_defined_on_class_test.rb +1 -1
  75. data/test/acceptance/stub_class_method_defined_on_module_test.rb +1 -1
  76. data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +1 -1
  77. data/test/acceptance/stub_everything_test.rb +1 -1
  78. data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +1 -1
  79. data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +1 -1
  80. data/test/acceptance/stub_instance_method_defined_on_class_test.rb +1 -1
  81. data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +1 -1
  82. data/test/acceptance/stub_instance_method_defined_on_module_test.rb +1 -1
  83. data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +1 -1
  84. data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +1 -1
  85. data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +1 -1
  86. data/test/acceptance/stub_module_method_test.rb +1 -1
  87. data/test/acceptance/stub_test.rb +1 -1
  88. data/test/acceptance/stubba_example_test.rb +1 -1
  89. data/test/acceptance/stubba_test_result_test.rb +1 -1
  90. data/test/acceptance/stubbing_error_backtrace_test.rb +1 -1
  91. data/test/acceptance/stubbing_frozen_object_test.rb +1 -1
  92. data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +1 -1
  93. data/test/acceptance/stubbing_method_unnecessarily_test.rb +1 -1
  94. data/test/acceptance/stubbing_nil_test.rb +1 -1
  95. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +1 -1
  96. data/test/acceptance/stubbing_non_existent_class_method_test.rb +1 -1
  97. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +1 -1
  98. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +1 -1
  99. data/test/acceptance/stubbing_non_public_class_method_test.rb +1 -1
  100. data/test/acceptance/stubbing_non_public_instance_method_test.rb +1 -1
  101. data/test/acceptance/stubbing_on_non_mock_object_test.rb +1 -1
  102. data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +3 -3
  103. data/test/acceptance/throw_test.rb +1 -1
  104. data/test/acceptance/unstubbing_test.rb +1 -1
  105. data/test/integration/mini_test_test.rb +9 -0
  106. data/test/integration/shared_tests.rb +174 -0
  107. data/test/integration/test_unit_test.rb +9 -0
  108. data/test/mini_test_result.rb +0 -1
  109. data/test/test_runner.rb +14 -14
  110. data/test/unit/class_methods_test.rb +40 -0
  111. data/test/unit/method_matcher_test.rb +5 -0
  112. data/test/unit/mock_test.rb +6 -0
  113. data/test/unit/module_methods_test.rb +19 -0
  114. data/test/unit/object_methods_test.rb +45 -0
  115. metadata +44 -72
  116. data/COPYING.rdoc +0 -3
  117. data/README.rdoc +0 -56
  118. data/examples/misc.rb +0 -43
  119. data/examples/mocha.rb +0 -25
  120. data/examples/stubba.rb +0 -64
  121. data/gemfiles/Gemfile.minitest.3.3.0 +0 -7
  122. data/gemfiles/Gemfile.minitest.4.2.0 +0 -7
  123. data/lib/mocha/integration/mini_test/assertion_counter.rb +0 -23
  124. data/lib/mocha/integration/mini_test/version_330_to_410.rb +0 -65
  125. data/lib/mocha/integration/mini_test/version_420_to_433.rb +0 -70
  126. data/lib/mocha/integration/mini_test/version_440.rb +0 -70
  127. data/lib/mocha/integration/test_unit/assertion_counter.rb +0 -23
  128. data/lib/mocha/integration/test_unit/gem_version_230_to_253.rb +0 -58
  129. data/lib/mocha/options.rb +0 -1
  130. data/test/acceptance/api_test.rb +0 -139
  131. data/test/acceptance/minitest_test.rb +0 -162
  132. data/test/unit/object_test.rb +0 -92
  133. /data/{MIT-LICENSE.rdoc → MIT-LICENSE.md} +0 -0
@@ -214,6 +214,12 @@ class MockTest < Test::Unit::TestCase
214
214
  assert_equal true, mock.respond_to?(:method1)
215
215
  end
216
216
 
217
+ def test_should_respond_to_expected_method_as_string
218
+ mock = build_mock
219
+ mock.expects(:method1)
220
+ assert_equal true, mock.respond_to?('method1')
221
+ end
222
+
217
223
  def test_should_not_respond_to_unexpected_method
218
224
  mock = build_mock
219
225
  assert_equal false, mock.respond_to?(:method1)
@@ -0,0 +1,19 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+ require 'mocha/module_methods'
3
+ require 'mocha/object_methods'
4
+
5
+ class ModuleMethodsTest < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @module = Module.new.extend(Mocha::ModuleMethods, Mocha::ObjectMethods)
9
+ end
10
+
11
+ def test_should_use_stubba_module_method_for_module
12
+ assert_equal Mocha::ModuleMethod, @module.stubba_method
13
+ end
14
+
15
+ def test_should_stub_self_for_module
16
+ assert_equal @module, @module.stubba_object
17
+ end
18
+
19
+ end
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+ require 'mocha/object_methods'
3
+ require 'mocha/mock'
4
+
5
+ class ObjectMethodsTest < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @object = Object.new.extend(Mocha::ObjectMethods)
9
+ end
10
+
11
+ def test_should_build_mocha_referring_to_self
12
+ mocha = @object.mocha
13
+ assert_not_nil mocha
14
+ assert mocha.is_a?(Mocha::Mock)
15
+ assert_equal @object.mocha_inspect, mocha.mocha_inspect
16
+ end
17
+
18
+ def test_should_reuse_existing_mocha
19
+ mocha_1 = @object.mocha
20
+ mocha_2 = @object.mocha
21
+ assert_equal mocha_1, mocha_2
22
+ end
23
+
24
+ def test_should_reset_mocha
25
+ assert_nil @object.reset_mocha
26
+ end
27
+
28
+ def test_should_use_stubba_instance_method_for_object
29
+ assert_equal Mocha::InstanceMethod, Object.new.stubba_method
30
+ end
31
+
32
+ def test_should_stub_self_for_object
33
+ assert_equal @object, @object.stubba_object
34
+ end
35
+
36
+ def test_nobody_expects_the_spanish_inquisition
37
+ assert_raise(Mocha::ExpectationError) { @object.expects(:the_spanish_inquisition) }
38
+ end
39
+
40
+ def test_should_alias_object_method
41
+ klass = Class.new { def self.method_x; end }
42
+ assert_equal klass._method(:method_x), klass.method(:method_x)
43
+ end
44
+
45
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mocha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.8
4
+ version: 0.13.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-10 00:00:00.000000000 Z
12
+ date: 2012-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: metaclass
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &70267336106140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,15 +21,10 @@ dependencies:
21
21
  version: 0.0.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: 0.0.1
24
+ version_requirements: *70267336106140
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: rake
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &70267336104820 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ! '>='
@@ -37,15 +32,10 @@ dependencies:
37
32
  version: '0'
38
33
  type: :development
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
35
+ version_requirements: *70267336104820
46
36
  - !ruby/object:Gem::Dependency
47
37
  name: introspection
48
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &70267336104360 !ruby/object:Gem::Requirement
49
39
  none: false
50
40
  requirements:
51
41
  - - ~>
@@ -53,15 +43,10 @@ dependencies:
53
43
  version: 0.0.1
54
44
  type: :development
55
45
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 0.0.1
46
+ version_requirements: *70267336104360
62
47
  - !ruby/object:Gem::Dependency
63
48
  name: yard
64
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &70267336103960 !ruby/object:Gem::Requirement
65
50
  none: false
66
51
  requirements:
67
52
  - - ! '>='
@@ -69,48 +54,34 @@ dependencies:
69
54
  version: '0'
70
55
  type: :development
71
56
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
57
+ version_requirements: *70267336103960
78
58
  - !ruby/object:Gem::Dependency
79
- name: rdoc
80
- requirement: !ruby/object:Gem::Requirement
59
+ name: redcarpet
60
+ requirement: &70267336103420 !ruby/object:Gem::Requirement
81
61
  none: false
82
62
  requirements:
83
- - - ! '>='
63
+ - - ~>
84
64
  - !ruby/object:Gem::Version
85
- version: '0'
65
+ version: '1'
86
66
  type: :development
87
67
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
68
+ version_requirements: *70267336103420
94
69
  description: Mocking and stubbing library with JMock/SchMock syntax, which allows
95
70
  mocking and stubbing of methods on real (non-mock) classes.
96
71
  email: mocha-developer@googlegroups.com
97
72
  executables: []
98
73
  extensions: []
99
- extra_rdoc_files:
100
- - README.rdoc
101
- - COPYING.rdoc
74
+ extra_rdoc_files: []
102
75
  files:
103
76
  - .gemtest
104
- - COPYING.rdoc
77
+ - .yardopts
78
+ - COPYING.md
105
79
  - Gemfile
106
- - MIT-LICENSE.rdoc
107
- - README.rdoc
108
- - RELEASE.rdoc
80
+ - MIT-LICENSE.md
81
+ - README.md
82
+ - RELEASE.md
109
83
  - Rakefile
110
84
  - build-matrix.rb
111
- - examples/misc.rb
112
- - examples/mocha.rb
113
- - examples/stubba.rb
114
85
  - gemfiles/Gemfile.minitest.1.3.0
115
86
  - gemfiles/Gemfile.minitest.1.4.0
116
87
  - gemfiles/Gemfile.minitest.1.4.1
@@ -120,8 +91,6 @@ files:
120
91
  - gemfiles/Gemfile.minitest.2.11.0
121
92
  - gemfiles/Gemfile.minitest.2.11.2
122
93
  - gemfiles/Gemfile.minitest.2.3.0
123
- - gemfiles/Gemfile.minitest.3.3.0
124
- - gemfiles/Gemfile.minitest.4.2.0
125
94
  - gemfiles/Gemfile.minitest.latest
126
95
  - gemfiles/Gemfile.test-unit.2.0.0
127
96
  - gemfiles/Gemfile.test-unit.2.0.1
@@ -137,20 +106,25 @@ files:
137
106
  - lib/mocha/central.rb
138
107
  - lib/mocha/change_state_side_effect.rb
139
108
  - lib/mocha/class_method.rb
109
+ - lib/mocha/class_methods.rb
140
110
  - lib/mocha/configuration.rb
111
+ - lib/mocha/debug.rb
141
112
  - lib/mocha/deprecation.rb
142
113
  - lib/mocha/exception_raiser.rb
143
114
  - lib/mocha/expectation.rb
144
115
  - lib/mocha/expectation_error.rb
145
116
  - lib/mocha/expectation_error_factory.rb
146
117
  - lib/mocha/expectation_list.rb
118
+ - lib/mocha/hooks.rb
147
119
  - lib/mocha/in_state_ordering_constraint.rb
148
120
  - lib/mocha/inspect.rb
149
121
  - lib/mocha/instance_method.rb
150
122
  - lib/mocha/integration.rb
123
+ - lib/mocha/integration/assertion_counter.rb
151
124
  - lib/mocha/integration/mini_test.rb
152
- - lib/mocha/integration/mini_test/assertion_counter.rb
125
+ - lib/mocha/integration/mini_test/adapter.rb
153
126
  - lib/mocha/integration/mini_test/exception_translation.rb
127
+ - lib/mocha/integration/mini_test/nothing.rb
154
128
  - lib/mocha/integration/mini_test/version_13.rb
155
129
  - lib/mocha/integration/mini_test/version_140.rb
156
130
  - lib/mocha/integration/mini_test/version_141.rb
@@ -160,15 +134,14 @@ files:
160
134
  - lib/mocha/integration/mini_test/version_2110_to_2111.rb
161
135
  - lib/mocha/integration/mini_test/version_2112_to_320.rb
162
136
  - lib/mocha/integration/mini_test/version_230_to_2101.rb
163
- - lib/mocha/integration/mini_test/version_330_to_410.rb
164
- - lib/mocha/integration/mini_test/version_420_to_433.rb
165
- - lib/mocha/integration/mini_test/version_440.rb
137
+ - lib/mocha/integration/monkey_patcher.rb
166
138
  - lib/mocha/integration/test_unit.rb
167
- - lib/mocha/integration/test_unit/assertion_counter.rb
139
+ - lib/mocha/integration/test_unit/adapter.rb
168
140
  - lib/mocha/integration/test_unit/gem_version_200.rb
169
141
  - lib/mocha/integration/test_unit/gem_version_201_to_202.rb
170
142
  - lib/mocha/integration/test_unit/gem_version_203_to_220.rb
171
- - lib/mocha/integration/test_unit/gem_version_230_to_253.rb
143
+ - lib/mocha/integration/test_unit/gem_version_230_to_250.rb
144
+ - lib/mocha/integration/test_unit/nothing.rb
172
145
  - lib/mocha/integration/test_unit/ruby_version_185_and_below.rb
173
146
  - lib/mocha/integration/test_unit/ruby_version_186_and_above.rb
174
147
  - lib/mocha/is_a.rb
@@ -177,11 +150,11 @@ files:
177
150
  - lib/mocha/mock.rb
178
151
  - lib/mocha/mockery.rb
179
152
  - lib/mocha/module_method.rb
153
+ - lib/mocha/module_methods.rb
180
154
  - lib/mocha/multiple_yields.rb
181
155
  - lib/mocha/names.rb
182
156
  - lib/mocha/no_yields.rb
183
- - lib/mocha/object.rb
184
- - lib/mocha/options.rb
157
+ - lib/mocha/object_methods.rb
185
158
  - lib/mocha/parameter_matchers.rb
186
159
  - lib/mocha/parameter_matchers/all_of.rb
187
160
  - lib/mocha/parameter_matchers/any_of.rb
@@ -208,6 +181,7 @@ files:
208
181
  - lib/mocha/pretty_parameters.rb
209
182
  - lib/mocha/return_values.rb
210
183
  - lib/mocha/sequence.rb
184
+ - lib/mocha/setup.rb
211
185
  - lib/mocha/single_return_value.rb
212
186
  - lib/mocha/single_yield.rb
213
187
  - lib/mocha/standalone.rb
@@ -220,7 +194,6 @@ files:
220
194
  - lib/mocha_standalone.rb
221
195
  - mocha.gemspec
222
196
  - test/acceptance/acceptance_test_helper.rb
223
- - test/acceptance/api_test.rb
224
197
  - test/acceptance/bug_18914_test.rb
225
198
  - test/acceptance/bug_21465_test.rb
226
199
  - test/acceptance/bug_21563_test.rb
@@ -230,7 +203,6 @@ files:
230
203
  - test/acceptance/failure_messages_test.rb
231
204
  - test/acceptance/issue_65_test.rb
232
205
  - test/acceptance/issue_70_test.rb
233
- - test/acceptance/minitest_test.rb
234
206
  - test/acceptance/mocha_example_test.rb
235
207
  - test/acceptance/mocha_test_result_test.rb
236
208
  - test/acceptance/mock_test.rb
@@ -279,6 +251,9 @@ files:
279
251
  - test/acceptance/unstubbing_test.rb
280
252
  - test/deprecation_disabler.rb
281
253
  - test/execution_point.rb
254
+ - test/integration/mini_test_test.rb
255
+ - test/integration/shared_tests.rb
256
+ - test/integration/test_unit_test.rb
282
257
  - test/method_definer.rb
283
258
  - test/mini_test_result.rb
284
259
  - test/simple_counter.rb
@@ -292,6 +267,7 @@ files:
292
267
  - test/unit/central_test.rb
293
268
  - test/unit/change_state_side_effect_test.rb
294
269
  - test/unit/class_method_test.rb
270
+ - test/unit/class_methods_test.rb
295
271
  - test/unit/configuration_test.rb
296
272
  - test/unit/date_time_inspect_test.rb
297
273
  - test/unit/exception_raiser_test.rb
@@ -302,10 +278,11 @@ files:
302
278
  - test/unit/method_matcher_test.rb
303
279
  - test/unit/mock_test.rb
304
280
  - test/unit/mockery_test.rb
281
+ - test/unit/module_methods_test.rb
305
282
  - test/unit/multiple_yields_test.rb
306
283
  - test/unit/no_yields_test.rb
307
284
  - test/unit/object_inspect_test.rb
308
- - test/unit/object_test.rb
285
+ - test/unit/object_methods_test.rb
309
286
  - test/unit/parameter_matchers/all_of_test.rb
310
287
  - test/unit/parameter_matchers/any_of_test.rb
311
288
  - test/unit/parameter_matchers/anything_test.rb
@@ -335,12 +312,7 @@ files:
335
312
  homepage: http://gofreerange.com/mocha/docs
336
313
  licenses: []
337
314
  post_install_message:
338
- rdoc_options:
339
- - --title
340
- - Mocha
341
- - --main
342
- - README.rdoc
343
- - --line-numbers
315
+ rdoc_options: []
344
316
  require_paths:
345
317
  - lib
346
318
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -351,7 +323,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
351
323
  version: '0'
352
324
  segments:
353
325
  - 0
354
- hash: -1796930620254320821
326
+ hash: -4192078905680069090
355
327
  required_rubygems_version: !ruby/object:Gem::Requirement
356
328
  none: false
357
329
  requirements:
@@ -360,9 +332,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
360
332
  version: '0'
361
333
  requirements: []
362
334
  rubyforge_project: mocha
363
- rubygems_version: 1.8.24
335
+ rubygems_version: 1.8.11
364
336
  signing_key:
365
337
  specification_version: 3
366
338
  summary: Mocking and stubbing library
367
339
  test_files: []
368
- has_rdoc:
340
+ has_rdoc: yard
data/COPYING.rdoc DELETED
@@ -1,3 +0,0 @@
1
- Copyright Revieworld Ltd. 2006
2
-
3
- You may use, copy and redistribute this library under the same terms as {Ruby itself}[http://www.ruby-lang.org/en/LICENSE.txt] or under the {file:MIT-LICENSE.rdoc MIT license}.
data/README.rdoc DELETED
@@ -1,56 +0,0 @@
1
- = Mocha {<img src="https://secure.travis-ci.org/freerange/mocha.png" />}[http://travis-ci.org/freerange/mocha]
2
-
3
- Mocha is a library for mocking and stubbing using a syntax like that of {JMock}[http://www.jmock.org].
4
-
5
- It can be used with many testing frameworks e.g. {Test::Unit}[http://www.ruby-doc.org/core/classes/Test/Unit.html], {RSpec}[http://rspec.info/], {test/spec}[http://chneukirchen.org/repos/testspec/README], {expectations}[http://expectations.rubyforge.org/], {Dust}[http://dust.rubyforge.org/], {MiniTest}[http://rubyforge.org/projects/bfts] and even {JtestR}[http://jtestr.codehaus.org/].
6
-
7
- Mocha provides a unified, simple and readable syntax for both traditional mocking and partial mocking.
8
-
9
- Mocha was harvested from projects at {Reevoo}[http://www.reevoo.com/] by me ({James}[http://jamesmead.org/]) and my (then) colleagues {Ben}[http://www.techbelly.com/], {Chris}[http://chrisroos.co.uk/] and {Paul}[http://po-ru.com/].
10
-
11
- == Installation
12
-
13
- Install the latest version of the gem with the following command...
14
-
15
- $ gem install mocha
16
-
17
- Note that if you are intending to use Mocha with Test::Unit or MiniTest, you should only load Mocha *after* loading the relevant test library...
18
-
19
- require "test/unit"
20
- require "mocha"
21
-
22
- If you're using Bundler, ensure the correct load order by not auto-requiring Mocha in the Gemfile and then later load it once you know the test library has been loaded...
23
-
24
- # Gemfile
25
- gem "mocha", :require => false
26
-
27
- # Elsewhere after Bundler has loaded gems
28
- require "test/unit"
29
- require "mocha"
30
-
31
- Note that versions 0.10.2, 0.10.3 & 0.11.0 included a bug. Please do not use these versions.
32
-
33
- Or install the {Rails}[http://www.rubyonrails.org/] plugin...
34
-
35
- $ script/plugin install git://github.com/freerange/mocha.git
36
-
37
- Note that versions 0.9.6 & 0.9.7 of the Rails plugin were broken. As of version 0.9.8, you need to explicitly load Mocha after the test framework e.g. by adding "require 'mocha'" at the bottom of test/test_helper.rb.
38
-
39
- == Examples
40
-
41
- * Quick Start - {file:misc.rb Usage Examples}
42
- * Traditional mocking - {file:mocha.rb Star Trek Example}
43
- * Setting expectations on real classes - {file:stubba.rb Order Example}
44
- * More examples on {James Mead's Blog}[http://jamesmead.org/blog/]
45
- * {Mailing List Archives}[http://groups.google.com/group/mocha-developer]
46
-
47
- == Links
48
-
49
- * {Source code}[http://github.com/freerange/mocha]
50
- * {Bug reports}[http://github.com/freerange/mocha/issues]
51
-
52
- == License
53
-
54
- Copyright Revieworld Ltd. 2006
55
-
56
- You may use, copy and redistribute this library under the same terms as {Ruby itself}[http://www.ruby-lang.org/en/LICENSE.txt] or under the {file:MIT-LICENSE.rdoc MIT license}.
data/examples/misc.rb DELETED
@@ -1,43 +0,0 @@
1
- require 'test/unit'
2
- require 'mocha'
3
-
4
- class MiscExampleTest < Test::Unit::TestCase
5
-
6
- def test_mocking_a_class_method
7
- product = Product.new
8
- Product.expects(:find).with(1).returns(product)
9
- assert_equal product, Product.find(1)
10
- end
11
-
12
- def test_mocking_an_instance_method_on_a_real_object
13
- product = Product.new
14
- product.expects(:save).returns(true)
15
- assert product.save
16
- end
17
-
18
- def test_stubbing_instance_methods_on_real_objects
19
- prices = [stub(:pence => 1000), stub(:pence => 2000)]
20
- product = Product.new
21
- product.stubs(:prices).returns(prices)
22
- assert_equal [1000, 2000], product.prices.collect {|p| p.pence}
23
- end
24
-
25
- def test_stubbing_an_instance_method_on_all_instances_of_a_class
26
- Product.any_instance.stubs(:name).returns('stubbed_name')
27
- product = Product.new
28
- assert_equal 'stubbed_name', product.name
29
- end
30
-
31
- def test_traditional_mocking
32
- object = mock()
33
- object.expects(:expected_method).with(:p1, :p2).returns(:result)
34
- assert_equal :result, object.expected_method(:p1, :p2)
35
- end
36
-
37
- def test_shortcuts
38
- object = stub(:method1 => :result1, :method2 => :result2)
39
- assert_equal :result1, object.method1
40
- assert_equal :result2, object.method2
41
- end
42
-
43
- end
data/examples/mocha.rb DELETED
@@ -1,25 +0,0 @@
1
- class Enterprise
2
-
3
- def initialize(dilithium)
4
- @dilithium = dilithium
5
- end
6
-
7
- def go(warp_factor)
8
- warp_factor.times { @dilithium.nuke(:anti_matter) }
9
- end
10
-
11
- end
12
-
13
- require 'test/unit'
14
- require 'mocha'
15
-
16
- class EnterpriseTest < Test::Unit::TestCase
17
-
18
- def test_should_boldly_go
19
- dilithium = mock()
20
- dilithium.expects(:nuke).with(:anti_matter).at_least_once # auto-verified at end of test
21
- enterprise = Enterprise.new(dilithium)
22
- enterprise.go(2)
23
- end
24
-
25
- end
data/examples/stubba.rb DELETED
@@ -1,64 +0,0 @@
1
- class Order
2
-
3
- attr_accessor :shipped_on
4
-
5
- def total_cost
6
- line_items.inject(0) { |total, line_item| total + line_item.price } + shipping_cost
7
- end
8
-
9
- def total_weight
10
- line_items.inject(0) { |total, line_item| total + line_item.weight }
11
- end
12
-
13
- def shipping_cost
14
- total_weight * 5 + 10
15
- end
16
-
17
- class << self
18
-
19
- def find_all
20
- # Database.connection.execute('select * from orders...
21
- end
22
-
23
- def number_shipped_since(date)
24
- find_all.select { |order| order.shipped_on > date }.length
25
- end
26
-
27
- def unshipped_value
28
- find_all.inject(0) { |total, order| order.shipped_on ? total : total + order.total_cost }
29
- end
30
-
31
- end
32
-
33
- end
34
-
35
- require 'test/unit'
36
- require 'mocha'
37
-
38
- class OrderTest < Test::Unit::TestCase
39
-
40
- # illustrates stubbing instance method
41
- def test_should_calculate_shipping_cost_based_on_total_weight
42
- order = Order.new
43
- order.stubs(:total_weight).returns(10)
44
- assert_equal 60, order.shipping_cost
45
- end
46
-
47
- # illustrates stubbing class method
48
- def test_should_count_number_of_orders_shipped_after_specified_date
49
- now = Time.now; week_in_secs = 7 * 24 * 60 * 60
50
- order_1 = Order.new; order_1.shipped_on = now - 1 * week_in_secs
51
- order_2 = Order.new; order_2.shipped_on = now - 3 * week_in_secs
52
- Order.stubs(:find_all).returns([order_1, order_2])
53
- assert_equal 1, Order.number_shipped_since(now - 2 * week_in_secs)
54
- end
55
-
56
- # illustrates stubbing instance method for all instances of a class
57
- def test_should_calculate_value_of_unshipped_orders
58
- Order.stubs(:find_all).returns([Order.new, Order.new, Order.new])
59
- Order.any_instance.stubs(:shipped_on).returns(nil)
60
- Order.any_instance.stubs(:total_cost).returns(10)
61
- assert_equal 30, Order.unshipped_value
62
- end
63
-
64
- end
@@ -1,7 +0,0 @@
1
- source :rubygems
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "minitest", "3.3.0"
7
- end
@@ -1,7 +0,0 @@
1
- source :rubygems
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "minitest", "4.2.0"
7
- end
@@ -1,23 +0,0 @@
1
- module Mocha
2
-
3
- module Integration
4
-
5
- module MiniTest
6
-
7
- class AssertionCounter
8
-
9
- def initialize(test_case)
10
- @test_case = test_case
11
- end
12
-
13
- def increment
14
- @test_case.assert(true)
15
- end
16
-
17
- end
18
-
19
- end
20
-
21
- end
22
-
23
- end
@@ -1,65 +0,0 @@
1
- require 'mocha/integration/mini_test/assertion_counter'
2
- require 'mocha/expectation_error'
3
-
4
- module Mocha
5
-
6
- module Integration
7
-
8
- module MiniTest
9
-
10
- module Version330To410
11
- def self.included(mod)
12
- $stderr.puts "Monkey patching MiniTest >= v3.3.0 <= v4.1.0" if $mocha_options['debug']
13
- end
14
- def run runner
15
- trap "INFO" do
16
- runner.report.each_with_index do |msg, i|
17
- warn "\n%3d) %s" % [i + 1, msg]
18
- end
19
- warn ''
20
- time = runner.start_time ? Time.now - runner.start_time : 0
21
- warn "Current Test: %s#%s %.2fs" % [self.class, self.__name__, time]
22
- runner.status $stderr
23
- end if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
24
- assertion_counter = AssertionCounter.new(self)
25
- result = ""
26
- begin
27
- begin
28
- @passed = nil
29
- self.before_setup
30
- self.setup
31
- self.after_setup
32
- self.run_test self.__name__
33
- mocha_verify(assertion_counter)
34
- result = "." unless io?
35
- @passed = true
36
- rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
37
- raise
38
- rescue Exception => e
39
- @passed = false
40
- result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
41
- ensure
42
- %w{ before_teardown teardown after_teardown }.each do |hook|
43
- begin
44
- self.send hook
45
- rescue *::MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
46
- raise
47
- rescue Exception => e
48
- @passed = false
49
- result = runner.puke self.class, self.__name__, Mocha::Integration::MiniTest.translate(e)
50
- end
51
- end
52
- trap 'INFO', 'DEFAULT' if ::MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL
53
- end
54
- ensure
55
- mocha_teardown
56
- end
57
- result
58
- end
59
- end
60
-
61
- end
62
-
63
- end
64
-
65
- end