mocha 0.12.10 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. data/.yardopts +22 -0
  2. data/COPYING.md +3 -0
  3. data/{MIT-LICENSE.rdoc → MIT-LICENSE.md} +0 -0
  4. data/README.md +230 -0
  5. data/{RELEASE.rdoc → RELEASE.md} +61 -56
  6. data/Rakefile +45 -37
  7. data/build-matrix.rb +16 -4
  8. data/lib/mocha.rb +6 -2
  9. data/lib/mocha/api.rb +13 -16
  10. data/lib/mocha/class_method.rb +7 -3
  11. data/lib/mocha/class_methods.rb +63 -0
  12. data/lib/mocha/debug.rb +11 -0
  13. data/lib/mocha/deprecation.rb +1 -1
  14. data/lib/mocha/exception_raiser.rb +1 -1
  15. data/lib/mocha/expectation_error.rb +5 -0
  16. data/lib/mocha/expectation_error_factory.rb +19 -0
  17. data/lib/mocha/hooks.rb +43 -0
  18. data/lib/mocha/integration.rb +6 -38
  19. data/lib/mocha/integration/assertion_counter.rb +13 -0
  20. data/lib/mocha/integration/mini_test.rb +42 -60
  21. data/lib/mocha/integration/mini_test/adapter.rb +54 -0
  22. data/lib/mocha/integration/mini_test/exception_translation.rb +0 -6
  23. data/lib/mocha/integration/mini_test/nothing.rb +19 -0
  24. data/lib/mocha/integration/mini_test/version_13.rb +32 -25
  25. data/lib/mocha/integration/mini_test/version_140.rb +32 -26
  26. data/lib/mocha/integration/mini_test/version_141.rb +40 -34
  27. data/lib/mocha/integration/mini_test/version_142_to_172.rb +40 -34
  28. data/lib/mocha/integration/mini_test/version_200.rb +41 -35
  29. data/lib/mocha/integration/mini_test/version_201_to_222.rb +41 -35
  30. data/lib/mocha/integration/mini_test/version_2110_to_2111.rb +49 -43
  31. data/lib/mocha/integration/mini_test/version_2112_to_320.rb +53 -47
  32. data/lib/mocha/integration/mini_test/version_230_to_2101.rb +43 -37
  33. data/lib/mocha/integration/monkey_patcher.rb +18 -0
  34. data/lib/mocha/integration/test_unit.rb +38 -45
  35. data/lib/mocha/integration/test_unit/adapter.rb +51 -0
  36. data/lib/mocha/integration/test_unit/gem_version_200.rb +36 -29
  37. data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +36 -29
  38. data/lib/mocha/integration/test_unit/gem_version_203_to_220.rb +36 -29
  39. data/lib/mocha/integration/test_unit/gem_version_230_to_250.rb +65 -0
  40. data/lib/mocha/integration/test_unit/nothing.rb +19 -0
  41. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +36 -29
  42. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +37 -30
  43. data/lib/mocha/method_matcher.rb +1 -1
  44. data/lib/mocha/module_methods.rb +14 -0
  45. data/lib/mocha/{object.rb → object_methods.rb} +0 -83
  46. data/lib/mocha/setup.rb +10 -0
  47. data/lib/mocha/standalone.rb +3 -0
  48. data/lib/mocha/version.rb +1 -1
  49. data/lib/mocha_standalone.rb +3 -1
  50. data/mocha.gemspec +16 -9
  51. data/test/acceptance/bug_18914_test.rb +1 -1
  52. data/test/acceptance/bug_21465_test.rb +1 -1
  53. data/test/acceptance/bug_21563_test.rb +1 -1
  54. data/test/acceptance/exception_rescue_test.rb +1 -1
  55. data/test/acceptance/expectations_on_multiple_methods_test.rb +1 -1
  56. data/test/acceptance/expected_invocation_count_test.rb +1 -1
  57. data/test/acceptance/failure_messages_test.rb +1 -1
  58. data/test/acceptance/issue_65_test.rb +1 -1
  59. data/test/acceptance/issue_70_test.rb +1 -1
  60. data/test/acceptance/mocha_example_test.rb +1 -1
  61. data/test/acceptance/mocha_test_result_test.rb +1 -1
  62. data/test/acceptance/mock_test.rb +1 -1
  63. data/test/acceptance/mock_with_initializer_block_test.rb +1 -1
  64. data/test/acceptance/mocked_methods_dispatch_test.rb +1 -1
  65. data/test/acceptance/multiple_expectations_failure_message_test.rb +1 -1
  66. data/test/acceptance/optional_parameters_test.rb +1 -1
  67. data/test/acceptance/parameter_matcher_test.rb +1 -1
  68. data/test/acceptance/partial_mocks_test.rb +1 -1
  69. data/test/acceptance/raise_exception_test.rb +1 -1
  70. data/test/acceptance/return_value_test.rb +1 -1
  71. data/test/acceptance/sequence_test.rb +1 -1
  72. data/test/acceptance/states_test.rb +1 -1
  73. data/test/acceptance/stub_any_instance_method_test.rb +1 -1
  74. data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +1 -1
  75. data/test/acceptance/stub_class_method_defined_on_class_test.rb +1 -1
  76. data/test/acceptance/stub_class_method_defined_on_module_test.rb +1 -1
  77. data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +1 -1
  78. data/test/acceptance/stub_everything_test.rb +1 -1
  79. data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +1 -1
  80. data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +1 -1
  81. data/test/acceptance/stub_instance_method_defined_on_class_test.rb +1 -1
  82. data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +1 -1
  83. data/test/acceptance/stub_instance_method_defined_on_module_test.rb +1 -1
  84. data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +1 -1
  85. data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +1 -1
  86. data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +1 -1
  87. data/test/acceptance/stub_module_method_test.rb +1 -1
  88. data/test/acceptance/stub_test.rb +1 -1
  89. data/test/acceptance/stubba_example_test.rb +1 -1
  90. data/test/acceptance/stubba_test_result_test.rb +1 -1
  91. data/test/acceptance/stubbing_error_backtrace_test.rb +1 -1
  92. data/test/acceptance/stubbing_frozen_object_test.rb +1 -1
  93. data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +1 -1
  94. data/test/acceptance/stubbing_method_unnecessarily_test.rb +1 -1
  95. data/test/acceptance/stubbing_nil_test.rb +1 -1
  96. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +1 -1
  97. data/test/acceptance/stubbing_non_existent_class_method_test.rb +1 -1
  98. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +1 -1
  99. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +1 -1
  100. data/test/acceptance/stubbing_non_public_class_method_test.rb +1 -1
  101. data/test/acceptance/stubbing_non_public_instance_method_test.rb +1 -1
  102. data/test/acceptance/stubbing_on_non_mock_object_test.rb +1 -1
  103. data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +3 -3
  104. data/test/acceptance/throw_test.rb +1 -1
  105. data/test/acceptance/unstubbing_test.rb +1 -1
  106. data/test/integration/mini_test_test.rb +9 -0
  107. data/test/integration/shared_tests.rb +174 -0
  108. data/test/integration/test_unit_test.rb +9 -0
  109. data/test/mini_test_result.rb +0 -1
  110. data/test/test_runner.rb +14 -14
  111. data/test/unit/class_methods_test.rb +40 -0
  112. data/test/unit/method_matcher_test.rb +5 -0
  113. data/test/unit/mock_test.rb +6 -0
  114. data/test/unit/module_methods_test.rb +19 -0
  115. data/test/unit/object_methods_test.rb +45 -0
  116. metadata +45 -74
  117. data/COPYING.rdoc +0 -3
  118. data/README.rdoc +0 -56
  119. data/examples/misc.rb +0 -43
  120. data/examples/mocha.rb +0 -25
  121. data/examples/stubba.rb +0 -64
  122. data/gemfiles/Gemfile.minitest.3.3.0 +0 -7
  123. data/gemfiles/Gemfile.minitest.4.2.0 +0 -7
  124. data/lib/mocha/integration/mini_test/assertion_counter.rb +0 -23
  125. data/lib/mocha/integration/mini_test/version_330_to_410.rb +0 -65
  126. data/lib/mocha/integration/mini_test/version_420_to_433.rb +0 -70
  127. data/lib/mocha/integration/mini_test/version_440.rb +0 -70
  128. data/lib/mocha/integration/mini_test/version_450_to_461.rb +0 -72
  129. data/lib/mocha/integration/test_unit/assertion_counter.rb +0 -23
  130. data/lib/mocha/integration/test_unit/gem_version_230_to_254.rb +0 -58
  131. data/lib/mocha/options.rb +0 -1
  132. data/test/acceptance/api_test.rb +0 -139
  133. data/test/acceptance/minitest_test.rb +0 -162
  134. data/test/unit/object_test.rb +0 -92
@@ -0,0 +1,22 @@
1
+ --no-private
2
+ lib/mocha/api.rb
3
+ lib/mocha/hooks.rb
4
+ lib/mocha/mock.rb
5
+ lib/mocha/expectation.rb
6
+ lib/mocha/object_methods.rb
7
+ lib/mocha/class_methods.rb
8
+ lib/mocha/parameter_matchers.rb
9
+ lib/mocha/parameter_matchers
10
+ lib/mocha/state_machine.rb
11
+ lib/mocha/sequence.rb
12
+ lib/mocha/configuration.rb
13
+ lib/mocha/expectation_error_factory.rb
14
+ lib/mocha/expectation_error.rb
15
+ lib/mocha/stubbing_error.rb
16
+ lib/mocha/unexpected_invocation.rb
17
+ lib/mocha/integration/test_unit/adapter.rb
18
+ lib/mocha/integration/mini_test/adapter.rb
19
+ -
20
+ RELEASE.md
21
+ COPYING.md
22
+ MIT-LICENSE.md
@@ -0,0 +1,3 @@
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 [MIT license](http://www.opensource.org/licenses/MIT).
File without changes
@@ -0,0 +1,230 @@
1
+ ## Mocha [![build status](https://secure.travis-ci.org/freerange/mocha.png)](https://secure.travis-ci.org/freerange/mocha)
2
+
3
+ ### Description
4
+
5
+ * A Ruby library for mocking and stubbing.
6
+ * A unified, simple and readable syntax for both full & partial mocking.
7
+ * Built-in support for MiniTest and Test::Unit.
8
+ * Supported by many other test frameworks.
9
+
10
+ ### Installation
11
+
12
+ #### Gem
13
+
14
+ Install the latest version of the gem with the following command...
15
+
16
+ $ gem install mocha
17
+
18
+ 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...
19
+
20
+ require "test/unit"
21
+ require "mocha/setup"
22
+
23
+ #### Bundler
24
+
25
+ If you're using Bundler, ensure the correct load order by not auto-requiring Mocha in the `Gemfile` and then load it later once you know the test library has been loaded...
26
+
27
+ # Gemfile
28
+ gem "mocha", :require => false
29
+
30
+ # Elsewhere after Bundler has loaded gems
31
+ require "test/unit"
32
+ require "mocha/setup"
33
+
34
+ #### Rails
35
+
36
+ If you're loading Mocha using Bundler within a Rails application, you should ensure Mocha is not auto-required (as above) and load Mocha manually e.g. at the bottom of your `test_helper.rb`.
37
+
38
+ # Gemfile in Rails app
39
+ gem "mocha", :require => false
40
+
41
+ # At bottom of test_helper.rb
42
+ require "mocha/setup"
43
+
44
+ #### Rails Plugin
45
+
46
+ Install the Rails plugin...
47
+
48
+ $ rails plugin install git://github.com/freerange/mocha.git
49
+
50
+ Note that as of version 0.9.8, the Mocha plugin is not automatically loaded at plugin load time. Instead it must be manually loaded e.g. at the bottom of your `test_helper.rb`.
51
+
52
+ #### Know Issues
53
+
54
+ * Versions 0.10.2, 0.10.3 & 0.11.0 of the gem were broken.
55
+ * Versions 0.9.6 & 0.9.7 of the Rails plugin were broken.
56
+ * Please do not use these versions.
57
+
58
+ ### Usage
59
+
60
+ #### Quick Start
61
+
62
+ ```ruby
63
+ require 'test/unit'
64
+ require 'mocha/setup'
65
+
66
+ class MiscExampleTest < Test::Unit::TestCase
67
+ def test_mocking_a_class_method
68
+ product = Product.new
69
+ Product.expects(:find).with(1).returns(product)
70
+ assert_equal product, Product.find(1)
71
+ end
72
+
73
+ def test_mocking_an_instance_method_on_a_real_object
74
+ product = Product.new
75
+ product.expects(:save).returns(true)
76
+ assert product.save
77
+ end
78
+
79
+ def test_stubbing_instance_methods_on_real_objects
80
+ prices = [stub(:pence => 1000), stub(:pence => 2000)]
81
+ product = Product.new
82
+ product.stubs(:prices).returns(prices)
83
+ assert_equal [1000, 2000], product.prices.collect {|p| p.pence}
84
+ end
85
+
86
+ def test_stubbing_an_instance_method_on_all_instances_of_a_class
87
+ Product.any_instance.stubs(:name).returns('stubbed_name')
88
+ product = Product.new
89
+ assert_equal 'stubbed_name', product.name
90
+ end
91
+
92
+ def test_traditional_mocking
93
+ object = mock('object')
94
+ object.expects(:expected_method).with(:p1, :p2).returns(:result)
95
+ assert_equal :result, object.expected_method(:p1, :p2)
96
+ end
97
+
98
+ def test_shortcuts
99
+ object = stub(:method1 => :result1, :method2 => :result2)
100
+ assert_equal :result1, object.method1
101
+ assert_equal :result2, object.method2
102
+ end
103
+ end
104
+ ```
105
+
106
+ #### Mock Objects
107
+
108
+ ```ruby
109
+ class Enterprise
110
+ def initialize(dilithium)
111
+ @dilithium = dilithium
112
+ end
113
+
114
+ def go(warp_factor)
115
+ warp_factor.times { @dilithium.nuke(:anti_matter) }
116
+ end
117
+ end
118
+
119
+ require 'test/unit'
120
+ require 'mocha/setup'
121
+
122
+ class EnterpriseTest < Test::Unit::TestCase
123
+ def test_should_boldly_go
124
+ dilithium = mock()
125
+ dilithium.expects(:nuke).with(:anti_matter).at_least_once # auto-verified at end of test
126
+ enterprise = Enterprise.new(dilithium)
127
+ enterprise.go(2)
128
+ end
129
+ end
130
+ ```
131
+
132
+ #### Partial Mocking
133
+
134
+ ```ruby
135
+ class Order
136
+ attr_accessor :shipped_on
137
+
138
+ def total_cost
139
+ line_items.inject(0) { |total, line_item| total + line_item.price } + shipping_cost
140
+ end
141
+
142
+ def total_weight
143
+ line_items.inject(0) { |total, line_item| total + line_item.weight }
144
+ end
145
+
146
+ def shipping_cost
147
+ total_weight * 5 + 10
148
+ end
149
+
150
+ class << self
151
+ def find_all
152
+ # Database.connection.execute('select * from orders...
153
+ end
154
+
155
+ def number_shipped_since(date)
156
+ find_all.select { |order| order.shipped_on > date }.length
157
+ end
158
+
159
+ def unshipped_value
160
+ find_all.inject(0) { |total, order| order.shipped_on ? total : total + order.total_cost }
161
+ end
162
+ end
163
+ end
164
+
165
+ require 'test/unit'
166
+ require 'mocha/setup'
167
+
168
+ class OrderTest < Test::Unit::TestCase
169
+ # illustrates stubbing instance method
170
+ def test_should_calculate_shipping_cost_based_on_total_weight
171
+ order = Order.new
172
+ order.stubs(:total_weight).returns(10)
173
+ assert_equal 60, order.shipping_cost
174
+ end
175
+
176
+ # illustrates stubbing class method
177
+ def test_should_count_number_of_orders_shipped_after_specified_date
178
+ now = Time.now; week_in_secs = 7 * 24 * 60 * 60
179
+ order_1 = Order.new; order_1.shipped_on = now - 1 * week_in_secs
180
+ order_2 = Order.new; order_2.shipped_on = now - 3 * week_in_secs
181
+ Order.stubs(:find_all).returns([order_1, order_2])
182
+ assert_equal 1, Order.number_shipped_since(now - 2 * week_in_secs)
183
+ end
184
+
185
+ # illustrates stubbing instance method for all instances of a class
186
+ def test_should_calculate_value_of_unshipped_orders
187
+ Order.stubs(:find_all).returns([Order.new, Order.new, Order.new])
188
+ Order.any_instance.stubs(:shipped_on).returns(nil)
189
+ Order.any_instance.stubs(:total_cost).returns(10)
190
+ assert_equal 30, Order.unshipped_value
191
+ end
192
+ end
193
+ ```
194
+
195
+ ### Useful Links
196
+
197
+ * [Official Documentation](http://gofreerange.com/mocha/docs/)
198
+ * [Source Code](http://github.com/freerange/mocha)
199
+ * [Mailing List](http://groups.google.com/group/mocha-developer)
200
+ * [James Mead's Blog](http://jamesmead.org/blog/)
201
+ * [An Introduction To Mock Objects In Ruby](http://jamesmead.org/talks/2007-07-09-introduction-to-mock-objects-in-ruby-at-lrug/)
202
+ * [Mocks Aren't Stubs](http://martinfowler.com/articles/mocksArentStubs.html)
203
+ * [Growing Object-Oriented Software Guided By Tests](http://www.growing-object-oriented-software.com/)
204
+ * [Mock Roles Not Objects](http://www.jmock.org/oopsla2004.pdf)
205
+ * [jMock](http://www.jmock.org/)
206
+
207
+ ### Contributing
208
+
209
+ * Fork the repository.
210
+ * Make your changes in a branch (including tests).
211
+ * Ensure all of the tests run against all supported versions of Test::Unit, MiniTest & Ruby by running ./build-matrix.rb (note that currently this makes a *lot* of assumptions about your local environment e.g. rbenv installed with specific Ruby versions).
212
+ * Send us a pull request from your fork/branch.
213
+
214
+ ### Contributors
215
+
216
+ See this [list of contributors](https://github.com/freerange/mocha/graphs/contributors).
217
+
218
+ ### Translations
219
+
220
+ * [Serbo-Croatian](http://science.webhostinggeeks.com/mocha) by [WHG Team](http://webhostinggeeks.com/).
221
+
222
+ ### History
223
+
224
+ Mocha was initially harvested from projects at [Reevoo](http://www.reevoo.com/). It's syntax is heavily based on that of [jMock](http://www.jmock.org).
225
+
226
+ ### License
227
+
228
+ &copy; Copyright Revieworld Ltd. 2006
229
+
230
+ 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 [MIT license](http://www.opensource.org/licenses/MIT).
@@ -1,38 +1,43 @@
1
- = 0.12.10
2
- * Officially support minitest v4.6.1 (still monkey-patching).
3
-
4
- = 0.12.9
5
- * Officially support minitest v4.5.0 & test-unit v2.5.4 (still monkey-patching).
6
-
7
- = 0.12.8
8
- * Officially support minitest v4.4.0 & test-unit v2.5.3 (still monkey-patching).
9
-
10
- = 0.12.7
1
+ # Release Notes
2
+
3
+ ## 0.13.0
4
+ * Major overhaul of MiniTest & Test::Unit integration. Mocha now integrates with later versions of the two test libraries using documented hooks rather than monkey-patching. This should mean that Mocha will integrate with new versions of either library without the need to release a new version of Mocha each time, which was clearly bad and unsustainable. Many thanks to @tenderlove, @zenspider & @kou for their help, suggestions & patience.
5
+ * Temporarily deprecated `require 'mocha'`. Use `require 'mocha/setup'` instead. The plan is that eventually `require 'mocha'` will *not* automatically integrate with either of the two test libraries as it does at the moment, and you'll need to explicitly & separately trigger the integration. I think this will provide a lot more flexibility and will hopefully do away with the need for the `require: false` option in the `Gemfile` which has always confused people.
6
+ * Deprecated `require 'mocha_standalone'` and `require 'mocha/standalone'`. Use `require 'mocha/api` instead.
7
+ * Although these are not part of Mocha's public API, I thought I should mention that the MiniTest and Test::Unit assertion counter classes have been combined into a single class `Mocha::Integration::AssertionCounter`.
8
+ * Extracted Mocha::Hooks module from Mocha::API and added documentation for test library authors.
9
+ * Improvements to documentation. Much of it has been combined into the README file.
10
+ * Fix #101 - Mock#respond_to? doesn't work with a string argument - thanks to @urbanautomaton.
11
+ * Fix #105 - Travis link in README - thanks to @cknadler.
12
+ * Various improvements to automated testing of integration with test libraries.
13
+ * Make deprecation warnings more prominent.
14
+
15
+ ## 0.12.7
11
16
  * Officially support minitest v4.1.0 (still monkey-patching).
12
17
 
13
- = 0.12.6
18
+ ## 0.12.6
14
19
  * Fixes #103.
15
20
 
16
- = 0.12.5
21
+ ## 0.12.5
17
22
  * Officially support minitest v3.5.0 (still monkey-patching).
18
23
 
19
- = 0.12.4
24
+ ## 0.12.4
20
25
  * Officially support minitest v3.4.0 & test-unit v2.5.2 (still monkey-patching).
21
26
 
22
- = 0.12.3
27
+ ## 0.12.3
23
28
  * Revert rename of undocumented internal module since it turns out Rails/ActiveSupport is relying on its existence.
24
29
 
25
- = 0.12.2
30
+ ## 0.12.2
26
31
  * Officially support minitest v3.3.0 (still monkey-patching)
27
32
 
28
- = 0.12.1
33
+ ## 0.12.1
29
34
  * Deprecation warning (instead of fail fast) if neither Test::Unit nor MiniTest is loaded. Fixes #88.
30
35
  * Remove deprecated access to `Mocha::Standalone`.
31
36
  * Remove the deprecated file `stubba.rb`.
32
37
  * Officially support test-unit v2.5.1 (still monkey-patching).
33
38
  * Improve the API acceptance test.
34
39
 
35
- = 0.12.0
40
+ ## 0.12.0
36
41
  * Fail fast if neither Test::Unit nor MiniTest is loaded. Fixes #40.
37
42
  * Officially support MiniTest up to v3.2.0 (still monkey-patching).
38
43
  * Officially support test-unit v2.5.0 (still monkey-patching).
@@ -40,19 +45,19 @@
40
45
  * Add acceptance tests to demonstrate using a block as a custom parameter matcher.
41
46
  * Update Travis CI build status image to use the new build under the freerange account.
42
47
 
43
- = 0.11.4
48
+ ## 0.11.4
44
49
  * Homepage has moved to http://gofreerange.com/mocha/docs.
45
50
 
46
- = 0.11.3
51
+ ## 0.11.3
47
52
  * Fix for #78 i.e. alias Object#method as Object#_method, not Object#__method__ which already exists as another Ruby method.
48
53
 
49
- = 0.11.2
54
+ ## 0.11.2
50
55
  * Rails has a Request class which defines its own #method method. This broke the new mechanism for stubbing a method. This release includes a slightly modified version of fix #77 provided by @sikachu. See https://github.com/rails/rails/pull/5907 for further info.
51
56
 
52
- = 0.11.1
57
+ ## 0.11.1
53
58
  * In Ruby 1.8.7 methods accepting a block parameter were incorrectly restored without the block parameter after being stubbed. Fix for #76.
54
59
 
55
- = 0.11.0 (this version was yanked from rubygems.org)
60
+ ## 0.11.0
56
61
  * Store original method when stubbing rather than using alias_method. This fixes #41, #47, #74 and all tests now pass on both Ruby 1.8.7 and 1.9.3.
57
62
  * Attempting to stub a method on a frozen object should fail fast. See #68.
58
63
  * Prevent stubbing a method on nil by default. See #68.
@@ -64,14 +69,14 @@
64
69
  * Improve documentation for ObjectMethods.
65
70
  * Provide a way to run multiple tests within a single acceptance test method.
66
71
 
67
- = 0.10.5
72
+ ## 0.10.5
68
73
  * Fix for issue #66 (hopefully without regressing on issue #63) - Mocha::Mock has Mocha::Mockery as a dependency. Stop trying to pretend otherwise. Thanks to @kennyj for reporting.
69
74
  * Fix a bunch of warnings in Ruby 1.9. There are still the 6 test failures mentioned in issue #41 which I suspect are due to the introspection gem not being Ruby 1.9-compatible.
70
75
  * Add links to README for source code & issue tracker.
71
76
  * Fix for issue #67 - Make the travis-ci badge visible in the README. Thanks to Diego Plentz for pull request.
72
77
  * Fix for issue #70 - Rename Mock#expectations to Mock#__expectations__ to avoid conflicts. Thanks to Jeremy Stephens for pull request.
73
78
 
74
- = 0.10.4
79
+ ## 0.10.4
75
80
  * Fix for issue #65 - expectations not being verified in subsequent tests.
76
81
  * Fix for issue #63 - require Mocha::Mockery at Mocha::Mock class load time and not on invocation of Mock#method_missing.
77
82
  * Fix for issue #45 - raise ArgumentError if Mocha::ParameterMatchers#has_entry is given
@@ -79,13 +84,13 @@ Hash with wrong number of entries.
79
84
  * Make global variable name more obscure to avoid clashes with other libraries.
80
85
  * Move travis-ci-related gemfiles into their own directory.
81
86
 
82
- = 0.10.3
87
+ ## 0.10.3
83
88
  * Fix for issue #57. Gem::Requirement#=~ was only added in rubygems v1.8.0, but Object#=~ means the result of various monkey-patching checks is always false/nil for earlier versions of rubygems. However, the method it aliases #satisfied_by? has existed since Gem::Dependency was extracted from Gem::Version in rubygems v0.9.4.4, so it's much safer to use that. Thanks to fguillen for reporting and helping with diagnosis.
84
89
 
85
- = 0.10.2
90
+ ## 0.10.2
86
91
  * Merge pull request #53. Unstubbing a method should not remove expectations for other stubbed methods. Fixes #52. Thanks to saikat.
87
92
 
88
- = 0.10.1
93
+ ## 0.10.1
89
94
  * Merge pull request #51. Use Gem::Requirement & Gem::Version for version comparison. Fixes issue #50. Thanks to meineerde.
90
95
  * Fixed typo in rdoc for Mocha::ObjectMethods.
91
96
  * Improve README as suggested in issue #46. Explain that Mocha must be loaded after test libraries and how to achieve this using Bundler.
@@ -95,7 +100,7 @@ Hash with wrong number of entries.
95
100
  * Support for MiniTest up to v2.6.2 has been verified.
96
101
  * Add explicit development dependency on coderay for generating syntax-highlighted code examples.
97
102
 
98
- = 0.10.0
103
+ ## 0.10.0
99
104
  * Add Expectation#throws to allow a stubbed method to use Kernel#throw.
100
105
  * Updates for versions of Test::Unit up to and including v2.3.3 (including patch by Jens Fahnenbruck).
101
106
  * Updates for versions of MiniTest up to and including v2.5.1.
@@ -114,13 +119,13 @@ Hash with wrong number of entries.
114
119
  * Remove the `use_test_unit_gem` MOCHA_OPTION which hasn't worked since we switched to bundler - we can now run the tests specifying a different Gemfile instead.
115
120
  * Use multiple Gemfiles seems to run Travis CI builds against multiple version of test-unit & minitest.
116
121
 
117
- = 0.9.12
122
+ ## 0.9.12
118
123
  * Make Mocha's tests pass under Ruby 1.9.2 i.e. using MiniTest. One of the main issues was that we were not parsing stacktraces on MiniTest errors comprehensively enough.
119
124
  * Avoid 'circular require considered harmful' warning when running Mocha's tests in Ruby 1.9.2
120
125
  * Make performance tests work on Ruby 1.9.2 i.e. using MiniTest.
121
126
  * Declare rake as a *development* dependency with newer versions of Rubygems since it's only needed to carry out developer-related tasks.
122
127
 
123
- = 0.9.11
128
+ ## 0.9.11
124
129
  * Added explicit support for minitest v1.5.0 to v2.0.2.
125
130
  * Make testable by rubygems-test.
126
131
  * Update links to my blog and make other links consistent.
@@ -128,13 +133,13 @@ Hash with wrong number of entries.
128
133
  * Include unexpected invocation in failure message and change the language slightly to make the failure message less confusing. See http://floehopper.lighthouseapp.com/projects/22289/tickets/52.
129
134
  * No need to create regular expression every time the BacktraceFilter#filtered method is called. See http://floehopper.lighthouseapp.com/projects/22289-mocha/tickets/66.
130
135
 
131
- = 0.9.10
136
+ ## 0.9.10
132
137
  * Added Mocha::ObjectMethods#unstub method - https://github.com/floehopper/mocha/issues#issue/6
133
138
  * Inherit Mocha::ExpectationError from Exception instead of StandardError to reduce the chances of a test passing by accident - thanks to James Sanders (jsanders) - https://github.com/floehopper/mocha/issues#issue/15
134
139
  * Fixed bug - GitHub README page to link correctly to code examples - https://github.com/floehopper/mocha/issues/closed#issue/11
135
140
  * Fixed bug - PASSTHROUGH_EXCEPTIONS are defined on MiniTest::Unit::TestCase not in Mocha - thanks to Brian Troutwine (blt) - https://github.com/floehopper/mocha/issues/closed#issue/14
136
141
 
137
- = 0.9.9
142
+ ## 0.9.9
138
143
  * Avoid loading bits of the test-unit gem by accident. This is an attempt at a fix for the problem that James Adam reported [1]. By using 'load' instead of 'require' to detect the version of Test::Unit, we can avoid rubygems trying to load bits of the test-unit gem when it's not wanted. [1] http://floehopper.lighthouseapp.com/projects/22289-mocha/tickets/50#ticket-50-13
139
144
  * Fix exception when running rake without test-unit gem. When test-unit gem >=v2.0.0 was installed but the "use_test_unit_gem" MOCHA_OPTIONS was not specified, a "comparison of Fixnum with Hash failed" exception was being raised when running the performance tests. This was because bits of the test-unit gem were being loaded accidentally and a Hash was being incorrectly supplied to the TestRunner.run method.
140
145
  * Explicitly require rubygems for running tests via rake using test-unit gem.
@@ -152,17 +157,17 @@ Hash with wrong number of entries.
152
157
  * Improved RDoc including a change suggested by Rohit Arondekar (rohit).
153
158
  * Updated gemspec as requested by Sam Woodard (shwoodard).
154
159
 
155
- = 0.9.8
160
+ ## 0.9.8
156
161
  * Fixed bug "NameError raised when using Mocha as a Rails plug-in" - http://floehopper.lighthouseapp.com/projects/22289/tickets/53. Since 0.9.6 the Rails plugin has been broken. See bug report for details. You will need to explicitly load Mocha *after* the test framework has been loaded, e.g. by adding "require 'mocha'" at the bottom of test/test_helper.rb.
157
162
  * Make Mocha::ParameterMatchers#regexp_matches, #includes, #has_value, #has_key more robust. Thanks to Sander Hartlage.
158
163
  * Allow passing a block to Mocha::Configuration methods to only change configuration for the duration of the block. Thanks to Dan Manges.
159
164
  * Fixed bug "doc generation fails in 0.9.7 gem" - http://floehopper.lighthouseapp.com/projects/22289/tickets/51.
160
165
  * Remove rdoc template incorporating google analytics from source control. The file just needs to exist locally and be ignored by source control. This should stop the warning showing up on e.g. RunCodeRun build results.
161
166
 
162
- = 0.9.7
167
+ ## 0.9.7
163
168
  * Although I had provided a deprecation warning for people using Mocha::Standalone, I had assumed people wouldn't be explicitly loading the mocha/standalone.rb file. It turns out this assumption was incorrect at least in the case of Rspec. This is now fixed.
164
169
 
165
- = 0.9.6
170
+ ## 0.9.6
166
171
  * Version 2.0.1 of the test-unit gem introduced a private 'run_test' method on TestCase which clashed with the public TestRunner#run_test method. So this latter method has been renamed to 'run_as_test'.
167
172
  * Stop requiring rubygems - this should be an environmental choice for the user. http://gist.github.com/54177 - describes why requiring rubygems in your library code is a bad idea.
168
173
  * It seems like overkill to vendorize coderay and meta_project when they're only needed to generate the examples for documentation and for publishing files on RubyForge. So I'm removing them and installing them locally as gems when I need them.
@@ -177,30 +182,30 @@ Hash with wrong number of entries.
177
182
  * Chad Humphries pointed out that in Ruby 1.9.1, if you are not using Test::Unit or MiniTest, Mocha will attempt to load and monkey-patch Test::Unit. Mocha will now only monkey-patch Test::Unit and/or MiniTest if they have already been loaded. MiniTest tests will now run in both Ruby 1.8.6 (with MiniTest gem) and in Ruby 1.9.1 (with MiniTest std lib). See Ligthouse ticket - http://floehopper.lighthouseapp.com/projects/22289/tickets/49.
178
183
  * Made Mocha compatible with minitest 1.4.0 and above (thanks to Denis Defreyne).
179
184
 
180
- = 0.9.5
185
+ ## 0.9.5
181
186
  * Fixed Lighthouse bug #32 - stub_everything should mean mock responds to anything.
182
187
  * Added Expectation#twice to improve readability. Thanks to pull request from Celestino Gomes.
183
188
  * In Ruby 1.9.1, requiring 'test/unit' loads a thin wrapper around MiniTest and Test::Unit::TestCase ends up inheriting from MiniTest::Unit::TestCase. So we need to avoid including the Mocha modules more than once to avoid nasty consequences. Thanks to Matthias Hennemeyer for help with this.
184
189
  * Ruby 1.9 includes rake, but not rake/contrib. For the moment I've moved the sshpublisher require into the only rake task that needs it, so that I can at least run the tests in Ruby 1.9. It looks like I will need to build a rake/contrib gem or similar to get this working properly - http://intertwingly.net/blog/2008/01/07/Rake-Contrib-for-1-9
185
190
 
186
- = 0.9.4
191
+ ## 0.9.4
187
192
  * Added mocha.gemspec file generated with Chad Woolley's new rake task, so that a floehopper-mocha gem will get built on GitHub.
188
193
  * Add rake task to update mocha.gemspec with unique version, which will cause gem to be auto-built on github
189
194
  * As Tobias Crawley correctly pointed out in feature request #23055 "stubs(with_hash) not working with existing object" [1], following the principle of least surprise, it should be possible to call ObjectMethods#expects & ObjectMethods#stubs with a Hash of method_names vs return_values like you can with Mock#expects & Mock#stubs. I've also updated & improved the docs to reflect the changes. [1] http://rubyforge.org/tracker/index.php?func=detail&aid=23055&group_id=1917&atid=7480
190
195
  * Removed deprecated gem autorequire.
191
196
 
192
- = 0.9.3
197
+ ## 0.9.3
193
198
  * Added support for MiniTest thanks to Jeff Smick.
194
199
  * Fixed a possible bug with some of the non-default Configuration options relating to the argument to Object#respond_to?
195
200
  * As per Jay Fields recommendations [1] and with further impetus from a talk at Ruby Manor, any methods added to core classes are now added by including a module. This means that Mocha is a better citizen of the Ruby world and it's behaviour is more easily extended. [1] http://blog.jayfields.com/2008/07/ruby-underuse-of-modules.html & http://blog.jayfields.com/2008/07/ruby-redefine-method-behavior.html
196
201
  * Removed deprecated gem autorequire.
197
202
 
198
- = 0.9.2
203
+ ## 0.9.2
199
204
  * Improved documentation to address [#22530] 'Mock methods with multiple return values not possible?'
200
205
  * respond_with parameter matcher was not available in tests.
201
206
  * Patch [#22630] Fix for a bug in running Rails tests with Ruby 1.8.7. Array#flatten was being called which in turn was checking whether each element responded to #to_ary. This check was using the two parameter version of #respond_to?, but Mock was only defining a one parameter version.
202
207
 
203
- = 0.9.1
208
+ ## 0.9.1
204
209
 
205
210
  * Fixed bug #21465 - expects & stubs should support method names as strings (as well as symbols) or fail fast. Convert all expectation method names to a symbol in case they were supplied as a string.
206
211
  * By removing Mock#unexpected_method_called we reduce the number of methods vulnerable to the problem that surfaced in bug #21563.
@@ -213,7 +218,7 @@ Hash with wrong number of entries.
213
218
  * It's more readable to talk about 'once' and 'twice' rather than '1 time' and '2 times'.
214
219
  * Fix bug #20883 - never should raise when called to prevent follow up errors. Fail fast when there are no matching invokable expectations and handle the stub_everything case sensibly. This might not be entirely backwards compatible, but I think the benefits outweigh the risks. The most likely change is that a test that was already failing will now fail faster, which doesn't seem so awful.
215
220
 
216
- = 0.9.0
221
+ ## 0.9.0
217
222
 
218
223
  * Configurable warnings or errors
219
224
  * when a method on a non-public method is stubbed
@@ -258,16 +263,16 @@ Hash with wrong number of entries.
258
263
  * 15977 in revision 198 - http://rubyforge.org/tracker/index.php?func=detail&aid=15977&group_id=1917&atid=7477
259
264
  * 11885 in revision 156 - http://rubyforge.org/tracker/index.php?func=detail&aid=11885&group_id=1917&atid=7477
260
265
 
261
- = 0.5.5
266
+ ## 0.5.5
262
267
 
263
268
  - Renamed Matches parameter matcher to RegexpMatches for clarity.
264
269
  - Added noframes tag to rdoc index to assist Google.
265
270
 
266
- = 0.5.4
271
+ ## 0.5.4
267
272
 
268
273
  - Added matches parameter matcher for matching regular expressions.
269
274
 
270
- = 0.5.3
275
+ ## 0.5.3
271
276
 
272
277
  - Attempt to fix packaging problems by switching to newer version (1.15.1) of gnutar and setting COPY_EXTENDED_ATTRIBUTES_DISABLE environment variable.
273
278
  - Removed unused ExpectationSequenceError exception.
@@ -275,16 +280,16 @@ Hash with wrong number of entries.
275
280
  - Added Google Webmaster meta tag to rdoc template header.
276
281
  - Put Google Webmaster meta tag in the right header i.e. the one for the index page.
277
282
 
278
- = 0.5.2
283
+ ## 0.5.2
279
284
 
280
285
  - Fix bug 11885 - "never doesn't work with stub_everything" submitted by Alexander Lang. In fixing this bug, also fixed undiscoverd bug where expected & actual invocation counts were being incorrectly reported which seems to have been introduced when fixes were added for invocation dispatch (see MockedMethodDispatchAcceptanceTest).
281
286
  - Previously when an expectation did not allow more invocations, it was treated as not matching. Now we prefer matching expectations which allow more invocations, but still match expectations which cannot allow more invocations. I think this may be overcomplicating things, but let's see how it goes.
282
287
 
283
- = 0.5.1
288
+ ## 0.5.1
284
289
 
285
290
  - Fixed bug #11583 "Mocha 0.5.0 throwing unexpected warnings". Also switched on ruby warning for all rake test tasks. Fixed majority of warnings, but some left to fix.
286
291
 
287
- = 0.5.0
292
+ ## 0.5.0
288
293
 
289
294
  - Parameter Matchers - I’ve added a few Hamcrest-style parameter matchers which are designed to be used inside Expectation#with. The following matchers are currently available: anything(), includes(), has_key(), has_value(), has_entry(), all_of() & any_of(). More to follow soon. The idea is eventually to get rid of the nasty parameter_block option on Expectation#with.
290
295
 
@@ -348,7 +353,7 @@ Hash with wrong number of entries.
348
353
  - Fiddled with mocha_inspect and tests to give more sensible results on x86 platform.
349
354
  - Fixed bug #7834 "infinite_range.rb makes incorrect assumption about to_f" logged by James Moore.
350
355
 
351
- = 0.4.0
356
+ ## 0.4.0
352
357
 
353
358
  - Allow naming of mocks (patch from Chris Roos).
354
359
  - Specify multiple return values for consecutive calls.
@@ -368,19 +373,19 @@ Hash with wrong number of entries.
368
373
  - Stubba & SmartTestCase modules incorporated into Mocha module so only need to require 'mocha' - no longer need to require 'stubba'.
369
374
  - AutoMocha removed.
370
375
 
371
- = 0.3.3
376
+ ## 0.3.3
372
377
 
373
378
  - Quick bug fix to restore instance methods on partial mocks (for Kevin Clark).
374
379
 
375
- = 0.3.2
380
+ ## 0.3.2
376
381
 
377
382
  - Examples added.
378
383
 
379
- = 0.3.1
384
+ ## 0.3.1
380
385
 
381
386
  - Dual licensing with MIT license added.
382
387
 
383
- = 0.3.0
388
+ ## 0.3.0
384
389
 
385
390
  * Rails plugin.
386
391
  * Auto-verify for expectations on concrete classes.
@@ -391,11 +396,11 @@ Hash with wrong number of entries.
391
396
  * Create stubs which stub all method calls.
392
397
  * Mocks now respond_to? expected methods.
393
398
 
394
- = 0.2.1
399
+ ## 0.2.1
395
400
 
396
401
  * Rename MochaAcceptanceTest::Rover#move method to avoid conflict with Rake (in Ruby 1.8.4 only?)
397
402
 
398
- = 0.2.0
403
+ ## 0.2.0
399
404
 
400
405
  * Small change to SetupAndTeardown#teardown_stubs suggested by Luke Redpath (http://www.lukeredpath.co.uk) to allow use of Stubba with RSpec (http://rspec.rubyforge.org).
401
406
  * Reorganized directory structure and extracted addition of setup and teardown methods into SmartTestCase mini-library.
@@ -439,10 +444,10 @@ you can have...
439
444
 
440
445
  wotsit = stub(:thingummy => 5, :summat => 25)
441
446
 
442
- = 0.1.2
447
+ ## 0.1.2
443
448
 
444
449
  * Minor tweaks
445
450
 
446
- = 0.1.1
451
+ ## 0.1.1
447
452
 
448
453
  * Initial release.