mocha 2.4.5 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/README.md +1 -7
- data/RELEASE.md +77 -0
- data/lib/mocha/mockery.rb +5 -5
- data/lib/mocha/ruby_version.rb +1 -0
- data/lib/mocha/version.rb +1 -1
- data/mocha.gemspec +8 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6e1cd848b633850f0774eb601a31b7c574658eaa1be031443a235410e73ef83
|
4
|
+
data.tar.gz: 67f6af8a50e7f0cbc294367eb04696e6f40a04d44c432b17cb9c534b006a6a65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5508f0dce73db625638223279e9a51215fabbbaed47bd911c1a8359c81efad57aa32f7c3b672ad6b900e1848a4a31335102c3113319855f08a91997d85466264
|
7
|
+
data.tar.gz: 37c2d7c0b5eaf2650a47a83b431e2c437f30f9b6bc0b902133b4d238e11b15daa3c005c738098bf326e3bb0a38ef82376923f8ef0e6f892e8a180c6b04038729
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -121,13 +121,7 @@ Follow the instructions for the relevant test framework in the [Bundler](#bundle
|
|
121
121
|
|
122
122
|
#### Known Issues
|
123
123
|
|
124
|
-
*
|
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.
|
124
|
+
* 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
125
|
|
132
126
|
### Usage
|
133
127
|
|
data/RELEASE.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Release Notes
|
2
2
|
|
3
|
+
## 2.5.0
|
4
|
+
|
5
|
+
### External changes
|
6
|
+
|
7
|
+
* Add metadata to gem specification, including `changelog_uri` (#608, eb1b8ea2) - thanks to @mattbrictson
|
8
|
+
* Fix warnings in Ruby v3.4 (#672, #669) - thanks to @radville for reporting
|
9
|
+
* Add warnings & notes about regressions, known issues, etc to release notes (#675, #676 & #677) - thanks to @davidstosik
|
10
|
+
|
11
|
+
### Internal changes
|
12
|
+
|
13
|
+
* Fix `jaro_winkler` compilation errors on MacOS (5c7d14cb)
|
14
|
+
* Fix typos in `IncludesTest` test names (6fb5a5a6)
|
15
|
+
* Fix `rubocop` version constraint for Ruby > v2.2.0 (d5c6b98a)
|
16
|
+
|
3
17
|
## 2.4.5
|
4
18
|
|
5
19
|
### External changes
|
@@ -12,18 +26,28 @@
|
|
12
26
|
|
13
27
|
* Fix regression when method expecting `Hash` parameter or keyword arguments is invoked with no arguments (#662, #663) - thanks to @vlad-pisanov for reporting
|
14
28
|
|
29
|
+
**WARNING: This release includes a regression:**
|
30
|
+
* 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.
|
31
|
+
|
15
32
|
## 2.4.3
|
16
33
|
|
17
34
|
### External changes
|
18
35
|
|
19
36
|
* Fix regression when matching `Hash` parameter or keyword arguments (#657, #660) - thanks to @josesei for reporting and testing
|
20
37
|
|
38
|
+
**WARNING: This release inadvertently introduced a couple of regressions:**
|
39
|
+
* 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.
|
40
|
+
* 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.
|
41
|
+
|
21
42
|
## 2.4.2
|
22
43
|
|
23
44
|
### External changes
|
24
45
|
|
25
46
|
* Don't trust `Object#is_a?` in presence of mock objects (#656) - thanks to @casperisfine
|
26
47
|
|
48
|
+
**WARNING: This release includes a regression:**
|
49
|
+
* 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.
|
50
|
+
|
27
51
|
## 2.4.1
|
28
52
|
|
29
53
|
### External changes
|
@@ -35,6 +59,9 @@
|
|
35
59
|
* Reduce duplication & consolidate `#to_matcher` method definitions (600ee2aa, e9de64e4, #655)
|
36
60
|
* Change `#to_matcher` method to use keyword arguments (3b60b7df, #655)
|
37
61
|
|
62
|
+
**WARNING: This release includes a regression:**
|
63
|
+
* 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.
|
64
|
+
|
38
65
|
## 2.4.0
|
39
66
|
|
40
67
|
### External changes
|
@@ -43,6 +70,10 @@
|
|
43
70
|
|
44
71
|
### Internal changes
|
45
72
|
|
73
|
+
**WARNING: This release includes a couple of regressions:**
|
74
|
+
* 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.
|
75
|
+
* 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.
|
76
|
+
|
46
77
|
* Improvements to `#mocha_inspect` unit tests (#650)
|
47
78
|
|
48
79
|
## 2.3.0
|
@@ -51,6 +82,10 @@
|
|
51
82
|
|
52
83
|
* Fix nested parameter matching for keyword arguments (f94e2504, #648) - thanks to @CodingAnarchy for reporting
|
53
84
|
|
85
|
+
**WARNING: This release inadvertently introduced a couple of regressions:**
|
86
|
+
* 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.
|
87
|
+
* 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.
|
88
|
+
|
54
89
|
## 2.2.0
|
55
90
|
|
56
91
|
### External changes
|
@@ -322,6 +357,9 @@ from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
|
|
322
357
|
* Add documentation for Cucumber integration (13ab797b)
|
323
358
|
* Add documentation about an undocumented feature of `API#mock`, `API#stub` & `API#stub_everything` being changed (7ed2e4e7, d30c1717)
|
324
359
|
|
360
|
+
**WARNING: This release inadvertently changed some undocumented behaviour:**
|
361
|
+
* 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.
|
362
|
+
|
325
363
|
## 1.10.0.beta.1
|
326
364
|
|
327
365
|
* Hide `ClassMethods#method_visibility` & `#method_exists?` methods to avoid clash with Rails (#428)
|
@@ -465,6 +503,9 @@ from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
|
|
465
503
|
* Fix typo in docs for equals - thanks to @alexcoco (#254)
|
466
504
|
* Add known issue for Ruby v1.8 to README - thanks to @chrisroos (2c642096)
|
467
505
|
|
506
|
+
**WARNING: This release inadvertently introduced the possibility of causing the Ruby interpreter to hang:**
|
507
|
+
* 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.
|
508
|
+
|
468
509
|
## 1.1.0
|
469
510
|
|
470
511
|
* Set visibility of any instance stub method.
|
@@ -473,6 +514,9 @@ from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
|
|
473
514
|
* Use GitHub convention for instructions on contributing to Mocha.
|
474
515
|
* Fix typos in docs. Thanks to @10io
|
475
516
|
|
517
|
+
**WARNING: This release inadvertently introduced the possibility of causing the Ruby interpreter to hang:**
|
518
|
+
* 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.
|
519
|
+
|
476
520
|
## 1.0.0
|
477
521
|
|
478
522
|
### External changes
|
@@ -535,6 +579,9 @@ relevant patch version.
|
|
535
579
|
* Adapt Mocha acceptance tests to cope with changes in output from latest (v4.6.2) of MiniTest.
|
536
580
|
* Updates to README about Rails compatibility.
|
537
581
|
|
582
|
+
**NOTE: This release inadvertently caused deprecation warnings in some contexts:**
|
583
|
+
* When used with Rails v3.2.0-v3.2.12, v3.1.0-v3.1.10 & v3.0.0-v3.0.19.
|
584
|
+
|
538
585
|
## 0.13.2
|
539
586
|
* Stubbing of methods re-declared with different visibilty. Fixes #109.
|
540
587
|
* Add `Mock#responds_like_instance_of`. Fixes #119.
|
@@ -544,10 +591,16 @@ relevant patch version.
|
|
544
591
|
* Add a Gem Badge to provide a link to Mocha on Rubygems.
|
545
592
|
* Make documentation example consistent with other examples.
|
546
593
|
|
594
|
+
**NOTE: This release inadvertently caused deprecation warnings in some contexts:**
|
595
|
+
* When used with Rails v3.2.0-v3.2.12, v3.1.0-v3.1.10 & v3.0.0-v3.0.19.
|
596
|
+
|
547
597
|
## 0.13.1
|
548
598
|
* Fix #97 - `Mocha::ParameterMatchers#has_entry` does not work with an Array as the entry's value. Thanks to @ngokli.
|
549
599
|
* Allow deprecation `:debug` mode to be switched on from `MOCHA_OPTIONS` environment variable.
|
550
600
|
|
601
|
+
**NOTE: This release inadvertently caused deprecation warnings in some contexts:**
|
602
|
+
* When used with Rails v3.2.0-v3.2.12, v3.1.0-v3.1.10 & v3.0.0-v3.0.19.
|
603
|
+
|
551
604
|
## 0.13.0
|
552
605
|
* 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.
|
553
606
|
* 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.
|
@@ -560,6 +613,9 @@ relevant patch version.
|
|
560
613
|
* Various improvements to automated testing of integration with test libraries.
|
561
614
|
* Make deprecation warnings more prominent.
|
562
615
|
|
616
|
+
**NOTE: This release inadvertently caused deprecation warnings in some contexts:**
|
617
|
+
* When used with Rails v3.2.0-v3.2.12, v3.1.0-v3.1.10 & v3.0.0-v3.0.19.
|
618
|
+
|
563
619
|
## 0.12.7
|
564
620
|
* Officially support minitest v4.1.0 (still monkey-patching).
|
565
621
|
|
@@ -596,15 +652,27 @@ relevant patch version.
|
|
596
652
|
## 0.11.4
|
597
653
|
* Homepage has moved to http://gofreerange.com/mocha/docs.
|
598
654
|
|
655
|
+
**WARNING: This release inadvertently included a Rails compatibility issue:**
|
656
|
+
* `TypeError: superclass mismatch for class ExpectationError` raised when using Rails v3.2.13. See #115.
|
657
|
+
|
599
658
|
## 0.11.3
|
600
659
|
* Fix for #78 i.e. alias Object#method as Object#_method, not Object#__method__ which already exists as another Ruby method.
|
601
660
|
|
661
|
+
**WARNING: This release inadvertently included a Rails compatibility issue:**
|
662
|
+
* `TypeError: superclass mismatch for class ExpectationError` raised when using Rails v3.2.13. See #115.
|
663
|
+
|
602
664
|
## 0.11.2
|
603
665
|
* 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.
|
604
666
|
|
667
|
+
**WARNING: This release inadvertently included a Rails compatibility issue:**
|
668
|
+
* `TypeError: superclass mismatch for class ExpectationError` raised when using Rails v3.2.13. See #115.
|
669
|
+
|
605
670
|
## 0.11.1
|
606
671
|
* In Ruby 1.8.7 methods accepting a block parameter were incorrectly restored without the block parameter after being stubbed. Fix for #76.
|
607
672
|
|
673
|
+
**WARNING: This release inadvertently included a Rails compatibility issue:**
|
674
|
+
* `TypeError: superclass mismatch for class ExpectationError` raised when using Rails v3.2.13. See #115.
|
675
|
+
|
608
676
|
## 0.11.0
|
609
677
|
* 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.
|
610
678
|
* Attempting to stub a method on a frozen object should fail fast. See #68.
|
@@ -617,6 +685,11 @@ relevant patch version.
|
|
617
685
|
* Improve documentation for ObjectMethods.
|
618
686
|
* Provide a way to run multiple tests within a single acceptance test method.
|
619
687
|
|
688
|
+
**WARNING: This release inadvertently included a significant bug - please do not use it!**
|
689
|
+
|
690
|
+
**WARNING: This release inadvertently introduced a Rails compatibility issue:**
|
691
|
+
* `TypeError: superclass mismatch for class ExpectationError` raised when using Rails v3.2.13. See #115.
|
692
|
+
|
620
693
|
## 0.10.5
|
621
694
|
* 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.
|
622
695
|
* 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.
|
@@ -635,9 +708,13 @@ Hash with wrong number of entries.
|
|
635
708
|
## 0.10.3
|
636
709
|
* 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.
|
637
710
|
|
711
|
+
**WARNING: This release inadvertently included a significant bug - please do not use it!**
|
712
|
+
|
638
713
|
## 0.10.2
|
639
714
|
* Merge pull request #53. Unstubbing a method should not remove expectations for other stubbed methods. Fixes #52. Thanks to saikat.
|
640
715
|
|
716
|
+
**WARNING: This release inadvertently included a significant bug - please do not use it!**
|
717
|
+
|
641
718
|
## 0.10.1
|
642
719
|
* Merge pull request #51. Use Gem::Requirement & Gem::Version for version comparison. Fixes issue #50. Thanks to meineerde.
|
643
720
|
* Fixed typo in rdoc for Mocha::ObjectMethods.
|
data/lib/mocha/mockery.rb
CHANGED
@@ -114,11 +114,11 @@ module Mocha
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def mocha_inspect
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
117
|
+
lines = []
|
118
|
+
lines << "unsatisfied expectations:\n- #{unsatisfied_expectations.map(&:mocha_inspect).join("\n- ")}\n" if unsatisfied_expectations.any?
|
119
|
+
lines << "satisfied expectations:\n- #{satisfied_expectations.map(&:mocha_inspect).join("\n- ")}\n" if satisfied_expectations.any?
|
120
|
+
lines << "states:\n- #{state_machines.map(&:mocha_inspect).join("\n- ")}\n" if state_machines.any?
|
121
|
+
lines.join
|
122
122
|
end
|
123
123
|
|
124
124
|
def on_stubbing(object, method)
|
data/lib/mocha/ruby_version.rb
CHANGED
data/lib/mocha/version.rb
CHANGED
data/mocha.gemspec
CHANGED
@@ -21,6 +21,14 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.homepage = 'https://mocha.jamesmead.org'
|
22
22
|
s.require_paths = ['lib']
|
23
23
|
s.summary = 'Mocking and stubbing library'
|
24
|
+
s.metadata = {
|
25
|
+
'bug_tracker_uri' => 'https://github.com/freerange/mocha/issues',
|
26
|
+
'changelog_uri' => 'https://github.com/freerange/mocha/blob/main/RELEASE.md',
|
27
|
+
'documentation_uri' => 'https://mocha.jamesmead.org/',
|
28
|
+
'funding_uri' => 'https://github.com/sponsors/floehopper',
|
29
|
+
'homepage_uri' => s.homepage,
|
30
|
+
'source_code_uri' => 'https://github.com/freerange/mocha'
|
31
|
+
}
|
24
32
|
|
25
33
|
s.add_runtime_dependency 'ruby2_keywords', '>= 0.0.5'
|
26
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mocha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Mead
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby2_keywords
|
@@ -132,7 +132,13 @@ homepage: https://mocha.jamesmead.org
|
|
132
132
|
licenses:
|
133
133
|
- MIT
|
134
134
|
- BSD-2-Clause
|
135
|
-
metadata:
|
135
|
+
metadata:
|
136
|
+
bug_tracker_uri: https://github.com/freerange/mocha/issues
|
137
|
+
changelog_uri: https://github.com/freerange/mocha/blob/main/RELEASE.md
|
138
|
+
documentation_uri: https://mocha.jamesmead.org/
|
139
|
+
funding_uri: https://github.com/sponsors/floehopper
|
140
|
+
homepage_uri: https://mocha.jamesmead.org
|
141
|
+
source_code_uri: https://github.com/freerange/mocha
|
136
142
|
post_install_message:
|
137
143
|
rdoc_options: []
|
138
144
|
require_paths:
|