rr 3.0.4 → 3.0.8
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/CHANGES.md +45 -0
- data/Gemfile +7 -0
- data/lib/rr/double_definitions/double_definition_create_blank_slate.rb +1 -0
- data/lib/rr/double_definitions/strategies/strategy.rb +0 -2
- data/lib/rr/injections/double_injection.rb +10 -19
- data/lib/rr/injections/method_missing_injection.rb +1 -0
- data/lib/rr/integrations/minitest_4.rb +12 -1
- data/lib/rr/keyword_arguments.rb +1 -7
- data/lib/rr/method_dispatches/method_dispatch.rb +2 -2
- data/lib/rr/method_dispatches/method_missing_dispatch.rb +1 -1
- data/lib/rr/space.rb +1 -0
- data/lib/rr/spy_verification.rb +13 -5
- data/lib/rr/spy_verification_proxy.rb +12 -5
- data/lib/rr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7450b7a3e656ff288e54d65cd2c9b899229706d72637a6e7b6944451b311bbe2
|
4
|
+
data.tar.gz: 44d9fa9e2e2f39809320e5d93819df20261dc6ad4ee83ec7e3fba9c81a03aa7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce0dc401f91fd48daeace9aabcc745e9d8f99a27362a82c890cfef326b21f465c826fcad5990f5f4b9f7a1757d5634431b2bdf71c9c6d02d319fc4ca3f9c2c99
|
7
|
+
data.tar.gz: acc8046b8610d2b35571414f736d58ba2e9dcfecf0b59da715c50f972bafbe839c4b627cee6e5d42fa023dd6ab7b2d7b645384f33a4f45c70af79f4e5fc64150
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,50 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.0.8 - 2021-10-17
|
4
|
+
|
5
|
+
### Fixes
|
6
|
+
|
7
|
+
* Minitest integration: Fixed a bug that `NameError` is raised.
|
8
|
+
[GitHub#88][Reported by Matijs van Zuijlen]
|
9
|
+
|
10
|
+
### Thanks
|
11
|
+
|
12
|
+
* Matijs van Zuijlen
|
13
|
+
|
14
|
+
## 3.0.7 - 2021-08-17
|
15
|
+
|
16
|
+
### Fixes
|
17
|
+
|
18
|
+
* Minitest + Active Support integration: Fixed a bug that `stub` in
|
19
|
+
`setup {...}` is ignored.
|
20
|
+
[GitHub#87][Reported by Boris]
|
21
|
+
|
22
|
+
### Thanks
|
23
|
+
|
24
|
+
* Boris
|
25
|
+
|
26
|
+
## 3.0.6 - 2021-08-07
|
27
|
+
|
28
|
+
### Improvements
|
29
|
+
|
30
|
+
* `assert_received`: Added support for keyword arguments.
|
31
|
+
[GitHub#86][Reported by imadoki]
|
32
|
+
|
33
|
+
### Thanks
|
34
|
+
|
35
|
+
* imadoki
|
36
|
+
|
37
|
+
## 3.0.5 - 2021-06-26
|
38
|
+
|
39
|
+
### Improvements
|
40
|
+
|
41
|
+
* Improved keyword arguments support on Ruby 2.7.
|
42
|
+
[GitHub#85][Patch by akira yamada]
|
43
|
+
|
44
|
+
### Thanks
|
45
|
+
|
46
|
+
* akira yamada
|
47
|
+
|
3
48
|
## 3.0.4 - 2021-06-23
|
4
49
|
|
5
50
|
### Fixes
|
data/Gemfile
CHANGED
@@ -137,25 +137,15 @@ module RR
|
|
137
137
|
id = BoundObjects.size
|
138
138
|
BoundObjects[id] = subject_class
|
139
139
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
remove_method(:#{method_name})
|
145
|
-
end
|
146
|
-
method_missing(:#{method_name}, *args, **kwargs, &block)
|
147
|
-
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)
|
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})
|
156
144
|
end
|
157
|
-
|
158
|
-
|
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
|
|
@@ -163,7 +153,7 @@ module RR
|
|
163
153
|
id = BoundObjects.size
|
164
154
|
BoundObjects[id] = subject_class
|
165
155
|
|
166
|
-
if KeywordArguments.fully_supported?
|
156
|
+
if KeywordArguments.fully_supported?
|
167
157
|
subject_class.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
168
158
|
def #{method_name}(*args, **kwargs, &block)
|
169
159
|
arguments = MethodArguments.new(args, kwargs, block)
|
@@ -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
|
@@ -39,10 +39,21 @@ module RR
|
|
39
39
|
include RR::DSL
|
40
40
|
include Mixin
|
41
41
|
|
42
|
+
if defined?(::ActiveSupport::TestCase)
|
43
|
+
is_active_support_test_case = lambda do |target|
|
44
|
+
target.is_a?(::ActiveSupport::TestCase)
|
45
|
+
end
|
46
|
+
else
|
47
|
+
is_active_support_test_case = lambda do |target|
|
48
|
+
false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
42
52
|
unless instance_methods.any? { |method_name| method_name.to_sym == :setup_with_rr }
|
43
53
|
alias_method :setup_without_rr, :setup
|
44
54
|
define_method(:setup_with_rr) do
|
45
55
|
setup_without_rr
|
56
|
+
return if is_active_support_test_case.call(self)
|
46
57
|
RR.reset
|
47
58
|
RR.trim_backtrace = true
|
48
59
|
RR.overridden_error_class = assertion_error_class
|
@@ -52,7 +63,7 @@ module RR
|
|
52
63
|
alias_method :teardown_without_rr, :teardown
|
53
64
|
define_method(:teardown_with_rr) do
|
54
65
|
begin
|
55
|
-
RR.verify
|
66
|
+
RR.verify unless is_active_support_test_case.call(self)
|
56
67
|
ensure
|
57
68
|
teardown_without_rr
|
58
69
|
end
|
data/lib/rr/keyword_arguments.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module RR
|
2
2
|
module KeywordArguments
|
3
3
|
class << self
|
4
|
-
if (RUBY_VERSION <=> "
|
4
|
+
if (RUBY_VERSION <=> "3.0.0") >= 0
|
5
5
|
def fully_supported?
|
6
6
|
true
|
7
7
|
end
|
@@ -10,12 +10,6 @@ module RR
|
|
10
10
|
false
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
14
|
-
def accept_kwargs?(subject_class, method_name)
|
15
|
-
subject_class.instance_method(method_name).parameters.any? { |t, _| t == :key || t == :keyrest }
|
16
|
-
rescue NameError
|
17
|
-
true
|
18
|
-
end
|
19
13
|
end
|
20
14
|
end
|
21
15
|
end
|
@@ -31,7 +31,7 @@ module RR
|
|
31
31
|
|
32
32
|
def call_original_method
|
33
33
|
if subject_has_original_method?
|
34
|
-
if KeywordArguments.fully_supported?
|
34
|
+
if KeywordArguments.fully_supported?
|
35
35
|
subject.__send__(original_method_alias_name, *args, **kwargs, &block)
|
36
36
|
else
|
37
37
|
subject.__send__(original_method_alias_name, *args, &block)
|
@@ -53,7 +53,7 @@ module RR
|
|
53
53
|
call_original_method
|
54
54
|
else
|
55
55
|
if implementation
|
56
|
-
if KeywordArguments.fully_supported?
|
56
|
+
if KeywordArguments.fully_supported?
|
57
57
|
implementation.call(*args, **kwargs, &block)
|
58
58
|
else
|
59
59
|
implementation.call(*args, &block)
|
@@ -52,7 +52,7 @@ module RR
|
|
52
52
|
if double_injection = Injections::DoubleInjection.find(subject_class, method_name)
|
53
53
|
double_injection.bind_method
|
54
54
|
# The DoubleInjection takes care of calling double.method_call
|
55
|
-
if KeywordArguments.fully_supported?
|
55
|
+
if KeywordArguments.fully_supported?
|
56
56
|
subject.__send__(method_name, *args, **kwargs, &block)
|
57
57
|
else
|
58
58
|
subject.__send__(method_name, *args, &block)
|
data/lib/rr/space.rb
CHANGED
data/lib/rr/spy_verification.rb
CHANGED
@@ -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
|
-
|
49
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
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
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.
|
4
|
+
version: 3.0.8
|
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-
|
13
|
+
date: 2021-10-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|