mocha 1.16.1 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -13
  3. data/.yardopts +1 -2
  4. data/COPYING.md +2 -2
  5. data/Gemfile +7 -4
  6. data/MIT-LICENSE.md +1 -1
  7. data/README.md +23 -24
  8. data/RELEASE.md +294 -0
  9. data/Rakefile +23 -24
  10. data/lib/mocha/api.rb +30 -71
  11. data/lib/mocha/backtrace_filter.rb +2 -2
  12. data/lib/mocha/cardinality.rb +4 -0
  13. data/lib/mocha/configuration.rb +44 -126
  14. data/lib/mocha/debug.rb +2 -5
  15. data/lib/mocha/detection/{mini_test.rb → minitest.rb} +5 -5
  16. data/lib/mocha/detection/test_unit.rb +2 -2
  17. data/lib/mocha/expectation.rb +99 -12
  18. data/lib/mocha/expectation_error_factory.rb +2 -2
  19. data/lib/mocha/expectation_list.rb +8 -6
  20. data/lib/mocha/hooks.rb +10 -4
  21. data/lib/mocha/inspect.rb +15 -4
  22. data/lib/mocha/integration/{mini_test → minitest}/adapter.rb +21 -6
  23. data/lib/mocha/integration/{mini_test → minitest}/exception_translation.rb +2 -2
  24. data/lib/mocha/integration/minitest.rb +28 -0
  25. data/lib/mocha/integration/test_unit/adapter.rb +9 -4
  26. data/lib/mocha/integration/test_unit.rb +10 -31
  27. data/lib/mocha/invocation.rb +2 -15
  28. data/lib/mocha/minitest.rb +3 -6
  29. data/lib/mocha/mock.rb +45 -18
  30. data/lib/mocha/mockery.rb +13 -9
  31. data/lib/mocha/names.rb +1 -1
  32. data/lib/mocha/object_methods.rb +2 -2
  33. data/lib/mocha/parameter_matchers/base.rb +4 -9
  34. data/lib/mocha/parameter_matchers/equivalent_uri.rb +1 -2
  35. data/lib/mocha/parameter_matchers/has_entries.rb +7 -2
  36. data/lib/mocha/parameter_matchers/includes.rb +3 -3
  37. data/lib/mocha/parameter_matchers/instance_methods.rb +10 -2
  38. data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +66 -0
  39. data/lib/mocha/parameter_matchers/responds_with.rb +32 -5
  40. data/lib/mocha/parameters_matcher.rb +10 -6
  41. data/lib/mocha/ruby_version.rb +2 -9
  42. data/lib/mocha/stubbed_method.rb +3 -39
  43. data/lib/mocha/test_unit.rb +1 -4
  44. data/lib/mocha/version.rb +1 -1
  45. data/mocha.gemspec +11 -1
  46. metadata +31 -31
  47. data/init.rb +0 -1
  48. data/lib/mocha/integration/mini_test/nothing.rb +0 -19
  49. data/lib/mocha/integration/mini_test/version_13.rb +0 -54
  50. data/lib/mocha/integration/mini_test/version_140.rb +0 -54
  51. data/lib/mocha/integration/mini_test/version_141.rb +0 -65
  52. data/lib/mocha/integration/mini_test/version_142_to_172.rb +0 -65
  53. data/lib/mocha/integration/mini_test/version_200.rb +0 -66
  54. data/lib/mocha/integration/mini_test/version_201_to_222.rb +0 -66
  55. data/lib/mocha/integration/mini_test/version_2110_to_2111.rb +0 -70
  56. data/lib/mocha/integration/mini_test/version_2112_to_320.rb +0 -73
  57. data/lib/mocha/integration/mini_test/version_230_to_2101.rb +0 -68
  58. data/lib/mocha/integration/mini_test.rb +0 -56
  59. data/lib/mocha/integration/test_unit/gem_version_200.rb +0 -62
  60. data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +0 -62
  61. data/lib/mocha/integration/test_unit/gem_version_203_to_220.rb +0 -62
  62. data/lib/mocha/integration/test_unit/gem_version_230_to_250.rb +0 -68
  63. data/lib/mocha/integration/test_unit/nothing.rb +0 -19
  64. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +0 -63
  65. data/lib/mocha/integration.rb +0 -11
  66. data/lib/mocha/setup.rb +0 -14
  67. data/yard-templates/default/layout/html/google_analytics.erb +0 -8
  68. data/yard-templates/default/layout/html/setup.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e91d0f079638506c5d57fc91f1d84f3232e9c9b923b4dcf173697ab564d72a9
4
- data.tar.gz: 7522a45c0fe7808e89b68e9703959fa320c722bf6fa760091e8aae7f9f25237c
3
+ metadata.gz: 61f3a7bc2e73c16b715a31472883ed85fc55726d28e43d051b5d62da21362b52
4
+ data.tar.gz: 8e2b6b411543932dfb02f9d97cbe0eb35ed48e983e9079a426c7963f075416da
5
5
  SHA512:
6
- metadata.gz: 4ac64c4e5ab1ffca88e410601a3f10e4dda4fde0cb2e00b6975280dcd9410f16918f249d6b98926cfc18956a165ef1e24d0d719d093ff29c9663bdfadb8b6457
7
- data.tar.gz: 4eb4166b55e1bb8ee63e8848db0f64d6368abe6ae03897aa680143e6a046202ec5420cbf2a2d01f2f4d0c893210dccf7277627ce81f3db523fd76c1de4618926
6
+ metadata.gz: dd352ea7b0ef64b7e56880a90faecd452b67891765a23441013f73405546da1746314025bb4c556b1322ea621a7d28d940efc77272a52b63716993bc27ebe94f
7
+ data.tar.gz: e229f55ddd4d53350941bef0af9d3b1026a76f904b666d187ebd6d808feb284101677c66e47005ea3889767626e1cd556330e222d80752f57be89665d4fafd3a
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.2 # closest to required_ruby_version of '>= 1.9'
4
+ TargetRubyVersion: 2.2 # closest to required_ruby_version of '>= 2.1'
5
5
 
6
6
  # Even the reference in the documentation suggests that you should prefer
7
7
  # `alias_method` vs `alias`, so I don't understand why that isn't the default.
@@ -11,22 +11,10 @@ Style/Alias:
11
11
  Style/Documentation:
12
12
  Enabled: false
13
13
 
14
- # Enumerable#each_with_object only available since Ruby v1.9
15
- Style/EachWithObject:
16
- Enabled: false
17
-
18
14
  # Kernel#__dir__ has only been available since Ruby v2.0
19
15
  Style/ExpandPathArguments:
20
16
  Enabled: false
21
17
 
22
- # Kernel#format has only supported named references since Ruby v1.9
23
- Style/FormatStringToken:
24
- EnforcedStyle: unannotated
25
-
26
- # ruby19 style has only been supported since Ruby v1.9
27
- Style/HashSyntax:
28
- EnforcedStyle: hash_rockets
29
-
30
18
  # I'm not keen on this cop, because it's easy to miss the conditional
31
19
  # I think the results are particularly unhelpful when Metrics/LineLength is big
32
20
  Style/IfUnlessModifier:
@@ -48,6 +36,15 @@ Style/WhileUntilModifier:
48
36
  Style/AccessModifierDeclarations:
49
37
  Enabled: false
50
38
 
39
+ # `Module#===` is useful in presence of objects such as mocks
40
+ # that may have a `is_a?` implementation that lies.
41
+ Style/CaseEquality:
42
+ Enabled: false
43
+
44
+ # This is useful when using `ExecutionPoint.current` to make tests more robust
45
+ Style/Semicolon:
46
+ Enabled: false
47
+
51
48
  # Enabling this cop results in an "Infinite loop detected" exception
52
49
  Layout/AccessModifierIndentation:
53
50
  Enabled: false
data/.yardopts CHANGED
@@ -1,5 +1,4 @@
1
1
  --output-dir docs
2
- --template-path yard-templates
3
2
  --no-private
4
3
  lib/mocha/api.rb
5
4
  lib/mocha/hooks.rb
@@ -17,7 +16,7 @@ lib/mocha/expectation_error.rb
17
16
  lib/mocha/stubbing_error.rb
18
17
  lib/mocha/unexpected_invocation.rb
19
18
  lib/mocha/integration/test_unit/adapter.rb
20
- lib/mocha/integration/mini_test/adapter.rb
19
+ lib/mocha/integration/minitest/adapter.rb
21
20
  -
22
21
  RELEASE.md
23
22
  COPYING.md
data/COPYING.md CHANGED
@@ -1,3 +1,3 @@
1
- Copyright Revieworld Ltd. 2006
1
+ Copyright James Mead 2006
2
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).
3
+ You may use, copy and redistribute this library under the same terms as [Ruby itself](https://www.ruby-lang.org/en/about/license.txt) or under the [MIT license](https://mit-license.org/).
data/Gemfile CHANGED
@@ -3,9 +3,7 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  # rubocop:disable Bundler/DuplicatedGem
6
- if RUBY_VERSION < '2'
7
- gem 'rake', '~> 12.2.1'
8
- elsif RUBY_VERSION < '2.2'
6
+ if RUBY_VERSION < '2.2'
9
7
  gem 'rake', '~> 12.3.3'
10
8
  else
11
9
  gem 'rake'
@@ -24,7 +22,12 @@ if RUBY_VERSION >= '2.2.0'
24
22
  gem 'minitest'
25
23
  end
26
24
  if RUBY_VERSION >= '2.2.0'
27
- gem 'rubocop', '<= 0.58.2'
25
+ gem 'jaro_winkler', '>= 1.5.5'
26
+ gem 'rubocop', '> 0.56', '<= 0.58.2'
27
+ end
28
+ if RUBY_ENGINE == 'jruby'
29
+ # Workaround for https://github.com/jruby/jruby/issues/8488
30
+ gem 'jar-dependencies', '~> 0.4.1'
28
31
  end
29
32
  if ENV['MOCHA_GENERATE_DOCS']
30
33
  gem 'redcarpet'
data/MIT-LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006 Revieworld Ltd.
1
+ Copyright (c) 2006 James Mead
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
data/README.md CHANGED
@@ -1,13 +1,14 @@
1
- ## Mocha [![CircleCI status of freerange/mocha](https://circleci.com/gh/freerange/mocha.svg?style=shield&circle-token=bc1f6576c77da43ec58badde9273fa4eb1d7f53a)](https://app.circleci.com/pipelines/github/freerange/mocha) [![Gem Version](https://badge.fury.io/rb/mocha.svg)](http://badge.fury.io/rb/mocha)
1
+ ## Mocha [![CircleCI status of freerange/mocha](https://circleci.com/gh/freerange/mocha.svg?style=shield)](https://app.circleci.com/pipelines/github/freerange/mocha) [![Gem Version](https://badge.fury.io/rb/mocha.svg)](http://badge.fury.io/rb/mocha)
2
2
 
3
3
  ### Description
4
4
 
5
5
  * A Ruby library for [mocking](http://xunitpatterns.com/Mock%20Object.html) and [stubbing](http://xunitpatterns.com/Test%20Stub.html) - but deliberately not (yet) [faking](http://xunitpatterns.com/Fake%20Object.html) or [spying](http://xunitpatterns.com/Test%20Spy.html).
6
6
  * A unified, simple and readable syntax for both full & partial mocking.
7
- * Built-in support for MiniTest and Test::Unit.
7
+ * Built-in support for Minitest and Test::Unit.
8
8
  * Supported by many other test frameworks.
9
9
 
10
10
  ### Intended Usage
11
+
11
12
  Mocha is intended to be used in unit tests for the [Mock Object](http://xunitpatterns.com/Mock%20Object.html) or [Test Stub](http://xunitpatterns.com/Test%20Stub.html) types of [Test Double](http://xunitpatterns.com/Test%20Double.html), not the [Fake Object](http://xunitpatterns.com/Fake%20Object.html) or [Test Spy](http://xunitpatterns.com/Test%20Spy.html) types. Although it would be possible to extend Mocha to allow the implementation of fakes and spies, we have chosen to keep it focused on mocks and stubs.
12
13
 
13
14
  ### Installation
@@ -18,7 +19,7 @@ Install the latest version of the gem with the following command...
18
19
 
19
20
  $ gem install mocha
20
21
 
21
- Note: If you are intending to use Mocha with Test::Unit or MiniTest, you should only setup Mocha *after* loading the relevant test library...
22
+ Note: If you are intending to use Mocha with Test::Unit or Minitest, you should only setup Mocha *after* loading the relevant test library...
22
23
 
23
24
  ##### Test::Unit
24
25
 
@@ -29,12 +30,12 @@ require 'test/unit'
29
30
  require 'mocha/test_unit'
30
31
  ```
31
32
 
32
- ##### MiniTest
33
+ ##### Minitest
33
34
 
34
35
  ```ruby
35
36
  require 'rubygems'
36
37
  gem 'mocha'
37
- require 'minitest/unit'
38
+ require 'minitest/autorun'
38
39
  require 'mocha/minitest'
39
40
  ```
40
41
 
@@ -53,14 +54,14 @@ require 'test/unit'
53
54
  require 'mocha/test_unit'
54
55
  ```
55
56
 
56
- ##### MiniTest
57
+ ##### Minitest
57
58
 
58
59
  ```ruby
59
60
  # Gemfile
60
61
  gem 'mocha'
61
62
 
62
63
  # Elsewhere after Bundler has loaded gems e.g. after `require 'bundler/setup'`
63
- require 'minitest/unit'
64
+ require 'minitest/autorun'
64
65
  require 'mocha/minitest'
65
66
  ```
66
67
 
@@ -103,9 +104,9 @@ end
103
104
 
104
105
  If you're loading Mocha using Bundler within a Rails application, you should setup Mocha manually e.g. at the bottom of your `test_helper.rb`.
105
106
 
106
- ##### MiniTest
107
+ ##### Minitest
107
108
 
108
- Note that since Rails v4 (at least), `ActiveSupport::TestCase` has inherited from `Minitest::Test` or its earlier equivalents. Thus unless you are *explicitly* using Test::Unit, you are likely to be using MiniTest.
109
+ Note that since Rails v4 (at least), `ActiveSupport::TestCase` has inherited from `Minitest::Test` or its earlier equivalents. Thus unless you are *explicitly* using Test::Unit, you are likely to be using Minitest.
109
110
 
110
111
  ```ruby
111
112
  # Gemfile in Rails app
@@ -121,13 +122,7 @@ Follow the instructions for the relevant test framework in the [Bundler](#bundle
121
122
 
122
123
  #### Known Issues
123
124
 
124
- * In Mocha v1.10.0 an undocumented feature of `API#mock`, `API#stub` & `API#stub_everything` was changed. Previously when these methods were passed a single symbol, they returned a mock object that responded to the method identified by the symbol. Now Passing a single symbol is equivalent to passing a single string, i.e. it now defines the 'name' of the mock object.
125
- * In Mocha v1.2.0 there is a scenario where stubbing a class method originally defined in a module hangs the Ruby interpreter due to [a bug in Ruby v2.3.1](https://bugs.ruby-lang.org/issues/12832). See #272. This was fixed in Mocha v1.2.1.
126
- * Since v1.1.0 Mocha has used prepended modules internally for stubbing methods. There is [an obscure Ruby bug](https://bugs.ruby-lang.org/issues/12876) in many (but not all) versions of Ruby between v2.0 & v2.3 which under certain circumstances may cause your Ruby interpreter to hang. See the Ruby bug report for more details. The bug has been fixed in Ruby v2.3.3 & v2.4.0.
127
- * Stubbing an aliased class method, where the original method is defined in a module that's used to `extend` the class doesn't work in Ruby 1.8.x. See stub_method_defined_on_module_and_aliased_test.rb for an example of this behaviour.
128
- * 0.13.x versions cause a harmless, but annoying, deprecation warning when used with Rails 3.2.0-3.2.12, 3.1.0-3.1.10 & 3.0.0-3.0.19.
129
- * 0.11.x versions don't work with Rails 3.2.13 (`TypeError: superclass mismatch for class ExpectationError`). See #115.
130
- * Versions 0.10.2, 0.10.3 & 0.11.0 of the Mocha gem were broken. Please do not use these versions.
125
+ * Prior to v1.15.0 (when support for Ruby v1.8 was dropped), stubbing an aliased class method where the original method is defined in a module that's used to `extend` the class doesn't work in Ruby v1.8. See `test/acceptance/stub_method_defined_on_module_and_aliased_test.rb` for an example of this behaviour.
131
126
 
132
127
  ### Usage
133
128
 
@@ -151,7 +146,7 @@ class MiscExampleTest < Test::Unit::TestCase
151
146
  end
152
147
 
153
148
  def test_stubbing_instance_methods_on_real_objects
154
- prices = [stub(:pence => 1000), stub(:pence => 2000)]
149
+ prices = [stub(pence: 1000), stub(pence: 2000)]
155
150
  product = Product.new
156
151
  product.stubs(:prices).returns(prices)
157
152
  assert_equal [1000, 2000], product.prices.collect {|p| p.pence}
@@ -170,7 +165,7 @@ class MiscExampleTest < Test::Unit::TestCase
170
165
  end
171
166
 
172
167
  def test_shortcuts
173
- object = stub(:method1 => :result1, :method2 => :result2)
168
+ object = stub(method1: :result1, method2: :result2)
174
169
  assert_equal :result1, object.method1
175
170
  assert_equal :result2, object.method2
176
171
  end
@@ -282,7 +277,7 @@ Maybe, but probably not. Partial mocking changes the state of objects in the `Ob
282
277
 
283
278
  Stubs and expectations are basically the same thing. A stub is just an expectation of zero or more invocations. The `Expectation#stubs` method is syntactic sugar to make the intent of the test more explicit.
284
279
 
285
- When a method is invoked on a mock object, the mock object searches through its expectations from newest to oldest to find one that matches the invocation. After the invocation, the matching expectation might stop matching further invocations.
280
+ When a method is invoked on a mock object, the mock object searches through its expectations from newest to oldest to find one that matches the invocation. After the invocation, the matching expectation might stop matching further invocations. If the expectation that matches the invocation has a cardinality of "never", then an unexpected invocation error is reported.
286
281
 
287
282
  See the [documentation](https://mocha.jamesmead.org/Mocha/Mock.html) for `Mocha::Mock` for further details.
288
283
 
@@ -302,6 +297,12 @@ See the [documentation](https://mocha.jamesmead.org/Mocha/Configuration.html) fo
302
297
  Only the following values are currently recognized and have an effect:
303
298
  * `debug`: Enables a debug mode which will output backtraces for each deprecation warning. This is useful for finding where in the test suite the deprecated calls are.
304
299
 
300
+ ### Semantic versioning
301
+
302
+ * Every effort is made to comply with [semantic versioning](https://semver.org/).
303
+ * However, this only applies to the behaviour documented in the public API.
304
+ * The documented public API does *not* include the content or format of messsages displayed to the user, e.g. assertion failure messages.
305
+
305
306
  ### Useful Links
306
307
 
307
308
  * [Official Documentation](https://mocha.jamesmead.org)
@@ -325,14 +326,12 @@ See this [list of contributors](https://github.com/freerange/mocha/graphs/contri
325
326
  * Commit & push to GitHub
326
327
  * Check CircleCI build is passing - https://app.circleci.com/pipelines/github/freerange/mocha
327
328
 
328
- * Sign in to Google Analytics - https://analytics.google.com/analytics/web/
329
- * Find the web property ID for floehopper (625523) > Mocha Documentation (UA-625523-7)
330
329
  * Generate documentation:
331
330
 
332
331
  ```bash
333
332
  $ MOCHA_GENERATE_DOCS=true bundle install
334
333
 
335
- $ MOCHA_GENERATE_DOCS=true GOOGLE_ANALYTICS_WEB_PROPERTY_ID=UA-625523-7 rake generate_docs
334
+ $ MOCHA_GENERATE_DOCS=true rake generate_docs
336
335
  ```
337
336
  * Commit documentation & push to GitHub
338
337
  * Sign in to rubygems.org and find API key - https://rubygems.org/profile/edit
@@ -358,6 +357,6 @@ Mocha was initially harvested from projects at [Reevoo](http://www.reevoo.com/).
358
357
 
359
358
  ### License
360
359
 
361
- &copy; Copyright Revieworld Ltd. 2006
360
+ &copy; Copyright James Mead 2006
362
361
 
363
- 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).
362
+ You may use, copy and redistribute this library under the same terms as [Ruby itself](https://www.ruby-lang.org/en/about/license.txt) or under the [MIT license](https://mit-license.org/).
data/RELEASE.md CHANGED
@@ -1,5 +1,251 @@
1
1
  # Release Notes
2
2
 
3
+ ## 2.7.1
4
+
5
+ ### External changes
6
+
7
+ * Deprecate `Configuration#stubbing_method_on_nil=` (#694)
8
+ * Indicate when parameter matcher logic is defined by block passed to `Expectation#with` (#698, b30e4434)
9
+ * Improve documentation for `Expectation#with`, especially when it is passed a block (#698, #682, #606 & #681)
10
+
11
+ ## 2.7.0
12
+
13
+ ### External changes
14
+
15
+ * Fail fast if invocation matches never expectation (#679, #678, #490, #131 & #44) - thanks to @ducmtran & @davidstosik for reporting
16
+
17
+ ### Internal changes
18
+
19
+ * Workaround for JRuby jar-dependencies issue (#690)
20
+ * Ruby v3.4 stacktrace uses single-quote vs backtick (#688 & #689) - thanks to Vít Ondruch
21
+
22
+ **WARNING: This release fixes a very _old_ bug**
23
+ * The bug relates to the use of `Expectation#never` in combination with other expectations on the same method.
24
+ * Please ensure you fix the relevant deprecation warnings when running against v2.6.1 *before* upgrading to v2.7.0.
25
+ * Previously, the following test would have passed, but now it will fail with an unexpected invocation error on the `foo.bar` line.
26
+
27
+ foo = mock('foo')
28
+ foo.stubs(:bar)
29
+ foo.expects(:bar).never
30
+ foo.bar
31
+
32
+ ## 2.6.1
33
+
34
+ ### External changes
35
+
36
+ * Fix logic for displaying deprecation warning for expectation with never cardinality (#686) - thanks to @davidstosik for reporting
37
+
38
+ ## 2.6.0
39
+
40
+ ### External changes
41
+
42
+ * Expectation with never cardinality should display deprecation warning (#681) - thanks to @ducmtran for reporting and testing
43
+
44
+ **WARNING: This release results in some incorrect deprecation warnings:**
45
+ * The logic for displaying the deprecation warnings is fixed in v2.6.1 (#686).
46
+
47
+ ### Internal changes
48
+
49
+ * Simplify backtrace related assertions (#680)
50
+ * Remove unused `ExpectationList#match_but_out_of_order` (f2fa9919)
51
+
52
+ ## 2.5.0
53
+
54
+ ### External changes
55
+
56
+ * Add metadata to gem specification, including `changelog_uri` (#608, eb1b8ea2) - thanks to @mattbrictson
57
+ * Fix warnings in Ruby v3.4 (#672, #669) - thanks to @radville for reporting
58
+ * Add warnings & notes about regressions, known issues, etc to release notes (#675, #676 & #677) - thanks to @davidstosik
59
+
60
+ ### Internal changes
61
+
62
+ * Fix `jaro_winkler` compilation errors on MacOS (5c7d14cb)
63
+ * Fix typos in `IncludesTest` test names (6fb5a5a6)
64
+ * Fix `rubocop` version constraint for Ruby > v2.2.0 (d5c6b98a)
65
+
66
+ ## 2.4.5
67
+
68
+ ### External changes
69
+
70
+ * Fix regression when stubbed method expects `Hash` but receives `ActionController::Parameters` object (#662, #664) - thanks to @evgeni for reporting and testing
71
+
72
+ ## 2.4.4
73
+
74
+ ### External changes
75
+
76
+ * Fix regression when method expecting `Hash` parameter or keyword arguments is invoked with no arguments (#662, #663) - thanks to @vlad-pisanov for reporting
77
+
78
+ **WARNING: This release includes a regression:**
79
+ * A `NoMethodError` was raised when a stubbed method was expecting a `Hash`, but was invoked with an instance of `ActionController::Parameters`. See #662 for the report and #664 for the fix which was released in v2.4.5.
80
+
81
+ ## 2.4.3
82
+
83
+ ### External changes
84
+
85
+ * Fix regression when matching `Hash` parameter or keyword arguments (#657, #660) - thanks to @josesei for reporting and testing
86
+
87
+ **WARNING: This release inadvertently introduced a couple of regressions:**
88
+ * A `NoMethodError` was raised when a stubbed method was expecting a `Hash`, but was invoked with no arguments, e.g. with `C.expects(:foo).with(bar: 42)` and invoking `C.expects(:foo)`. See #662 for the report and #663 for the fix which was released in v2.4.4.
89
+ * A `NoMethodError` was raised when a stubbed method was expecting a `Hash`, but was invoked with an instance of `ActionController::Parameters`. See #662 for the report and #664 for the fix which was released in v2.4.5.
90
+
91
+ ## 2.4.2
92
+
93
+ ### External changes
94
+
95
+ * Don't trust `Object#is_a?` in presence of mock objects (#656) - thanks to @casperisfine
96
+
97
+ **WARNING: This release includes a regression:**
98
+ * Keyword argument and top-level `Hash` matching became more relaxed than intended, e.g. `mock.expects(:method).with(key: "value")` accepted `mock.method(key: "value", key2: "value")` when it should not have done. See #657 & #675 for the reports and #660 for the fix which was released in v2.4.3.
99
+
100
+ ## 2.4.1
101
+
102
+ ### External changes
103
+
104
+ * Fix regression in matchers when used with keyword arguments (#654 & #655) - thanks to @ElvinEfendi for reporting
105
+
106
+ ### Internal changes
107
+
108
+ * Reduce duplication & consolidate `#to_matcher` method definitions (600ee2aa, e9de64e4, #655)
109
+ * Change `#to_matcher` method to use keyword arguments (3b60b7df, #655)
110
+
111
+ **WARNING: This release includes a regression:**
112
+ * Keyword argument and top-level `Hash` matching became more relaxed than intended, e.g. `mock.expects(:method).with(key: "value")` accepted `mock.method(key: "value", key2: "value")` when it should not have done. See #657 & #675 for the reports and #660 for the fix which was released in v2.4.3.
113
+
114
+ ## 2.4.0
115
+
116
+ ### External changes
117
+
118
+ * Improve rendering of keyword arguments (#652) - thanks to @casperisfine
119
+
120
+ ### Internal changes
121
+
122
+ **WARNING: This release includes a couple of regressions:**
123
+ * Nested parameter matching for keyword arguments became more relaxed than intended, e.g. `mock.expects(:method).with(has_entry(:k1, k2: 'v2'))` accepted `mock.method(k1: { k2: 'v2', k3: 'v3' })` when it should not have done. See #654 for the report and #655 for the fix which was released in v2.4.1.
124
+ * Keyword argument and top-level `Hash` matching became more relaxed than intended, e.g. `mock.expects(:method).with(key: "value")` accepted `mock.method(key: "value", key2: "value")` when it should not have done. See #657 & #675 for the reports and #660 for the fix which was released in v2.4.3.
125
+
126
+ * Improvements to `#mocha_inspect` unit tests (#650)
127
+
128
+ ## 2.3.0
129
+
130
+ ### External changes
131
+
132
+ * Fix nested parameter matching for keyword arguments (f94e2504, #648) - thanks to @CodingAnarchy for reporting
133
+
134
+ **WARNING: This release inadvertently introduced a couple of regressions:**
135
+ * Nested parameter matching for keyword arguments became more relaxed than intended, e.g. `mock.expects(:method).with(has_entry(:k1, k2: 'v2'))` accepted `mock.method(k1: { k2: 'v2', k3: 'v3' })` when it should not have done. See #654 for the report and #655 for the fix which was released in v2.4.1.
136
+ * Keyword argument and top-level `Hash` matching became more relaxed than intended, e.g. `mock.expects(:method).with(key: "value")` accepted `mock.method(key: "value", key2: "value")` when it should not have done. See #657 & #675 for the reports and #660 for the fix which was released in v2.4.3.
137
+
138
+ ## 2.2.0
139
+
140
+ ### External changes
141
+
142
+ * Support multiple methods in `responds_with` matcher (f086b7e4, #578) - thanks to @vlad-pisanov for the suggestion
143
+ * Add block syntax for sequences (93fdffd, #61)
144
+ * Improve sequence failure message (0800c6ff, #60)
145
+ * Drop support for Ruby v2.0 (85848fb0, #642)
146
+ * Include the original test name in expired stub error messages (ca3ff8eb, #641, #642) - thanks to @casperisfine
147
+
148
+ * Avoid rubocop directive ending up in YARD docs (2a9ee81a)
149
+ * Update docs to fix those for `Mock#method_missing` (cee0bad6)
150
+ * Reinstate missing CNAME for GitHub Pages site (da67bb0d)
151
+ * Use Ruby v1.9 Hash syntax in docs (6de20726, #625)
152
+ * Add missing YARD tag for API#sequence name param (343c5979)
153
+ * Add missing YARD tag for API#states name param (f798df83)
154
+
155
+ ### Internal changes
156
+
157
+ * Tidy up Minitest vs MiniTest references (#626, #614, #615) - thanks to @zenspider & @Maimer for their help
158
+ * Add Ruby v3.3 to CI build matrix (ce31b544)
159
+
160
+ ## 2.1.0
161
+
162
+ ### External changes
163
+
164
+ * Fix compatibility with Minitest (#614) - thanks to @kyrofa & @manewitz for reporting and to @zenspider for his input
165
+
166
+ ### Internal changes
167
+
168
+ * Update URLs for links to Ruby & MIT licenses (d6470af4)
169
+
170
+ ## 2.0.4
171
+
172
+ ### Internal changes
173
+
174
+ * Update `README.md` (e8c21e1b)
175
+
176
+ ## 2.0.3
177
+
178
+ ### External changes
179
+
180
+ * Fix `BacktraceFilter` to handle special characters (e242033f, #592) - thanks to @casperisfine
181
+
182
+ ### Internal changes
183
+
184
+ * Add Ruby v3.1 to the CircleCI build (3e460489)
185
+ * DRY up `regexp_matches` test (ae9fed4a)
186
+ * Fix regexp_matches tests in Ruby v3.2 (26b106a5, #590)
187
+ * Use Ruby 1.9 hash syntax (8bc0ad2f, #598, #537) - thanks to @herwinw
188
+ * Simplify storage of `MOCHA_OPTIONS` (b70507a1, #600) - thanks to @herwinw
189
+ * Pin JRuby to v9.3.9.0 in CircleCI builds (b8e6d064, #591)
190
+ * Rubocop: enable Style/FormatStringToken cop (089a688e, #603) - thanks to @herwinw
191
+ * Remove Ruby version check from `RespondsLikeTest` (21583129)
192
+ * Add Ruby v3.2 to CircleCI build (f7e17636, #601)
193
+ * Use Ruby v2.6 vs v2.2 to run lint CI job (af40b7db)
194
+ * Pin yard version to v0.9.28 to avoid `ArgumentError` (12f1eef7)
195
+ * Revert "Pin JRuby to v9.3.9.0 in CircleCI builds" (4f5bb2f0, #591)
196
+ * Remove invalid CircleCI token from badge URL (7078e76a)
197
+ * Revert "Pin yard version to v0.9.28 to avoid ArgumentError" (7c6c10c5, #609)
198
+ * Remove Google Analytics tracking code (2279c49d, #612)
199
+ * Update `MIT-LICENSE.md` (48162b4e)
200
+ * Update `COPYING.md` (f3152376)
201
+
202
+ ## 2.0.2
203
+
204
+ ### External changes
205
+
206
+ * Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,ba4d619e)
207
+
208
+ ## 2.0.1
209
+
210
+ ### External changes
211
+
212
+ * Fix `LoadError` when using v2.0.0 with Ruby < v2.7 by moving declaration of runtime dependency on `ruby2_keywords` gem from `Gemfile` to `mocha.gemspec` - thanks to @mishina2228 for reporting (#581, #582, cdeb0356)
213
+
214
+ ## 2.0.0
215
+
216
+ ### External changes
217
+
218
+ * Remove support for Ruby v1.9 - thanks to @wasabigeek (#552)
219
+ * Support strict keyword argument matching - see docs for `Expectation#with` & `Configuration#strict_keyword_argument_matching=` - thanks to @wasabigeek (#446,#535,#544,#562)
220
+ * Deprecate `Hash` args that don't strictly match (#563,981c31be)
221
+ * Drop support for older versions of test-unit - gem versions of test-unit earlier than v2.5.1 and versions of test-unit
222
+ from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
223
+ * Drop support for older versions of minitest - versions of minitest earlier than v3.3.0 are no longer supported (#541,ca69dc9e)
224
+ * Remove deprecated `mocha/setup.rb` mechanism (642a0ff4)
225
+ * Add missing docs for `API#stub` parameter (257b4cb4)
226
+ * Remove optional reinstatement of v1.9 behaviour (#436,#438,#569,1473ee25)
227
+ * Remove deprecated methods in `Configuration` (#421,e7ff7528)
228
+ * Fail fast when mock receives invocations in another test (#440,#442,cb054d59)
229
+ * Improve docs re using matchers in `Expectation#with` (da7237cd)
230
+ * Expand `Expectation#with` docs re keyword arguments (fed6808d)
231
+ * Improve docs for `strict_keyword_argument_matching` (8d8f881d)
232
+ * Remove deprecated Rails plugin `init.rb` file (1c617175)
233
+ * Improve strict keyword argument matching deprecation warning by including the source location of the stub definition (77c0d4cc)
234
+ * Add README section re semantic versioning (00758246)
235
+
236
+ ### Internal changes
237
+
238
+ * Separate linting from tests in terms of Rake tasks & CircleCI jobs - thanks to @wasabigeek (#556)
239
+ * Remove tests specific to Ruby v1.8 behaviour (46fca7ac, 3b369e99)
240
+ * Multi-line rubocop disable in `Mock#method_missing` (af2194c4)
241
+ * Remove unused arg for `HashMethods#mocha_inspect` (4f59e27f)
242
+ * Improve test runner assertions - failure vs error (eec7200a)
243
+ * Improve test coverage of `PositionalOrKeywordHash` (c294fe70)
244
+ * More consistent Test::Unit & Minitest integration (27dd3817)
245
+ * Remove redundant `require` statements (d82218a8,fa17b114)
246
+ * Add missing `require` statement (73493761)
247
+ * Disable Style/Semicolon cop globally (8cd0b705)
248
+
3
249
  ## 1.16.1
4
250
 
5
251
  ### External changes
@@ -17,6 +263,12 @@
17
263
 
18
264
  * Remove redundant deprecation disabling in MockTest (dc8ca969)
19
265
 
266
+ ## 1.15.1
267
+
268
+ ### External changes
269
+
270
+ * Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,c586a08c)
271
+
20
272
  ## 1.15.0
21
273
 
22
274
  ### External changes
@@ -154,6 +406,9 @@
154
406
  * Add documentation for Cucumber integration (13ab797b)
155
407
  * Add documentation about an undocumented feature of `API#mock`, `API#stub` & `API#stub_everything` being changed (7ed2e4e7, d30c1717)
156
408
 
409
+ **WARNING: This release inadvertently changed some undocumented behaviour:**
410
+ * An undocumented feature of `API#mock`, `API#stub` & `API#stub_everything` was changed. Previously when these methods were passed a single symbol, they returned a mock object that responded to the method identified by the symbol. Now Passing a single symbol is equivalent to passing a single string, i.e. it now defines the 'name' of the mock object.
411
+
157
412
  ## 1.10.0.beta.1
158
413
 
159
414
  * Hide `ClassMethods#method_visibility` & `#method_exists?` methods to avoid clash with Rails (#428)
@@ -297,6 +552,9 @@
297
552
  * Fix typo in docs for equals - thanks to @alexcoco (#254)
298
553
  * Add known issue for Ruby v1.8 to README - thanks to @chrisroos (2c642096)
299
554
 
555
+ **WARNING: This release inadvertently introduced the possibility of causing the Ruby interpreter to hang:**
556
+ * There is a scenario where stubbing a class method originally defined in a module hangs the Ruby interpreter due to [a bug in Ruby v2.3.1](https://bugs.ruby-lang.org/issues/12832). See #272. This was fixed in Mocha v1.2.1.
557
+
300
558
  ## 1.1.0
301
559
 
302
560
  * Set visibility of any instance stub method.
@@ -305,6 +563,9 @@
305
563
  * Use GitHub convention for instructions on contributing to Mocha.
306
564
  * Fix typos in docs. Thanks to @10io
307
565
 
566
+ **WARNING: This release inadvertently introduced the possibility of causing the Ruby interpreter to hang:**
567
+ * From this release onwards, prepended modules have been used internally for stubbing methods. There is [an obscure Ruby bug](https://bugs.ruby-lang.org/issues/12876) in many (but not all) versions of Ruby between v2.0 & v2.3 which under certain circumstances may cause your Ruby interpreter to hang. See the Ruby bug report for more details. The bug has been fixed in Ruby v2.3.3 & v2.4.0.
568
+
308
569
  ## 1.0.0
309
570
 
310
571
  ### External changes
@@ -367,6 +628,9 @@ relevant patch version.
367
628
  * Adapt Mocha acceptance tests to cope with changes in output from latest (v4.6.2) of MiniTest.
368
629
  * Updates to README about Rails compatibility.
369
630
 
631
+ **NOTE: This release inadvertently caused deprecation warnings in some contexts:**
632
+ * When used with Rails v3.2.0-v3.2.12, v3.1.0-v3.1.10 & v3.0.0-v3.0.19.
633
+
370
634
  ## 0.13.2
371
635
  * Stubbing of methods re-declared with different visibilty. Fixes #109.
372
636
  * Add `Mock#responds_like_instance_of`. Fixes #119.
@@ -376,10 +640,16 @@ relevant patch version.
376
640
  * Add a Gem Badge to provide a link to Mocha on Rubygems.
377
641
  * Make documentation example consistent with other examples.
378
642
 
643
+ **NOTE: This release inadvertently caused deprecation warnings in some contexts:**
644
+ * When used with Rails v3.2.0-v3.2.12, v3.1.0-v3.1.10 & v3.0.0-v3.0.19.
645
+
379
646
  ## 0.13.1
380
647
  * Fix #97 - `Mocha::ParameterMatchers#has_entry` does not work with an Array as the entry's value. Thanks to @ngokli.
381
648
  * Allow deprecation `:debug` mode to be switched on from `MOCHA_OPTIONS` environment variable.
382
649
 
650
+ **NOTE: This release inadvertently caused deprecation warnings in some contexts:**
651
+ * When used with Rails v3.2.0-v3.2.12, v3.1.0-v3.1.10 & v3.0.0-v3.0.19.
652
+
383
653
  ## 0.13.0
384
654
  * 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.
385
655
  * 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.
@@ -392,6 +662,9 @@ relevant patch version.
392
662
  * Various improvements to automated testing of integration with test libraries.
393
663
  * Make deprecation warnings more prominent.
394
664
 
665
+ **NOTE: This release inadvertently caused deprecation warnings in some contexts:**
666
+ * When used with Rails v3.2.0-v3.2.12, v3.1.0-v3.1.10 & v3.0.0-v3.0.19.
667
+
395
668
  ## 0.12.7
396
669
  * Officially support minitest v4.1.0 (still monkey-patching).
397
670
 
@@ -428,15 +701,27 @@ relevant patch version.
428
701
  ## 0.11.4
429
702
  * Homepage has moved to http://gofreerange.com/mocha/docs.
430
703
 
704
+ **WARNING: This release inadvertently included a Rails compatibility issue:**
705
+ * `TypeError: superclass mismatch for class ExpectationError` raised when using Rails v3.2.13. See #115.
706
+
431
707
  ## 0.11.3
432
708
  * Fix for #78 i.e. alias Object#method as Object#_method, not Object#__method__ which already exists as another Ruby method.
433
709
 
710
+ **WARNING: This release inadvertently included a Rails compatibility issue:**
711
+ * `TypeError: superclass mismatch for class ExpectationError` raised when using Rails v3.2.13. See #115.
712
+
434
713
  ## 0.11.2
435
714
  * 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.
436
715
 
716
+ **WARNING: This release inadvertently included a Rails compatibility issue:**
717
+ * `TypeError: superclass mismatch for class ExpectationError` raised when using Rails v3.2.13. See #115.
718
+
437
719
  ## 0.11.1
438
720
  * In Ruby 1.8.7 methods accepting a block parameter were incorrectly restored without the block parameter after being stubbed. Fix for #76.
439
721
 
722
+ **WARNING: This release inadvertently included a Rails compatibility issue:**
723
+ * `TypeError: superclass mismatch for class ExpectationError` raised when using Rails v3.2.13. See #115.
724
+
440
725
  ## 0.11.0
441
726
  * 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.
442
727
  * Attempting to stub a method on a frozen object should fail fast. See #68.
@@ -449,6 +734,11 @@ relevant patch version.
449
734
  * Improve documentation for ObjectMethods.
450
735
  * Provide a way to run multiple tests within a single acceptance test method.
451
736
 
737
+ **WARNING: This release inadvertently included a significant bug - please do not use it!**
738
+
739
+ **WARNING: This release inadvertently introduced a Rails compatibility issue:**
740
+ * `TypeError: superclass mismatch for class ExpectationError` raised when using Rails v3.2.13. See #115.
741
+
452
742
  ## 0.10.5
453
743
  * 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.
454
744
  * 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.
@@ -467,9 +757,13 @@ Hash with wrong number of entries.
467
757
  ## 0.10.3
468
758
  * 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.
469
759
 
760
+ **WARNING: This release inadvertently included a significant bug - please do not use it!**
761
+
470
762
  ## 0.10.2
471
763
  * Merge pull request #53. Unstubbing a method should not remove expectations for other stubbed methods. Fixes #52. Thanks to saikat.
472
764
 
765
+ **WARNING: This release inadvertently included a significant bug - please do not use it!**
766
+
473
767
  ## 0.10.1
474
768
  * Merge pull request #51. Use Gem::Requirement & Gem::Version for version comparison. Fixes issue #50. Thanks to meineerde.
475
769
  * Fixed typo in rdoc for Mocha::ObjectMethods.