mocha 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/RELEASE.md +11 -0
- data/lib/mocha/cardinality.rb +4 -0
- data/lib/mocha/expectation.rb +5 -0
- data/lib/mocha/expectation_list.rb +4 -6
- data/lib/mocha/mock.rb +23 -3
- data/lib/mocha/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a2fb97d6eb77787f83c9199c83fcadd3605a07ec431a5e3d47a0d2ee6ff2c67
|
4
|
+
data.tar.gz: 42815979d195d003a14b42f36c4818fa6b1ca59d498e5ca3b743338a6dc13af8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b3494f44f9b603513afa227fd58f499275155695ae2c5e6759f11a0288d4f0fc706d2be90c01e12b8166caf328a8caf543303671310f91a4e3f28b130319973
|
7
|
+
data.tar.gz: d8b24445529930e616433246b41e43c78f034842967dff64df9c026be1dab5b5f3b671115d984608166caae6e7a73d253dc8e12bcca8b60514aefbd0520b9c76
|
data/RELEASE.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Release Notes
|
2
2
|
|
3
|
+
## 2.6.0
|
4
|
+
|
5
|
+
### External changes
|
6
|
+
|
7
|
+
* Expectation with never cardinality should display deprecation warning (#681) - thanks to @ducmtran for reporting and testing
|
8
|
+
|
9
|
+
### Internal changes
|
10
|
+
|
11
|
+
* Simplify backtrace related assertions (#680)
|
12
|
+
* Remove unused `ExpectationList#match_but_out_of_order` (f2fa9919)
|
13
|
+
|
3
14
|
## 2.5.0
|
4
15
|
|
5
16
|
### External changes
|
data/lib/mocha/cardinality.rb
CHANGED
data/lib/mocha/expectation.rb
CHANGED
@@ -21,14 +21,14 @@ module Mocha
|
|
21
21
|
matching_expectations(invocation, ignoring_order: ignoring_order).first
|
22
22
|
end
|
23
23
|
|
24
|
-
def match_but_out_of_order(invocation)
|
25
|
-
matching_expectations(invocation).first
|
26
|
-
end
|
27
|
-
|
28
24
|
def match_allowing_invocation(invocation)
|
29
25
|
matching_expectations(invocation).detect(&:invocations_allowed?)
|
30
26
|
end
|
31
27
|
|
28
|
+
def match_never_allowing_invocation(invocation)
|
29
|
+
matching_expectations(invocation).detect(&:invocations_never_allowed?)
|
30
|
+
end
|
31
|
+
|
32
32
|
def verified?(assertion_counter = nil)
|
33
33
|
@expectations.all? { |expectation| expectation.verified?(assertion_counter) }
|
34
34
|
end
|
@@ -53,8 +53,6 @@ module Mocha
|
|
53
53
|
self.class.new(to_a + other.to_a)
|
54
54
|
end
|
55
55
|
|
56
|
-
private
|
57
|
-
|
58
56
|
def matching_expectations(invocation, ignoring_order: false)
|
59
57
|
@expectations.select { |e| e.match?(invocation, ignoring_order: ignoring_order) }
|
60
58
|
end
|
data/lib/mocha/mock.rb
CHANGED
@@ -8,6 +8,7 @@ require 'mocha/method_matcher'
|
|
8
8
|
require 'mocha/parameters_matcher'
|
9
9
|
require 'mocha/argument_iterator'
|
10
10
|
require 'mocha/expectation_error_factory'
|
11
|
+
require 'mocha/deprecation'
|
11
12
|
|
12
13
|
module Mocha
|
13
14
|
# Traditional mock object.
|
@@ -321,10 +322,21 @@ module Mocha
|
|
321
322
|
check_expiry
|
322
323
|
check_responder_responds_to(symbol)
|
323
324
|
invocation = Invocation.new(self, symbol, arguments, block)
|
324
|
-
|
325
|
+
|
326
|
+
matching_expectations = all_expectations.matching_expectations(invocation)
|
327
|
+
matching_expectation_allowing_invocation = matching_expectations.detect(&:invocations_allowed?)
|
328
|
+
matching_expectation_never_allowing_invocation = matching_expectations.detect(&:invocations_never_allowed?)
|
329
|
+
|
330
|
+
if matching_expectation_allowing_invocation
|
331
|
+
if matching_expectation_never_allowing_invocation
|
332
|
+
invocation_not_allowed_warning(invocation, matching_expectation_never_allowing_invocation)
|
333
|
+
end
|
325
334
|
matching_expectation_allowing_invocation.invoke(invocation)
|
326
|
-
|
327
|
-
|
335
|
+
else
|
336
|
+
matching_expectation_ignoring_order = all_expectations.match(invocation, ignoring_order: true)
|
337
|
+
if matching_expectation_ignoring_order || (!matching_expectation_ignoring_order && !@everything_stubbed)
|
338
|
+
raise_unexpected_invocation_error(invocation, matching_expectation_ignoring_order)
|
339
|
+
end
|
328
340
|
end
|
329
341
|
end
|
330
342
|
|
@@ -369,6 +381,14 @@ module Mocha
|
|
369
381
|
|
370
382
|
private
|
371
383
|
|
384
|
+
def invocation_not_allowed_warning(invocation, expectation)
|
385
|
+
messages = [
|
386
|
+
"The expectation defined at #{expectation.definition_location} does not allow invocations, but #{invocation.call_description} was invoked.",
|
387
|
+
'This invocation will cause the test to fail fast in a future version of Mocha.'
|
388
|
+
]
|
389
|
+
Deprecation.warning(messages.join(' '))
|
390
|
+
end
|
391
|
+
|
372
392
|
def raise_unexpected_invocation_error(invocation, matching_expectation)
|
373
393
|
if @unexpected_invocation.nil?
|
374
394
|
@unexpected_invocation = invocation
|
data/lib/mocha/version.rb
CHANGED
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.6.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-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby2_keywords
|
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
154
|
- !ruby/object:Gem::Version
|
155
155
|
version: '0'
|
156
156
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
157
|
+
rubygems_version: 3.5.22
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: Mocking and stubbing library
|