rspec-support 3.7.1 → 3.9.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
- SHA1:
3
- metadata.gz: 0fe50cb7f542a64bbfaf228bf0d4222210131c9c
4
- data.tar.gz: 3252ea5991d2b3583a042f16843f81195ea60ffb
2
+ SHA256:
3
+ metadata.gz: 5c8cd61c982e4ac70aa43e70803e06e76018107daa69d666eb489734ccf78e91
4
+ data.tar.gz: 68f0a5ab651d9adfb6c53708bbf0b694eb40fe2781da413afd795a375dabbb5f
5
5
  SHA512:
6
- metadata.gz: 505b60919c61f1615270f98a9c6cdafcb8553eef14661423a1ca32bef71bd7bd1aae7e9f8fef6da4cd6de0c207cf666aa429e525915b41310b1f7195d1703932
7
- data.tar.gz: 2a8d7ffcd478cd7e9dfd90dd97daf14e9296b32fad88e39391d60e785c9326c02db0940b47873ba04dcb98c252dca9535171f9a56633992fbfe7e0930042fc60
6
+ metadata.gz: 57f69f0570273c83d2eca2570a40e203afa78bc259591770e97b330b8ebac66884db77f906244916becfbcd5e13bbd1365db05833c1336b520f6d21c07345162
7
+ data.tar.gz: 76eb5e023bdce42de00e3194491530bb7c32819aae9975b95536734c064af676890f30d3618fb04a4d000e6934e3644af577593fd5708496c61ac9ae647bdac9
@@ -1 +1,3 @@
1
- X+�ӄ��kʕH���|��Ǫձ�(+��4'��i.���tI����DM���٢ ii���b�n�����0����(�YQds��!�sA�֒�� $ ��bOy��TV�{ϒ=�߂fDg��s�1�<"�.~w����T{�5x\�� wGݿ�����=��4�ϐ�@J��Z��{��k��t6e�`�P�|^k��{C~I6��۵�?�#���
1
+ �y�>k�k�ce�;�m���(#�h�n����Գ�G{{-�������(:��N3���D'j��/:/�ί�4W }2��a����%%�&�o�:l���k�!�P|�^ F,��΀nz�̉�W���uة1",��/�����_U�� ��ݽ�Z�3T�,,['(7o��P��yt�/
2
+ �`
3
+ .���(>k�8�o��!�ڷQ�+����qH����<P���I�������g�_6�SG@�R�XR��5�]�60�qs�ž�,֤�6���N�@�;�E����3�Nآ -�ٴB}65����&� F%i�epO�M&C�Î�O�;PҘF�n��Et�V�ZG� ���������>�t�4� '`���9��]VE��q�P�j� ��a7����џ�^c 2]&�B-�?����_�,�a���/�\����+��[9�M~<륦�k-q��Ȅ��!C<�e�^8��,y�b��%�#�{�O���0 ��e�t�ok�yw-�����'�
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,51 @@
1
+ ### 3.9.1 / 2019-12-28
2
+
3
+ Bug Fixes:
4
+
5
+ * Remove warning caused by keyword arguments on Ruby 2.7.0.
6
+ (Jon Rowe, #392)
7
+
8
+ ### 3.9.0 / 2019-10-07
9
+
10
+ *NO CHANGES*
11
+
12
+ Version 3.9.0 was released to allow other RSpec gems to release 3.9.0.
13
+
14
+ ### 3.8.3 / 2019-10-02
15
+
16
+ Bug Fixes:
17
+
18
+ * Escape \r when outputting strings inside arrays.
19
+ (Tomita Masahiro, Jon Rowe, #378)
20
+ * Ensure that optional hash arguments are recognised correctly vs keyword
21
+ arguments. (Evgeni Dzhelyov, #366)
22
+
23
+ ### 3.8.2 / 2019-06-10
24
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.1...v3.8.2)
25
+
26
+ Bug Fixes:
27
+
28
+ * Ensure that an empty hash is recognised as empty keyword arguments when
29
+ applicable. (Thomas Walpole, #375)
30
+ * Ensure that diffing truthy values produce diffs consistently.
31
+ (Lucas Nestor, #377)
32
+
33
+ ### 3.8.1 / 2019-03-03
34
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.0...v3.8.1)
35
+
36
+ Bug Fixes:
37
+
38
+ * Ensure that inspecting a `SimpleDelegator` based object works regardless of
39
+ visibilty of the `__getobj__` method. (Jon Rowe, #369)
40
+
41
+ ### 3.8.0 / 2018-08-04
42
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.1...v3.8.0)
43
+
44
+ Bug Fixes:
45
+
46
+ * Order hash keys before diffing to improve diff accuracy when using mocked calls.
47
+ (James Crisp, #334)
48
+
1
49
  ### 3.7.1 / 2018-01-29
2
50
  [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.0...v3.7.1)
3
51
 
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
 
@@ -139,7 +139,7 @@ module RSpec
139
139
  end
140
140
  end
141
141
 
142
- # The Differ is only needed when a a spec fails with a diffable failure.
142
+ # The Differ is only needed when a spec fails with a diffable failure.
143
143
  # In the more common case of all specs passing or the only failures being
144
144
  # non-diffable, we can avoid the extra cost of loading the differ, diff-lcs,
145
145
  # pp, etc by avoiding an unnecessary require. Instead, autoload will take
@@ -11,7 +11,7 @@ module RSpec
11
11
  def diff(actual, expected)
12
12
  diff = ""
13
13
 
14
- if actual && expected
14
+ unless actual.nil? || expected.nil?
15
15
  if all_strings?(actual, expected)
16
16
  if any_multiline_strings?(actual, expected)
17
17
  diff = diff_as_string(coerce_to_string(actual), coerce_to_string(expected))
@@ -97,7 +97,7 @@ module RSpec
97
97
  if Array === entry
98
98
  entry.inspect
99
99
  else
100
- entry.to_s.gsub("\n", "\\n")
100
+ entry.to_s.gsub("\n", "\\n").gsub("\r", "\\r")
101
101
  end
102
102
  end
103
103
  end
@@ -112,11 +112,40 @@ module RSpec
112
112
  string = remove_invalid_bytes(string)
113
113
  string.encode(@encoding)
114
114
  rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError
115
- string.encode(@encoding, ENCODE_UNCONVERTABLE_BYTES)
115
+ encode_unconvertable_bytes(string)
116
116
  rescue Encoding::ConverterNotFoundError
117
- string.dup.force_encoding(@encoding).encode(ENCODE_NO_CONVERTER)
117
+ encode_no_converter(string.dup.force_encoding(@encoding))
118
118
  end
119
119
 
120
+ private
121
+
122
+ # On Ruby 2.7.0 keyword arguments mixed with conventional cause a warning to
123
+ # be issued requiring us to be explicit by using a ** to pass the hash as
124
+ # keyword arguments. Any keyword argument supporting Ruby supports this.
125
+ if RubyFeatures.kw_args_supported?
126
+ # Note on non keyword supporting Ruby ** causes a syntax error hence
127
+ # we must use eval. To be removed in RSpec 4.
128
+ binding.eval(<<-CODE, __FILE__, __LINE__)
129
+ def encode_unconvertable_bytes(string)
130
+ string.encode(@encoding, **ENCODE_UNCONVERTABLE_BYTES)
131
+ end
132
+
133
+ def encode_no_converter(string)
134
+ string.encode(**ENCODE_NO_CONVERTER)
135
+ end
136
+ CODE
137
+ else
138
+ def encode_unconvertable_bytes(string)
139
+ string.encode(@encoding, ENCODE_UNCONVERTABLE_BYTES)
140
+ end
141
+
142
+ def encode_no_converter(string)
143
+ string.encode(ENCODE_NO_CONVERTER)
144
+ end
145
+ end
146
+
147
+ public
148
+
120
149
  # Prevents raising ArgumentError
121
150
  if String.method_defined?(:scrub)
122
151
  # https://github.com/ruby/ruby/blob/eeb05e8c11/doc/NEWS-2.1.0#L120-L123
@@ -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
@@ -65,14 +77,19 @@ module RSpec
65
77
  given_kw_args - @allowed_kw_args
66
78
  end
67
79
 
80
+ # If the last argument is Hash, Ruby will treat only symbol keys as keyword arguments
81
+ # the rest will be grouped in another Hash and passed as positional argument.
68
82
  def has_kw_args_in?(args)
69
- Hash === args.last && could_contain_kw_args?(args)
83
+ Hash === args.last &&
84
+ could_contain_kw_args?(args) &&
85
+ (args.last.empty? || args.last.keys.any? { |x| x.is_a?(Symbol) })
70
86
  end
71
87
 
72
88
  # Without considering what the last arg is, could it
73
89
  # contain keyword arguments?
74
90
  def could_contain_kw_args?(args)
75
91
  return false if args.count <= min_non_kw_args
92
+
76
93
  @allows_any_kw_args || @allowed_kw_args.any?
77
94
  end
78
95
 
@@ -137,36 +154,58 @@ module RSpec
137
154
  false
138
155
  end
139
156
 
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
157
+ alias_method :classify_parameters, :classify_arity
152
158
  end
153
159
 
154
160
  INFINITY = 1 / 0.0
155
161
  end
156
162
 
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 == []
163
+ if RSpec::Support::Ruby.jruby?
164
+ # JRuby has only partial support for UnboundMethod#parameters, so we fall back on using #arity
165
+ # https://github.com/jruby/jruby/issues/2816 and https://github.com/jruby/jruby/issues/2817
166
+ if RubyFeatures.optional_and_splat_args_supported? &&
167
+ Java::JavaLang::String.instance_method(:char_at).parameters == []
162
168
 
163
- class MethodSignature < remove_const(:MethodSignature)
164
- private
169
+ class MethodSignature < remove_const(:MethodSignature)
170
+ private
165
171
 
166
- def classify_parameters
167
- super
168
- return unless @method.parameters == [] && @method.arity == 1
169
- @max_non_kw_args = @min_non_kw_args = 1
172
+ def classify_parameters
173
+ super
174
+ if (arity = @method.arity) != 0 && @method.parameters.empty?
175
+ classify_arity(arity)
176
+ end
177
+ end
178
+ end
179
+ end
180
+
181
+ # JRuby used to always report -1 arity for Java proxy methods.
182
+ # The workaround essentially makes use of Java's introspection to figure
183
+ # out matching methods (which could be more than one partly because Java
184
+ # supports multiple overloads, and partly because JRuby introduces
185
+ # aliases to make method names look more Rubyesque). If there is only a
186
+ # single match, we can use that methods arity directly instead of the
187
+ # default -1 arity.
188
+ #
189
+ # This workaround only works for Java proxy methods, and in order to
190
+ # support regular methods and blocks, we need to be careful about calling
191
+ # owner and java_class as they might not be available
192
+ if Java::JavaLang::String.instance_method(:char_at).arity == -1
193
+ class MethodSignature < remove_const(:MethodSignature)
194
+ private
195
+
196
+ def classify_parameters
197
+ super
198
+ return unless @method.arity == -1
199
+ return unless @method.respond_to?(:owner)
200
+ return unless @method.owner.respond_to?(:java_class)
201
+ java_instance_methods = @method.owner.java_class.java_instance_methods
202
+ compatible_overloads = java_instance_methods.select do |java_method|
203
+ @method == @method.owner.instance_method(java_method.name)
204
+ end
205
+ if compatible_overloads.size == 1
206
+ classify_arity(compatible_overloads.first.arity)
207
+ end
208
+ end
170
209
  end
171
210
  end
172
211
  end
@@ -323,7 +362,14 @@ module RSpec
323
362
 
324
363
  def split_args(*args)
325
364
  kw_args = if @signature.has_kw_args_in?(args)
326
- args.pop.keys
365
+ last = args.pop
366
+ non_kw_args = last.reject { |k, _| k.is_a?(Symbol) }
367
+ if non_kw_args.empty?
368
+ last.keys
369
+ else
370
+ args << non_kw_args
371
+ last.select { |k, _| k.is_a?(Symbol) }.keys
372
+ end
327
373
  else
328
374
  []
329
375
  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
@@ -217,7 +225,7 @@ module RSpec
217
225
  end
218
226
 
219
227
  def inspect
220
- "#<#{object.class}(#{formatter.format(object.__getobj__)})>"
228
+ "#<#{object.class}(#{formatter.format(object.send(:__getobj__))})>"
221
229
  end
222
230
  end
223
231
 
@@ -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
@@ -74,6 +90,15 @@ module RSpec
74
90
  end
75
91
  end
76
92
 
93
+ if RUBY_VERSION.to_f >= 2.7
94
+ def supports_taint?
95
+ false
96
+ end
97
+ else
98
+ def supports_taint?
99
+ true
100
+ end
101
+ end
77
102
  ripper_requirements = [ComparableVersion.new(RUBY_VERSION) >= '1.9.2']
78
103
 
79
104
  ripper_requirements.push(false) if Ruby.rbx?
@@ -109,7 +134,6 @@ module RSpec
109
134
  end
110
135
  else
111
136
  # RBX / JRuby et al support is unknown for keyword arguments
112
- # rubocop:disable Lint/Eval
113
137
  begin
114
138
  eval("o = Object.new; def o.m(a: 1); end;"\
115
139
  " raise SyntaxError unless o.method(:m).parameters.include?([:key, :a])")
@@ -147,7 +171,6 @@ module RSpec
147
171
  false
148
172
  end
149
173
  end
150
- # rubocop:enable Lint/Eval
151
174
  end
152
175
 
153
176
  def module_refinement_supported?
@@ -59,10 +59,15 @@ module RSpec
59
59
  l =~ %r{bundler/source/rubygems} ||
60
60
  # Ignore bundler + rubygems warning.
61
61
  l =~ %r{site_ruby/\d\.\d\.\d/rubygems} ||
62
+ l =~ %r{jruby-\d\.\d\.\d\.\d/lib/ruby/stdlib/rubygems} ||
62
63
  # This is required for windows for some reason
63
64
  l =~ %r{lib/bundler/rubygems} ||
64
65
  # This is a JRuby file that generates warnings on 9.0.3.0
65
- l =~ %r{lib/ruby/stdlib/jar}
66
+ l =~ %r{lib/ruby/stdlib/jar} ||
67
+ # This is a JRuby file that generates warnings on 9.1.7.0
68
+ l =~ %r{org/jruby/RubyKernel\.java} ||
69
+ # Remove blank lines
70
+ l == "" || l.nil?
66
71
  end.join("\n")
67
72
  end
68
73
 
@@ -38,6 +38,10 @@ module RSpec
38
38
  def write(line)
39
39
  return if line =~ %r{^\S+/gems/\S+:\d+: warning:} # http://rubular.com/r/kqeUIZOfPG
40
40
 
41
+ # Ruby 2.7.0 complains about hashes used in place of keyword arguments
42
+ # Aruba 0.14.2 uses this internally triggering that here
43
+ return if line =~ %r{lib/ruby/2\.7\.0/fileutils\.rb:622: warning:}
44
+
41
45
  @orig_stderr.write(line)
42
46
  @output_tracker.write(line)
43
47
  end
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Support
3
3
  module Version
4
- STRING = '3.7.1'
4
+ STRING = '3.9.1'
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.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
@@ -48,22 +48,8 @@ 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: 2019-12-28 00:00:00.000000000 Z
52
52
  dependencies:
53
- - !ruby/object:Gem::Dependency
54
- name: bundler
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '1.3'
60
- type: :development
61
- prerelease: false
62
- version_requirements: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - "~>"
65
- - !ruby/object:Gem::Version
66
- version: '1.3'
67
53
  - !ruby/object:Gem::Dependency
68
54
  name: rake
69
55
  requirement: !ruby/object:Gem::Requirement
@@ -135,7 +121,12 @@ files:
135
121
  homepage: https://github.com/rspec/rspec-support
136
122
  licenses:
137
123
  - MIT
138
- metadata: {}
124
+ metadata:
125
+ bug_tracker_uri: https://github.com/rspec/rspec-support/issues
126
+ changelog_uri: https://github.com/rspec/rspec-support/blob/v3.9.1/Changelog.md
127
+ documentation_uri: https://rspec.info/documentation/
128
+ mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
129
+ source_code_uri: https://github.com/rspec/rspec-support
139
130
  post_install_message:
140
131
  rdoc_options:
141
132
  - "--charset=UTF-8"
@@ -152,9 +143,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
143
  - !ruby/object:Gem::Version
153
144
  version: '0'
154
145
  requirements: []
155
- rubyforge_project:
156
- rubygems_version: 2.6.13
146
+ rubygems_version: 3.1.2
157
147
  signing_key:
158
148
  specification_version: 4
159
- summary: rspec-support-3.7.1
149
+ summary: rspec-support-3.9.1
160
150
  test_files: []
metadata.gz.sig CHANGED
Binary file