rspec-support 3.7.0 → 3.9.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
- SHA1:
3
- metadata.gz: 97a8c3ef5bd62597387905254a288976a0c64c7a
4
- data.tar.gz: b43e05200a5722ac6b8df8f6e34b1e7b2a30804a
2
+ SHA256:
3
+ metadata.gz: 27ddd84c490aacfced87a3d772c93cf8391484030d28f78789ff5e9263811d42
4
+ data.tar.gz: 515eecb4064c04ac636b6171ad1308532596a13d9b132ac4689893ab76f43bfe
5
5
  SHA512:
6
- metadata.gz: fb1cfe9e1c326894f7a44d40df99e09ae579a39c2dac9dbe2af2e4996e76521d37bb7950f764f16c6a0c5864c384725042df706b9e22d3476628a0384bf47616
7
- data.tar.gz: 8638d927462d2555d0ad2eba87dd5b0abfd3c2379d28430da87d447cccbc0630c75466438b250547994b95da13de042ae688830f109d8d9b6958de8a0ce84faa
6
+ metadata.gz: 3755a83a18dcd1326ac122e8250b0abbe0c50af2e630748478c8dfbf0c0f64f65d59725db3ae5370e382f49409b8f7d1639aa09a75c143d4186a8bfeda36a9e3
7
+ data.tar.gz: 6a41a8e6f905e1c2a37a776a2438d461859aab8434b1cd20c0aa4ca50fb17d898465535710018c8c01c199fde6e179ffef35feb1cd118dc4b71894a0a12d960b
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,7 +1,53 @@
1
- ### Development
2
- [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.0...master)
1
+ ### 3.9.0 / 2019-10-07
3
2
 
4
- ### 3.7.0 / 2017-05-04
3
+ *NO CHANGES*
4
+
5
+ Version 3.9.0 was released to allow other RSpec gems to release 3.9.0.
6
+
7
+ ### 3.8.3 / 2019-10-02
8
+
9
+ Bug Fixes:
10
+
11
+ * Escape \r when outputting strings inside arrays.
12
+ (Tomita Masahiro, Jon Rowe, #378)
13
+ * Ensure that optional hash arguments are recognised correctly vs keyword
14
+ arguments. (Evgeni Dzhelyov, #366)
15
+
16
+ ### 3.8.2 / 2019-06-10
17
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.1...v3.8.2)
18
+
19
+ Bug Fixes:
20
+
21
+ * Ensure that an empty hash is recognised as empty keyword arguments when
22
+ applicable. (Thomas Walpole, #375)
23
+ * Ensure that diffing truthy values produce diffs consistently.
24
+ (Lucas Nestor, #377)
25
+
26
+ ### 3.8.1 / 2019-03-03
27
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.8.0...v3.8.1)
28
+
29
+ Bug Fixes:
30
+
31
+ * Ensure that inspecting a `SimpleDelegator` based object works regardless of
32
+ visibilty of the `__getobj__` method. (Jon Rowe, #369)
33
+
34
+ ### 3.8.0 / 2018-08-04
35
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.1...v3.8.0)
36
+
37
+ Bug Fixes:
38
+
39
+ * Order hash keys before diffing to improve diff accuracy when using mocked calls.
40
+ (James Crisp, #334)
41
+
42
+ ### 3.7.1 / 2018-01-29
43
+ [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.7.0...v3.7.1)
44
+
45
+ Bug Fixes:
46
+
47
+ * Fix source extraction logic so that it does not trigger a `SystemStackError`
48
+ when processing deeply nested example groups. (Craig Bass, #343)
49
+
50
+ ### 3.7.0 / 2017-10-17
5
51
  [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.6.0...v3.7.0)
6
52
 
7
53
  Enhancements:
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
@@ -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
@@ -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?
@@ -45,13 +45,16 @@ module RSpec
45
45
  @location ||= args.find { |arg| arg.is_a?(Location) }
46
46
  end
47
47
 
48
- def each(&block)
48
+ # We use a loop here (instead of recursion) to prevent SystemStackError
49
+ def each
49
50
  return to_enum(__method__) unless block_given?
50
51
 
51
- yield self
52
+ node_queue = []
53
+ node_queue << self
52
54
 
53
- children.each do |child|
54
- child.each(&block)
55
+ while (current_node = node_queue.shift)
56
+ yield current_node
57
+ node_queue.concat(current_node.children)
55
58
  end
56
59
  end
57
60
 
@@ -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
 
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Support
3
3
  module Version
4
- STRING = '3.7.0'
4
+ STRING = '3.9.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.0
4
+ version: 3.9.0
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: 2017-10-17 00:00:00.000000000 Z
51
+ date: 2019-10-07 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.0/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.14
146
+ rubygems_version: 3.0.6
157
147
  signing_key:
158
148
  specification_version: 4
159
- summary: rspec-support-3.7.0
149
+ summary: rspec-support-3.9.0
160
150
  test_files: []
metadata.gz.sig CHANGED
Binary file