mocha 2.3.0 → 2.4.1

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: d39bbef9363c1fb12001142111cd1e324a7c304100f456d0c723e9d839a15de4
4
- data.tar.gz: 9a91ce33d3fcacd82f4f4461da86042f66e9c0e0efdba61fbaf588aaddb0ce91
3
+ metadata.gz: 365de18bfd8d5aa67a5baf350c2a89082f702aef92ca581a78bd427529654f36
4
+ data.tar.gz: 8b989ea9c7fea12a78a82ab2db2cd2600793b32e513348e9eb7ea7d4d41094fc
5
5
  SHA512:
6
- metadata.gz: 0662556bb9f093c581bdea78f4484a0d8472dd63a7ee4589ebcdd4564628780e1cc68c32e9a4ae334d08ebe4bab75a9b9aeffe177a560e2e5424d9ff5349f4c7
7
- data.tar.gz: ecabbed8691ddaea029cb0272705c1701c5b2815bfca4236baa559ea6f53eef3e8f650be861b81a43b3e9dff59edcca8a195ccaea7e2ef31f0990e8873753ed4
6
+ metadata.gz: 131e1759a21fd24f1ec7ed7a222626b6fd326a72a4bd38b720c45bac3e800e4b563c28827caf539a397bc9734ab42d1bec03ae8f4c112edeccb61a995d7d3cfb
7
+ data.tar.gz: cf625e741f8324539cd315a7c716cbac1311d0d42db68b4bcf72fe663676a55753b5fa6073bb05c58e169e419fc810822d36bf06db174c49bd24ca7f7391b195
data/RELEASE.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Release Notes
2
2
 
3
+ ## 2.4.1
4
+
5
+ ### External changes
6
+
7
+ * Fix regression in matchers when used with keyword arguments (#648, #655) - thanks to @ElvinEfendi for reporting
8
+
9
+ ### Internal changes
10
+
11
+ * Reduce duplication & consolidate `#to_matcher` method definitions (600ee2aa, e9de64e4, #655)
12
+ * Change `#to_matcher` method to use keyword arguments (3b60b7df, #655)
13
+
14
+ ## 2.4.0
15
+
16
+ ### External changes
17
+
18
+ * Improve rendering of keyword arguments (#652) - thanks to @casperisfine
19
+
20
+ ### Internal changes
21
+
22
+ * Improvements to `#mocha_inspect` unit tests (#650)
23
+
3
24
  ## 2.3.0
4
25
 
5
26
  ### External changes
data/lib/mocha/inspect.rb CHANGED
@@ -19,8 +19,19 @@ module Mocha
19
19
 
20
20
  module HashMethods
21
21
  def mocha_inspect
22
- unwrapped = collect { |key, value| "#{key.mocha_inspect} => #{value.mocha_inspect}" }.join(', ')
23
- Hash.ruby2_keywords_hash?(self) ? unwrapped : "{#{unwrapped}}"
22
+ if Hash.ruby2_keywords_hash?(self)
23
+ collect do |key, value|
24
+ case key
25
+ when Symbol
26
+ "#{key}: #{value.mocha_inspect}"
27
+ else
28
+ "#{key.mocha_inspect} => #{value.mocha_inspect}"
29
+ end
30
+ end.join(', ')
31
+ else
32
+ unwrapped = collect { |key, value| "#{key.mocha_inspect} => #{value.mocha_inspect}" }.join(', ')
33
+ "{#{unwrapped}}"
34
+ end
24
35
  end
25
36
  end
26
37
 
@@ -2,11 +2,6 @@ module Mocha
2
2
  module ParameterMatchers
3
3
  # @abstract Subclass and implement +#matches?+ and +#mocha_inspect+ to define a custom matcher. Also add a suitably named instance method to {ParameterMatchers} to build an instance of the new matcher c.f. {#equals}.
4
4
  class Base
5
- # @private
6
- def to_matcher(_expectation = nil)
7
- self
8
- end
9
-
10
5
  # A shorthand way of combining two matchers when both must match.
11
6
  #
12
7
  # Returns a new {AllOf} parameter matcher combining two matchers using a logical AND.
@@ -1,3 +1,4 @@
1
+ require 'mocha/parameter_matchers/base'
1
2
  require 'mocha/parameter_matchers/equals'
2
3
  require 'mocha/parameter_matchers/positional_or_keyword_hash'
3
4
 
@@ -6,8 +7,14 @@ module Mocha
6
7
  # @private
7
8
  module InstanceMethods
8
9
  # @private
9
- def to_matcher(_expectation = nil)
10
- Mocha::ParameterMatchers::Equals.new(self)
10
+ def to_matcher(expectation: nil, top_level: false)
11
+ if is_a?(Base)
12
+ self
13
+ elsif is_a?(Hash) && top_level
14
+ Mocha::ParameterMatchers::PositionalOrKeywordHash.new(self, expectation)
15
+ else
16
+ Mocha::ParameterMatchers::Equals.new(self)
17
+ end
11
18
  end
12
19
  end
13
20
  end
@@ -17,11 +24,3 @@ end
17
24
  class Object
18
25
  include Mocha::ParameterMatchers::InstanceMethods
19
26
  end
20
-
21
- # @private
22
- class Hash
23
- # @private
24
- def to_matcher(expectation = nil)
25
- Mocha::ParameterMatchers::PositionalOrKeywordHash.new(self, expectation)
26
- end
27
- end
@@ -28,7 +28,7 @@ module Mocha
28
28
  end
29
29
 
30
30
  def matchers
31
- @expected_parameters.map { |p| p.to_matcher(@expectation) }
31
+ @expected_parameters.map { |p| p.to_matcher(expectation: @expectation, top_level: true) }
32
32
  end
33
33
  end
34
34
  end
data/lib/mocha/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mocha
2
- VERSION = '2.3.0'.freeze
2
+ VERSION = '2.4.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.3.0
4
+ version: 2.4.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-05-17 00:00:00.000000000 Z
11
+ date: 2024-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby2_keywords