mocha 2.4.4 → 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 +83 -0
- data/lib/mocha/mockery.rb +5 -5
- data/lib/mocha/parameter_matchers/has_entries.rb +2 -1
- 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,23 +1,53 @@
|
|
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
|
+
|
17
|
+
## 2.4.5
|
18
|
+
|
19
|
+
### External changes
|
20
|
+
|
21
|
+
* Fix regression when stubbed method expects `Hash` but receives `ActionController::Parameters` object (#662, #664) - thanks to @evgeni for reporting and testing
|
22
|
+
|
3
23
|
## 2.4.4
|
4
24
|
|
5
25
|
### External changes
|
6
26
|
|
7
27
|
* Fix regression when method expecting `Hash` parameter or keyword arguments is invoked with no arguments (#662, #663) - thanks to @vlad-pisanov for reporting
|
8
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
|
+
|
9
32
|
## 2.4.3
|
10
33
|
|
11
34
|
### External changes
|
12
35
|
|
13
36
|
* Fix regression when matching `Hash` parameter or keyword arguments (#657, #660) - thanks to @josesei for reporting and testing
|
14
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
|
+
|
15
42
|
## 2.4.2
|
16
43
|
|
17
44
|
### External changes
|
18
45
|
|
19
46
|
* Don't trust `Object#is_a?` in presence of mock objects (#656) - thanks to @casperisfine
|
20
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
|
+
|
21
51
|
## 2.4.1
|
22
52
|
|
23
53
|
### External changes
|
@@ -29,6 +59,9 @@
|
|
29
59
|
* Reduce duplication & consolidate `#to_matcher` method definitions (600ee2aa, e9de64e4, #655)
|
30
60
|
* Change `#to_matcher` method to use keyword arguments (3b60b7df, #655)
|
31
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
|
+
|
32
65
|
## 2.4.0
|
33
66
|
|
34
67
|
### External changes
|
@@ -37,6 +70,10 @@
|
|
37
70
|
|
38
71
|
### Internal changes
|
39
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
|
+
|
40
77
|
* Improvements to `#mocha_inspect` unit tests (#650)
|
41
78
|
|
42
79
|
## 2.3.0
|
@@ -45,6 +82,10 @@
|
|
45
82
|
|
46
83
|
* Fix nested parameter matching for keyword arguments (f94e2504, #648) - thanks to @CodingAnarchy for reporting
|
47
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
|
+
|
48
89
|
## 2.2.0
|
49
90
|
|
50
91
|
### External changes
|
@@ -316,6 +357,9 @@ from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
|
|
316
357
|
* Add documentation for Cucumber integration (13ab797b)
|
317
358
|
* Add documentation about an undocumented feature of `API#mock`, `API#stub` & `API#stub_everything` being changed (7ed2e4e7, d30c1717)
|
318
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
|
+
|
319
363
|
## 1.10.0.beta.1
|
320
364
|
|
321
365
|
* Hide `ClassMethods#method_visibility` & `#method_exists?` methods to avoid clash with Rails (#428)
|
@@ -459,6 +503,9 @@ from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
|
|
459
503
|
* Fix typo in docs for equals - thanks to @alexcoco (#254)
|
460
504
|
* Add known issue for Ruby v1.8 to README - thanks to @chrisroos (2c642096)
|
461
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
|
+
|
462
509
|
## 1.1.0
|
463
510
|
|
464
511
|
* Set visibility of any instance stub method.
|
@@ -467,6 +514,9 @@ from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
|
|
467
514
|
* Use GitHub convention for instructions on contributing to Mocha.
|
468
515
|
* Fix typos in docs. Thanks to @10io
|
469
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
|
+
|
470
520
|
## 1.0.0
|
471
521
|
|
472
522
|
### External changes
|
@@ -529,6 +579,9 @@ relevant patch version.
|
|
529
579
|
* Adapt Mocha acceptance tests to cope with changes in output from latest (v4.6.2) of MiniTest.
|
530
580
|
* Updates to README about Rails compatibility.
|
531
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
|
+
|
532
585
|
## 0.13.2
|
533
586
|
* Stubbing of methods re-declared with different visibilty. Fixes #109.
|
534
587
|
* Add `Mock#responds_like_instance_of`. Fixes #119.
|
@@ -538,10 +591,16 @@ relevant patch version.
|
|
538
591
|
* Add a Gem Badge to provide a link to Mocha on Rubygems.
|
539
592
|
* Make documentation example consistent with other examples.
|
540
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
|
+
|
541
597
|
## 0.13.1
|
542
598
|
* Fix #97 - `Mocha::ParameterMatchers#has_entry` does not work with an Array as the entry's value. Thanks to @ngokli.
|
543
599
|
* Allow deprecation `:debug` mode to be switched on from `MOCHA_OPTIONS` environment variable.
|
544
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
|
+
|
545
604
|
## 0.13.0
|
546
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.
|
547
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.
|
@@ -554,6 +613,9 @@ relevant patch version.
|
|
554
613
|
* Various improvements to automated testing of integration with test libraries.
|
555
614
|
* Make deprecation warnings more prominent.
|
556
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
|
+
|
557
619
|
## 0.12.7
|
558
620
|
* Officially support minitest v4.1.0 (still monkey-patching).
|
559
621
|
|
@@ -590,15 +652,27 @@ relevant patch version.
|
|
590
652
|
## 0.11.4
|
591
653
|
* Homepage has moved to http://gofreerange.com/mocha/docs.
|
592
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
|
+
|
593
658
|
## 0.11.3
|
594
659
|
* Fix for #78 i.e. alias Object#method as Object#_method, not Object#__method__ which already exists as another Ruby method.
|
595
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
|
+
|
596
664
|
## 0.11.2
|
597
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.
|
598
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
|
+
|
599
670
|
## 0.11.1
|
600
671
|
* In Ruby 1.8.7 methods accepting a block parameter were incorrectly restored without the block parameter after being stubbed. Fix for #76.
|
601
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
|
+
|
602
676
|
## 0.11.0
|
603
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.
|
604
678
|
* Attempting to stub a method on a frozen object should fail fast. See #68.
|
@@ -611,6 +685,11 @@ relevant patch version.
|
|
611
685
|
* Improve documentation for ObjectMethods.
|
612
686
|
* Provide a way to run multiple tests within a single acceptance test method.
|
613
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
|
+
|
614
693
|
## 0.10.5
|
615
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.
|
616
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.
|
@@ -629,9 +708,13 @@ Hash with wrong number of entries.
|
|
629
708
|
## 0.10.3
|
630
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.
|
631
710
|
|
711
|
+
**WARNING: This release inadvertently included a significant bug - please do not use it!**
|
712
|
+
|
632
713
|
## 0.10.2
|
633
714
|
* Merge pull request #53. Unstubbing a method should not remove expectations for other stubbed methods. Fixes #52. Thanks to saikat.
|
634
715
|
|
716
|
+
**WARNING: This release inadvertently included a significant bug - please do not use it!**
|
717
|
+
|
635
718
|
## 0.10.1
|
636
719
|
* Merge pull request #51. Use Gem::Requirement & Gem::Version for version comparison. Fixes issue #50. Thanks to meineerde.
|
637
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)
|
@@ -39,7 +39,8 @@ module Mocha
|
|
39
39
|
def matches?(available_parameters)
|
40
40
|
parameter = available_parameters.shift
|
41
41
|
return false unless parameter
|
42
|
-
return false
|
42
|
+
return false unless parameter.respond_to?(:keys)
|
43
|
+
return false if @exact && @entries.length != parameter.keys.length
|
43
44
|
|
44
45
|
has_entry_matchers = @entries.map { |key, value| HasEntry.new(key, value) }
|
45
46
|
AllOf.new(*has_entry_matchers).matches?([parameter])
|
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:
|