rspec-support 3.7.1 → 3.8.0
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
- checksums.yaml.gz.sig +2 -1
- data.tar.gz.sig +0 -0
- data/Changelog.md +8 -0
- data/README.md +1 -1
- data/lib/rspec/support/method_signature_verifier.rb +57 -23
- data/lib/rspec/support/object_formatter.rb +13 -5
- data/lib/rspec/support/ruby_features.rb +16 -2
- data/lib/rspec/support/version.rb +1 -1
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 631283161faf72604c2081235f9acbbda6ea980f
|
4
|
+
data.tar.gz: 99170c1beccff1f998787873e0bd156af46ca9ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23464780384e45e24c4a8a8255dce0f78d0afd406723d817d68ef66d20a8c0d973d40bdc6bee54188e9714c6ffb20b116045a08bb9c90aa11cb2ec2bdea453a6
|
7
|
+
data.tar.gz: 4b08b17ebd14c92b615d9d6838d1be78c32b9e695933c895bb99710693bec391736ce26864f139c0e22f794e085367aa5cf0081b659068994cffddbfea23f0bc
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
X
|
1
|
+
�7��,�H�X�j'�:������V����Mu��<�[%�8��b8���)žN�$�tA�N�`ʘ>zQ(���8��������,���BM��g辋g�}Ԅ�&�_
|
2
|
+
q��ѡ�>e-���}8Yn+߀��>���?r����O9��;l�����Sw��?�AZ�H���B���o�Ę!�Z�p��b�/s�Q�H��B�]K����� ���.`�ƿ��ĹO�R���P��Z6Ȯ���
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### 3.8.0 / 2018-08-04
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.1...v3.8.0)
|
3
|
+
|
4
|
+
Bug Fixes:
|
5
|
+
|
6
|
+
* Order hash keys before diffing to improve diff accuracy when using mocked calls.
|
7
|
+
(James Crisp, #334)
|
8
|
+
|
1
9
|
### 3.7.1 / 2018-01-29
|
2
10
|
[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.0...v3.7.1)
|
3
11
|
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ RSpec repos as well. Add the following to your `Gemfile`:
|
|
13
13
|
|
14
14
|
```ruby
|
15
15
|
%w[rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
|
16
|
-
gem lib, :git => "
|
16
|
+
gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'master'
|
17
17
|
end
|
18
18
|
```
|
19
19
|
|
@@ -33,6 +33,18 @@ module RSpec
|
|
33
33
|
optional_max_arg_count <= max_non_kw_args
|
34
34
|
end
|
35
35
|
|
36
|
+
def classify_arity(arity=@method.arity)
|
37
|
+
if arity < 0
|
38
|
+
# `~` inverts the one's complement and gives us the
|
39
|
+
# number of required args
|
40
|
+
@min_non_kw_args = ~arity
|
41
|
+
@max_non_kw_args = INFINITY
|
42
|
+
else
|
43
|
+
@min_non_kw_args = arity
|
44
|
+
@max_non_kw_args = arity
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
36
48
|
if RubyFeatures.optional_and_splat_args_supported?
|
37
49
|
def description
|
38
50
|
@description ||= begin
|
@@ -137,36 +149,58 @@ module RSpec
|
|
137
149
|
false
|
138
150
|
end
|
139
151
|
|
140
|
-
|
141
|
-
arity = @method.arity
|
142
|
-
if arity < 0
|
143
|
-
# `~` inverts the one's complement and gives us the
|
144
|
-
# number of required args
|
145
|
-
@min_non_kw_args = ~arity
|
146
|
-
@max_non_kw_args = INFINITY
|
147
|
-
else
|
148
|
-
@min_non_kw_args = arity
|
149
|
-
@max_non_kw_args = arity
|
150
|
-
end
|
151
|
-
end
|
152
|
+
alias_method :classify_parameters, :classify_arity
|
152
153
|
end
|
153
154
|
|
154
155
|
INFINITY = 1 / 0.0
|
155
156
|
end
|
156
157
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
158
|
+
if RSpec::Support::Ruby.jruby?
|
159
|
+
# JRuby has only partial support for UnboundMethod#parameters, so we fall back on using #arity
|
160
|
+
# https://github.com/jruby/jruby/issues/2816 and https://github.com/jruby/jruby/issues/2817
|
161
|
+
if RubyFeatures.optional_and_splat_args_supported? &&
|
162
|
+
Java::JavaLang::String.instance_method(:char_at).parameters == []
|
162
163
|
|
163
|
-
|
164
|
-
|
164
|
+
class MethodSignature < remove_const(:MethodSignature)
|
165
|
+
private
|
165
166
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
167
|
+
def classify_parameters
|
168
|
+
super
|
169
|
+
if (arity = @method.arity) != 0 && @method.parameters.empty?
|
170
|
+
classify_arity(arity)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# JRuby used to always report -1 arity for Java proxy methods.
|
177
|
+
# The workaround essentially makes use of Java's introspection to figure
|
178
|
+
# out matching methods (which could be more than one partly because Java
|
179
|
+
# supports multiple overloads, and partly because JRuby introduces
|
180
|
+
# aliases to make method names look more Rubyesque). If there is only a
|
181
|
+
# single match, we can use that methods arity directly instead of the
|
182
|
+
# default -1 arity.
|
183
|
+
#
|
184
|
+
# This workaround only works for Java proxy methods, and in order to
|
185
|
+
# support regular methods and blocks, we need to be careful about calling
|
186
|
+
# owner and java_class as they might not be available
|
187
|
+
if Java::JavaLang::String.instance_method(:char_at).arity == -1
|
188
|
+
class MethodSignature < remove_const(:MethodSignature)
|
189
|
+
private
|
190
|
+
|
191
|
+
def classify_parameters
|
192
|
+
super
|
193
|
+
return unless @method.arity == -1
|
194
|
+
return unless @method.respond_to?(:owner)
|
195
|
+
return unless @method.owner.respond_to?(:java_class)
|
196
|
+
java_instance_methods = @method.owner.java_class.java_instance_methods
|
197
|
+
compatible_overloads = java_instance_methods.select do |java_method|
|
198
|
+
@method == @method.owner.instance_method(java_method.name)
|
199
|
+
end
|
200
|
+
if compatible_overloads.size == 1
|
201
|
+
classify_arity(compatible_overloads.first.arity)
|
202
|
+
end
|
203
|
+
end
|
170
204
|
end
|
171
205
|
end
|
172
206
|
end
|
@@ -5,7 +5,7 @@ module RSpec
|
|
5
5
|
# Provide additional output details beyond what `inspect` provides when
|
6
6
|
# printing Time, DateTime, or BigDecimal
|
7
7
|
# @api private
|
8
|
-
class ObjectFormatter # rubocop:disable
|
8
|
+
class ObjectFormatter # rubocop:disable Metrics/ClassLength
|
9
9
|
ELLIPSIS = "..."
|
10
10
|
|
11
11
|
attr_accessor :max_formatted_output_length
|
@@ -31,15 +31,15 @@ module RSpec
|
|
31
31
|
|
32
32
|
def format(object)
|
33
33
|
if max_formatted_output_length.nil?
|
34
|
-
|
34
|
+
prepare_for_inspection(object).inspect
|
35
35
|
else
|
36
36
|
formatted_object = prepare_for_inspection(object).inspect
|
37
37
|
if formatted_object.length < max_formatted_output_length
|
38
|
-
|
38
|
+
formatted_object
|
39
39
|
else
|
40
40
|
beginning = truncate_string formatted_object, 0, max_formatted_output_length / 2
|
41
41
|
ending = truncate_string formatted_object, -max_formatted_output_length / 2, -1
|
42
|
-
|
42
|
+
beginning + ELLIPSIS + ending
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -73,7 +73,7 @@ module RSpec
|
|
73
73
|
|
74
74
|
def prepare_hash(input_hash)
|
75
75
|
with_entering_structure(input_hash) do
|
76
|
-
input_hash.inject({}) do |output_hash, key_and_value|
|
76
|
+
sort_hash_keys(input_hash).inject({}) do |output_hash, key_and_value|
|
77
77
|
key, value = key_and_value.map { |element| prepare_element(element) }
|
78
78
|
output_hash[key] = value
|
79
79
|
output_hash
|
@@ -81,6 +81,14 @@ module RSpec
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
+
def sort_hash_keys(input_hash)
|
85
|
+
if input_hash.keys.all? { |k| k.is_a?(String) || k.is_a?(Symbol) }
|
86
|
+
Hash[input_hash.sort_by { |k, _v| k.to_s }]
|
87
|
+
else
|
88
|
+
input_hash
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
84
92
|
def prepare_element(element)
|
85
93
|
if recursive_structure?(element)
|
86
94
|
case element
|
@@ -56,6 +56,22 @@ module RSpec
|
|
56
56
|
module RubyFeatures
|
57
57
|
module_function
|
58
58
|
|
59
|
+
if Ruby.jruby?
|
60
|
+
# On JRuby 1.7 `--1.8` mode, `Process.respond_to?(:fork)` returns true,
|
61
|
+
# but when you try to fork, it raises an error:
|
62
|
+
# NotImplementedError: fork is not available on this platform
|
63
|
+
#
|
64
|
+
# When we drop support for JRuby 1.7 and/or Ruby 1.8, we can drop
|
65
|
+
# this special case.
|
66
|
+
def fork_supported?
|
67
|
+
false
|
68
|
+
end
|
69
|
+
else
|
70
|
+
def fork_supported?
|
71
|
+
Process.respond_to?(:fork)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
59
75
|
def optional_and_splat_args_supported?
|
60
76
|
Method.method_defined?(:parameters)
|
61
77
|
end
|
@@ -109,7 +125,6 @@ module RSpec
|
|
109
125
|
end
|
110
126
|
else
|
111
127
|
# RBX / JRuby et al support is unknown for keyword arguments
|
112
|
-
# rubocop:disable Lint/Eval
|
113
128
|
begin
|
114
129
|
eval("o = Object.new; def o.m(a: 1); end;"\
|
115
130
|
" raise SyntaxError unless o.method(:m).parameters.include?([:key, :a])")
|
@@ -147,7 +162,6 @@ module RSpec
|
|
147
162
|
false
|
148
163
|
end
|
149
164
|
end
|
150
|
-
# rubocop:enable Lint/Eval
|
151
165
|
end
|
152
166
|
|
153
167
|
def module_refinement_supported?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Chelimsky
|
@@ -48,7 +48,7 @@ cert_chain:
|
|
48
48
|
ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
|
49
49
|
F3MdtaDehhjC
|
50
50
|
-----END CERTIFICATE-----
|
51
|
-
date: 2018-
|
51
|
+
date: 2018-08-04 00:00:00.000000000 Z
|
52
52
|
dependencies:
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: bundler
|
@@ -156,5 +156,5 @@ rubyforge_project:
|
|
156
156
|
rubygems_version: 2.6.13
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
|
-
summary: rspec-support-3.
|
159
|
+
summary: rspec-support-3.8.0
|
160
160
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|