mocha 2.4.1 → 2.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 365de18bfd8d5aa67a5baf350c2a89082f702aef92ca581a78bd427529654f36
4
- data.tar.gz: 8b989ea9c7fea12a78a82ab2db2cd2600793b32e513348e9eb7ea7d4d41094fc
3
+ metadata.gz: 20b26576ac50c2162b416a544a08067d42398349077ac592e8e1f950497f8fbd
4
+ data.tar.gz: d587d5707e1a636734571b94935a450848303248f232e1d1cab9f4c0ba971460
5
5
  SHA512:
6
- metadata.gz: 131e1759a21fd24f1ec7ed7a222626b6fd326a72a4bd38b720c45bac3e800e4b563c28827caf539a397bc9734ab42d1bec03ae8f4c112edeccb61a995d7d3cfb
7
- data.tar.gz: cf625e741f8324539cd315a7c716cbac1311d0d42db68b4bcf72fe663676a55753b5fa6073bb05c58e169e419fc810822d36bf06db174c49bd24ca7f7391b195
6
+ metadata.gz: eaa8c9e311cdced9c27bda88ce59e14929e8533c9dbb87913c32ccf4432b499ce28c340c31d4d725bc703419c5c5a3fcf8ef241ab47539ccb4adc224cea3738c
7
+ data.tar.gz: e7088d55909895d76db07023f58342913b558cfc8d628779d51b1b46b6132a52f6f6f60ea50b147cc120d7b5a5b1c046567beeb91f272b5701665cd22bc65f83
data/.rubocop.yml CHANGED
@@ -36,6 +36,11 @@ Style/WhileUntilModifier:
36
36
  Style/AccessModifierDeclarations:
37
37
  Enabled: false
38
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
+
39
44
  # This is useful when using `ExecutionPoint.current` to make tests more robust
40
45
  Style/Semicolon:
41
46
  Enabled: false
data/RELEASE.md CHANGED
@@ -1,10 +1,22 @@
1
1
  # Release Notes
2
2
 
3
+ ## 2.4.3
4
+
5
+ ### External changes
6
+
7
+ * Fix regression when matching Hash parameter or keyword arguments (#657, #660) - thanks to @josesei for reporting and testing
8
+
9
+ ## 2.4.2
10
+
11
+ ### External changes
12
+
13
+ * Don't trust `Object#is_a?` in presence of mock objects (#656) - thanks to @casperisfine
14
+
3
15
  ## 2.4.1
4
16
 
5
17
  ### External changes
6
18
 
7
- * Fix regression in matchers when used with keyword arguments (#648, #655) - thanks to @ElvinEfendi for reporting
19
+ * Fix regression in matchers when used with keyword arguments (#654 & #655) - thanks to @ElvinEfendi for reporting
8
20
 
9
21
  ### Internal changes
10
22
 
@@ -30,20 +30,23 @@ module Mocha
30
30
  # Parameter matcher which matches when actual parameter contains all expected +Hash+ entries.
31
31
  class HasEntries < Base
32
32
  # @private
33
- def initialize(entries)
33
+ def initialize(entries, exact: false)
34
34
  @entries = entries
35
+ @exact = exact
35
36
  end
36
37
 
37
38
  # @private
38
39
  def matches?(available_parameters)
39
40
  parameter = available_parameters.shift
41
+ return false if @exact && @entries.length != parameter.length
42
+
40
43
  has_entry_matchers = @entries.map { |key, value| HasEntry.new(key, value) }
41
44
  AllOf.new(*has_entry_matchers).matches?([parameter])
42
45
  end
43
46
 
44
47
  # @private
45
48
  def mocha_inspect
46
- "has_entries(#{@entries.mocha_inspect})"
49
+ @exact ? @entries.mocha_inspect : "has_entries(#{@entries.mocha_inspect})"
47
50
  end
48
51
  end
49
52
  end
@@ -8,9 +8,9 @@ module Mocha
8
8
  module InstanceMethods
9
9
  # @private
10
10
  def to_matcher(expectation: nil, top_level: false)
11
- if is_a?(Base)
11
+ if Base === self
12
12
  self
13
- elsif is_a?(Hash) && top_level
13
+ elsif Hash === self && top_level
14
14
  Mocha::ParameterMatchers::PositionalOrKeywordHash.new(self, expectation)
15
15
  else
16
16
  Mocha::ParameterMatchers::Equals.new(self)
@@ -1,6 +1,7 @@
1
1
  require 'mocha/configuration'
2
2
  require 'mocha/deprecation'
3
3
  require 'mocha/parameter_matchers/base'
4
+ require 'mocha/parameter_matchers/has_entries'
4
5
 
5
6
  module Mocha
6
7
  module ParameterMatchers
@@ -14,7 +15,7 @@ module Mocha
14
15
  def matches?(available_parameters)
15
16
  parameter, is_last_parameter = extract_parameter(available_parameters)
16
17
 
17
- return false unless HasEntries.new(@value).matches?([parameter])
18
+ return false unless HasEntries.new(@value, exact: true).matches?([parameter])
18
19
 
19
20
  if is_last_parameter && !same_type_of_hash?(parameter, @value)
20
21
  return false if Mocha.configuration.strict_keyword_argument_matching?
data/lib/mocha/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mocha
2
- VERSION = '2.4.1'.freeze
2
+ VERSION = '2.4.3'.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.4.1
4
+ version: 2.4.3
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-07-16 00:00:00.000000000 Z
11
+ date: 2024-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby2_keywords