rspec-support 3.7.1 → 3.8.0

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
  SHA1:
3
- metadata.gz: 0fe50cb7f542a64bbfaf228bf0d4222210131c9c
4
- data.tar.gz: 3252ea5991d2b3583a042f16843f81195ea60ffb
3
+ metadata.gz: 631283161faf72604c2081235f9acbbda6ea980f
4
+ data.tar.gz: 99170c1beccff1f998787873e0bd156af46ca9ef
5
5
  SHA512:
6
- metadata.gz: 505b60919c61f1615270f98a9c6cdafcb8553eef14661423a1ca32bef71bd7bd1aae7e9f8fef6da4cd6de0c207cf666aa429e525915b41310b1f7195d1703932
7
- data.tar.gz: 2a8d7ffcd478cd7e9dfd90dd97daf14e9296b32fad88e39391d60e785c9326c02db0940b47873ba04dcb98c252dca9535171f9a56633992fbfe7e0930042fc60
6
+ metadata.gz: 23464780384e45e24c4a8a8255dce0f78d0afd406723d817d68ef66d20a8c0d973d40bdc6bee54188e9714c6ffb20b116045a08bb9c90aa11cb2ec2bdea453a6
7
+ data.tar.gz: 4b08b17ebd14c92b615d9d6838d1be78c32b9e695933c895bb99710693bec391736ce26864f139c0e22f794e085367aa5cf0081b659068994cffddbfea23f0bc
@@ -1 +1,2 @@
1
- X+�ӄ��kʕH���|��Ǫձ�(+��4'��i.���tI����DM���٢ ii���b�n�����0����(�YQds��!�sA�֒�� $ ��b�Oy��TV�{ϒ=�߂fDg��s�1�<"�.~w����T{�5x\�� wGݿ�����=��4�ϐ�@J��Z��{��k��t�6�e�`�P�|^k��{C~I6��۵�?�#���
1
+ �7��,�H�X�j'�:������V����Mu��<�[%�8��b8���)žN�$�tAN�`ʘ>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
@@ -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 => "git://github.com/rspec/#{lib}.git", :branch => 'master'
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
- def classify_parameters
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
- # Some versions of JRuby have a nasty bug we have to work around :(.
158
- # https://github.com/jruby/jruby/issues/2816
159
- if RSpec::Support::Ruby.jruby? &&
160
- RubyFeatures.optional_and_splat_args_supported? &&
161
- Class.new { attr_writer :foo }.instance_method(:foo=).parameters == []
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
- class MethodSignature < remove_const(:MethodSignature)
164
- private
164
+ class MethodSignature < remove_const(:MethodSignature)
165
+ private
165
166
 
166
- def classify_parameters
167
- super
168
- return unless @method.parameters == [] && @method.arity == 1
169
- @max_non_kw_args = @min_non_kw_args = 1
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 Style/ClassLength
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
- return prepare_for_inspection(object).inspect
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
- return formatted_object
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
- return beginning + ELLIPSIS + ending
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?
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Support
3
3
  module Version
4
- STRING = '3.7.1'
4
+ STRING = '3.8.0'
5
5
  end
6
6
  end
7
7
  end
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.7.1
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-01-30 00:00:00.000000000 Z
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.7.1
159
+ summary: rspec-support-3.8.0
160
160
  test_files: []
metadata.gz.sig CHANGED
Binary file