mocha 2.6.0 → 2.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a2fb97d6eb77787f83c9199c83fcadd3605a07ec431a5e3d47a0d2ee6ff2c67
4
- data.tar.gz: 42815979d195d003a14b42f36c4818fa6b1ca59d498e5ca3b743338a6dc13af8
3
+ metadata.gz: 427e4fdcdcceac0496dd9ad52802ae29be41ba102de0888e58f6c379c77ac24e
4
+ data.tar.gz: d2c3e87c6d5f861f1ae2124b758fd548e19f2299e1ebe69551b7483d0941516d
5
5
  SHA512:
6
- metadata.gz: 8b3494f44f9b603513afa227fd58f499275155695ae2c5e6759f11a0288d4f0fc706d2be90c01e12b8166caf328a8caf543303671310f91a4e3f28b130319973
7
- data.tar.gz: d8b24445529930e616433246b41e43c78f034842967dff64df9c026be1dab5b5f3b671115d984608166caae6e7a73d253dc8e12bcca8b60514aefbd0520b9c76
6
+ metadata.gz: 7b82f53427cf92b742d97c551808e42f8b954148f7311f97bb52e4c1c15952515cce115e23022ce10a5d52e07238dc8ce7188d810de5f4a7e193ca59d72b2e4f
7
+ data.tar.gz: c345496f74391ca1b8b2f6a4b0d3947f30c119a89416c7f69037b064c6ca207a77607fa8bd93443152c196f4f5fef93cccc984c4a75040ee675d140237dd0f8b
data/RELEASE.md CHANGED
@@ -1,11 +1,20 @@
1
1
  # Release Notes
2
2
 
3
+ ## 2.6.1
4
+
5
+ ### External changes
6
+
7
+ * Fix logic for displaying deprecation warning for expectation with never cardinality (#686) - thanks to @davidstosik for reporting
8
+
3
9
  ## 2.6.0
4
10
 
5
11
  ### External changes
6
12
 
7
13
  * Expectation with never cardinality should display deprecation warning (#681) - thanks to @ducmtran for reporting and testing
8
14
 
15
+ **WARNING: This release results in some incorrect deprecation warnings:**
16
+ * The logic for displaying the deprecation warnings is fixed in v2.6.1 (#686).
17
+
9
18
  ### Internal changes
10
19
 
11
20
  * Simplify backtrace related assertions (#680)
data/lib/mocha/mock.rb CHANGED
@@ -318,25 +318,31 @@ module Mocha
318
318
  ruby2_keywords(:method_missing)
319
319
 
320
320
  # @private
321
- def handle_method_call(symbol, arguments, block)
321
+ def handle_method_call(symbol, arguments, block) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
322
322
  check_expiry
323
323
  check_responder_responds_to(symbol)
324
324
  invocation = Invocation.new(self, symbol, arguments, block)
325
325
 
326
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
327
 
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
334
- matching_expectation_allowing_invocation.invoke(invocation)
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)
328
+ index = 0
329
+ never_allowed_expectation = nil
330
+ while index < matching_expectations.length
331
+ matching_expectation = matching_expectations[index]
332
+ if matching_expectation.invocations_never_allowed?
333
+ never_allowed_expectation = matching_expectation
334
+ elsif matching_expectation.invocations_allowed?
335
+ if never_allowed_expectation
336
+ invocation_not_allowed_warning(invocation, never_allowed_expectation)
337
+ end
338
+ return matching_expectation.invoke(invocation)
339
339
  end
340
+ index += 1
341
+ end
342
+
343
+ matching_expectation_ignoring_order = all_expectations.match(invocation, ignoring_order: true)
344
+ if matching_expectation_ignoring_order || (!matching_expectation_ignoring_order && !@everything_stubbed) # rubocop:disable Style/GuardClause
345
+ raise_unexpected_invocation_error(invocation, matching_expectation_ignoring_order)
340
346
  end
341
347
  end
342
348
 
data/lib/mocha/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mocha
2
- VERSION = '2.6.0'.freeze
2
+ VERSION = '2.6.1'.freeze
3
3
  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.6.0
4
+ version: 2.6.1
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-24 00:00:00.000000000 Z
11
+ date: 2024-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby2_keywords