rr 3.0.2 → 3.0.6

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: 2b7ca60f4fec0c9f87e1710f6b7faf5ed8a1d52d6c8dd7a8ba82667c1ba920d7
4
- data.tar.gz: 8c80f469725cc6875ea30384439dc6347e2c998f042c9522eb2c8964a9f7f316
3
+ metadata.gz: 82a39c0be764a7469ef744b7d1ad4628b515e036013928623104e3876e70b01b
4
+ data.tar.gz: 78167900a5154d427ec6e0416f3ed740a79b92d3f24b85d4682acd34013b0f4d
5
5
  SHA512:
6
- metadata.gz: '07490a4037a941546b5b8c2139520d3c0d91d752a73e59cc52ef1bdae2ba2b0579deb57cd202db69eb96b67f89a5c5533699a0f6d439a787f8c999cf10f5bf7d'
7
- data.tar.gz: '094e48f18e353e818ed21492f95fdc9fb15c23d01ae17689e0c044f86e6282736a73622451633daf88b04602f31b2848a84996cdd62965be717187dcc1f36b08'
6
+ metadata.gz: d07f274243be2338d218a19ff6ce448012875ad75f10eb9a29027b3a029b4541675d3cf92c4dd6cf5886a01abfb131ad39274a602c901f1cae9a04cf690cb0a2
7
+ data.tar.gz: febd48a6b12d689603d6f9ad9c31f97b034399b1227352b15acccd6d7b15f90496058f189c5290c0acb0510d35279656f06923f763da296cb539a5c3d682c332
data/CHANGES.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.0.6 - 2021-08-07
4
+
5
+ ### Improvements
6
+
7
+ * `assert_received`: Add support for keyword arguments.
8
+ [GitHub#86][Reported by imadoki]
9
+
10
+ ### Thanks
11
+
12
+ * imadoki
13
+
14
+ ## 3.0.5 - 2021-06-26
15
+
16
+ ### Improvements
17
+
18
+ * Improved keyword arguments support on Ruby 2.7.
19
+ [GitHub#85][Patch by akira yamada]
20
+
21
+ ### Thanks
22
+
23
+ * akira yamada
24
+
25
+ ## 3.0.4 - 2021-06-23
26
+
27
+ ### Fixes
28
+
29
+ * Fix inverted condition in keyword arguments related code.
30
+ [GitHub#84][Patch by akira yamada]
31
+
32
+ ### Thanks
33
+
34
+ * akira yamada
35
+
36
+ ## 3.0.3 - 2021-06-22
37
+
38
+ ### Improvements
39
+
40
+ * Improved keyword arguments support.
41
+ [GitHub#83][Patch by akira yamada]
42
+
43
+ ### Thanks
44
+
45
+ * akira yamada
46
+
3
47
  ## 3.0.2 - 2021-06-18
4
48
 
5
49
  ### Improvements
@@ -22,6 +22,7 @@ module RR
22
22
  def method_missing(method_name, *args, &block)
23
23
  @double_definition_create.call(method_name, args, {}, &block)
24
24
  end
25
+ ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
25
26
  end
26
27
 
27
28
  def __double_definition_create__
@@ -137,25 +137,15 @@ module RR
137
137
  id = BoundObjects.size
138
138
  BoundObjects[id] = subject_class
139
139
 
140
- if KeywordArguments.fully_supported?
141
- subject_class.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
142
- def #{method_name}(*args, **kwargs, &block)
143
- ::RR::Injections::DoubleInjection::BoundObjects[#{id}].class_eval do
144
- remove_method(:#{method_name})
145
- end
146
- method_missing(:#{method_name}, *args, **kwargs, &block)
140
+ subject_class.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
141
+ def #{method_name}(*args, &block)
142
+ ::RR::Injections::DoubleInjection::BoundObjects[#{id}].class_eval do
143
+ remove_method(:#{method_name})
147
144
  end
148
- RUBY
149
- else
150
- subject_class.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
151
- def #{method_name}(*args, &block)
152
- ::RR::Injections::DoubleInjection::BoundObjects[#{id}].class_eval do
153
- remove_method(:#{method_name})
154
- end
155
- method_missing(:#{method_name}, *args, &block)
156
- end
157
- RUBY
158
- end
145
+ method_missing(:#{method_name}, *args, &block)
146
+ end
147
+ ruby2_keywords(:#{method_name}) if respond_to?(:ruby2_keywords, true)
148
+ RUBY
159
149
  self
160
150
  end
161
151
 
@@ -192,6 +182,7 @@ module RR
192
182
  arguments.block
193
183
  )
194
184
  end
185
+ ruby2_keywords(:#{method_name}) if respond_to?(:ruby2_keywords, true)
195
186
  RUBY
196
187
  end
197
188
  self
@@ -106,6 +106,7 @@ module RR
106
106
  ).call
107
107
  end
108
108
  end
109
+ ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
109
110
  METHOD
110
111
  end
111
112
  end
@@ -1,7 +1,7 @@
1
1
  module RR
2
2
  module KeywordArguments
3
3
  class << self
4
- if (RUBY_VERSION <=> "2.7.0") >= 0
4
+ if (RUBY_VERSION <=> "3.0.0") >= 0
5
5
  def fully_supported?
6
6
  true
7
7
  end
data/lib/rr/space.rb CHANGED
@@ -22,6 +22,7 @@ module RR
22
22
  def method_missing(method_name, *args, &block)
23
23
  instance.__send__(method_name, *args, &block)
24
24
  end
25
+ ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
25
26
  end
26
27
  end
27
28
 
@@ -1,9 +1,9 @@
1
1
  module RR
2
2
  class SpyVerification
3
- def initialize(subject, method_name, args)
3
+ def initialize(subject, method_name, args, kwargs)
4
4
  @subject = subject
5
5
  @method_name = method_name.to_sym
6
- set_argument_expectation_for_args(args)
6
+ set_argument_expectation_for_args(args, kwargs)
7
7
  @ordered = false
8
8
  once
9
9
  end
@@ -44,9 +44,17 @@ module RR
44
44
  protected
45
45
  attr_writer :times_matcher
46
46
 
47
- def set_argument_expectation_for_args(args)
48
- # with_no_args and with actually set @argument_expectation
49
- args.empty? ? with_no_args : with(*args)
47
+ def set_argument_expectation_for_args(args, kwargs)
48
+ if args.empty? and kwargs.empty?
49
+ # with_no_args and with actually set @argument_expectation
50
+ with_no_args
51
+ else
52
+ if KeywordArguments.fully_supported?
53
+ with(*args, **kwargs)
54
+ else
55
+ with(*args)
56
+ end
57
+ end
50
58
  end
51
59
 
52
60
  def install_method_callback(return_value_block)
@@ -5,9 +5,16 @@ module RR
5
5
  def initialize(subject)
6
6
  @subject = subject
7
7
  end
8
-
9
- def method_missing(method_name, *args, &block)
10
- SpyVerification.new(@subject, method_name, args)
11
- end
8
+
9
+ if KeywordArguments.fully_supported?
10
+ def method_missing(method_name, *args, **kwargs, &block)
11
+ SpyVerification.new(@subject, method_name, args, kwargs)
12
+ end
13
+ else
14
+ def method_missing(method_name, *args, &block)
15
+ SpyVerification.new(@subject, method_name, args, {})
16
+ end
17
+ ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
18
+ end
12
19
  end
13
- end
20
+ end
data/lib/rr/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module RR
2
- VERSION = '3.0.2'.freeze
2
+ VERSION = '3.0.6'.freeze
3
3
  def self.version; VERSION; end
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rr
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-06-18 00:00:00.000000000 Z
13
+ date: 2021-08-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler