rspec-core 3.12.0 → 3.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f573a79d2311b74b6d9cdf7f8694856d70aa84037566289b6834c6ca710ecfd0
4
- data.tar.gz: 9ec85ab6c34cf92e45404985f5578241b7a54ebb48a2a13d182493ce9ff31b71
3
+ metadata.gz: 74e1ccff0acb0f5e68bb6ed4c4552b0313d28e348f414d37e09b5741321c6153
4
+ data.tar.gz: 017cac1b0c789c1a75dc9bb782a415608284ef2e9fcaba87087e5745040abeb2
5
5
  SHA512:
6
- metadata.gz: f03be116127209918f11a49536975a5f584185d6b4dd72fb845a8eb270ff0da131ed729a86dc7c8b0205b7d7e6f3a922ff8e01f3118e7a3bfd017d2cdaeea966
7
- data.tar.gz: 24bebf24323887a2534c5fdecdcfdd4c269e10947464cab62ed4f702bd025dd4ea2f9f6725c89d2e9b096f9a5424895f80aac6b250113aabff6f92c1662aeed9
6
+ metadata.gz: e16148576b7e0405cf5de89771fc303a7ae20166250f5d29b5c651bc5a7757a7da183081eccf762050cc85b2e8f2618d7a4104f5957da9e5d6709b17b780d81a
7
+ data.tar.gz: e8a969ee3e5154e6873a5b180ae71a24cc0ae5c62cf5c2642fafab7be5814c2e37987256cbf908421ee1eacfd0ebe0476f254108845df2cdc921cf2fbebd3741
checksums.yaml.gz.sig CHANGED
Binary file
data/Changelog.md CHANGED
@@ -1,5 +1,45 @@
1
1
  ### Development
2
- [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.0...3-12-maintenance)
2
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.3...main)
3
+
4
+ ### 3.13.0 / 2024-02-04
5
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.3...v3.13.0)
6
+
7
+ Enhancements:
8
+
9
+ * Support the `--backtrace` flag when using the JSON formatter. (Matt Larraz, #2980)
10
+ * Ignore commented out lines in CLI config files (e.g. `.rspec`). (Junichi Ito, #2984)
11
+ * Add `pending_failure_output` config option to allow skipping backtraces or
12
+ muting pending specs output. (Phil Pirozhkov, #2957)
13
+ * Process `--dry-run` before configuration flags that read files so that introspecting
14
+ it returns the correct value. (Xenor Chang, #3008)
15
+ * Allow specifying custom ordering strategies via `--order`. (Jon Rowe, #3025)
16
+ * Use the improved `syntax_suggest` output for `SyntaxError` when available.
17
+ (Richard Schneeman, #3015, #3026)
18
+ * Add config option (`RSpec::Core::Configuration#full_cause_backtrace`) to print the
19
+ entire backtrace of an exception cause. (David Taylor, #3046)
20
+
21
+ ### 3.12.3 / 2024-02-04
22
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.2...v3.12.3)
23
+
24
+ Bug fixes:
25
+
26
+ * Use `__send__` in output wrapper to avoid issues with IO objects that implement `send`
27
+ like `Socket`. (Richard Platel, #3045)
28
+
29
+ ### 3.12.2 / 2023-04-18
30
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.1...v3.12.2)
31
+
32
+ Bug fixes:
33
+
34
+ * Remove link to outdated documentation in generated output. (Jon Rowe, #3035)
35
+
36
+ ### 3.12.1 / 2023-02-03
37
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.0...v3.12.1)
38
+
39
+ Bug fixes:
40
+
41
+ * Prevent multiple calls to `extra_failure_lines` from adding additional whitespace
42
+ around them when the lines already contain whitespace. (Jon Rowe, #3006)
3
43
 
4
44
  ### 3.12.0 / 2022-10-26
5
45
  [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.11.0...v3.12.0)
data/README.md CHANGED
@@ -116,6 +116,11 @@ pretty much the same as `shared_examples` and `include_examples`, providing
116
116
  more accurate naming when you share hooks, `let` declarations, helper methods,
117
117
  etc, but no examples.
118
118
 
119
+ If you want to reuse shared examples or contexts across your RSpec suite you can
120
+ define them in a stand alone _*.rb_ files (_spec/support/shared_examples/definition.rb_
121
+ for example). But you will have to manually `require` them (there is no autoloading of
122
+ _spec/support/_ directory unless you set it up yourself).
123
+
119
124
  ## Metadata
120
125
 
121
126
  rspec-core stores a metadata hash with every example and group, which
@@ -322,14 +327,14 @@ Failures:
322
327
  got: nil
323
328
 
324
329
  (compared using ==)
325
- # ./spec/calcalator_spec.rb:6:in `block (3 levels) in <top (required)>'
330
+ # ./spec/calculator_spec.rb:6:in `block (3 levels) in <top (required)>'
326
331
 
327
332
  Finished in 0.00131 seconds (files took 0.10968 seconds to load)
328
333
  1 example, 1 failure
329
334
 
330
335
  Failed examples:
331
336
 
332
- rspec ./spec/calcalator_spec.rb:5 # Calculator#add returns the sum of its arguments
337
+ rspec ./spec/calculator_spec.rb:5 # Calculator#add returns the sum of its arguments
333
338
  ```
334
339
 
335
340
  Implement the simplest solution, by changing the definition of `Calculator#add` to:
@@ -453,11 +453,30 @@ module RSpec
453
453
  add_setting :threadsafe
454
454
 
455
455
  # @macro add_setting
456
- # Maximum count of failed source lines to display in the failure reports.
457
- # (default `10`).
456
+ # Maximum count of failed source lines to display in the failure reports
457
+ # (defaults to `10`).
458
458
  # return [Integer]
459
459
  add_setting :max_displayed_failure_line_count
460
460
 
461
+ # @macro full_cause_backtrace
462
+ # Display the full backtrace of an exceptions cause (defaults to `false`).
463
+ # return [Boolean]
464
+ add_setting :full_cause_backtrace
465
+
466
+ # @macro add_setting
467
+ # Format the output for pending examples. Can be set to:
468
+ # - :full (default) - pending examples appear similarly to failures
469
+ # - :no_backtrace - same as above, but with no backtrace
470
+ # - :skip - do not show the section at all
471
+ # return [Symbol]
472
+ add_read_only_setting :pending_failure_output
473
+ def pending_failure_output=(mode)
474
+ raise ArgumentError,
475
+ "`pending_failure_output` can be set to :full, :no_backtrace, " \
476
+ "or :skip" unless [:full, :no_backtrace, :skip].include?(mode)
477
+ @pending_failure_output = mode
478
+ end
479
+
461
480
  # Determines which bisect runner implementation gets used to run subsets
462
481
  # of the suite during a bisection. Your choices are:
463
482
  #
@@ -557,8 +576,10 @@ module RSpec
557
576
  @derived_metadata_blocks = FilterableItemRepository::QueryOptimized.new(:any?)
558
577
  @threadsafe = true
559
578
  @max_displayed_failure_line_count = 10
579
+ @full_cause_backtrace = false
560
580
  @world = World::Null
561
581
  @shared_context_metadata_behavior = :trigger_inclusion
582
+ @pending_failure_output = :full
562
583
 
563
584
  define_built_in_hooks
564
585
  end
@@ -678,7 +699,7 @@ module RSpec
678
699
  end
679
700
 
680
701
  # Set regular expressions used to exclude lines in backtrace.
681
- # @param patterns [Array<Regexp>] set backtrace_formatter exlusion_patterns
702
+ # @param patterns [Array<Regexp>] set backtrace_formatter exclusion_patterns
682
703
  def backtrace_exclusion_patterns=(patterns)
683
704
  @backtrace_formatter.exclusion_patterns = patterns
684
705
  end
@@ -1820,7 +1841,7 @@ module RSpec
1820
1841
  # by not setting `mock_with` or `expect_with` to anything else).
1821
1842
  #
1822
1843
  # @note If the user uses this options with `mock_with :mocha`
1823
- # (or similiar) they will still have monkey patching active
1844
+ # (or similar) they will still have monkey patching active
1824
1845
  # in their test environment from mocha.
1825
1846
  #
1826
1847
  # @example
@@ -2120,6 +2141,13 @@ module RSpec
2120
2141
  suggestions = DidYouMean.new(relative_file).call
2121
2142
  reporter.notify_non_example_exception(ex, "An error occurred while loading #{relative_file}.#{suggestions}")
2122
2143
  RSpec.world.wants_to_quit = true
2144
+ rescue SyntaxError => ex
2145
+ relative_file = Metadata.relative_path(file)
2146
+ reporter.notify_non_example_exception(
2147
+ ex,
2148
+ "While loading #{relative_file} a `raise SyntaxError` occurred, RSpec will now quit."
2149
+ )
2150
+ RSpec.world.rspec_is_quitting = true
2123
2151
  rescue Support::AllExceptionsExceptOnesWeMustNotRescue => ex
2124
2152
  relative_file = Metadata.relative_path(file)
2125
2153
  reporter.notify_non_example_exception(ex, "An error occurred while loading #{relative_file}.")
@@ -79,6 +79,10 @@ module RSpec
79
79
  # deprecation (or otherwise access the reporter).
80
80
  :deprecation_stream,
81
81
 
82
+ # In order for `RSpec.configuration.dry_run?` to return `true` during
83
+ # processing the `requires` option, it must be parsed before it.
84
+ :dry_run,
85
+
82
86
  # load paths depend on nothing, but must be set before `requires`
83
87
  # to support load-path-relative requires.
84
88
  :libs,
@@ -169,7 +173,8 @@ module RSpec
169
173
  def args_from_options_file(path)
170
174
  return [] unless path && File.exist?(path)
171
175
  config_string = options_file_as_erb_string(path)
172
- FlatMap.flat_map(config_string.split(/\n+/), &:shellsplit)
176
+ config_lines = config_string.split(/\n+/).reject { |s| s =~ /\A\s*#/ }
177
+ FlatMap.flat_map(config_lines, &:shellsplit)
173
178
  end
174
179
 
175
180
  def options_file_as_erb_string(path)
@@ -63,7 +63,7 @@ module RSpec
63
63
  # were loaded but not executed (due to filtering, `--fail-fast`
64
64
  # or whatever) should have a `:status` of `UNKNOWN_STATUS`.
65
65
  #
66
- # This willl produce a new list that:
66
+ # This will produce a new list that:
67
67
  # - Will be missing examples from previous runs that we know for sure
68
68
  # no longer exist.
69
69
  # - Will have the latest known status for any examples that either
@@ -164,7 +164,7 @@ module RSpec
164
164
  end
165
165
 
166
166
  def formatted_value_rows
167
- @foramtted_value_rows ||= rows.map do |row|
167
+ @formatted_value_rows ||= rows.map do |row|
168
168
  formatted_row_from(row)
169
169
  end
170
170
  end
@@ -56,7 +56,12 @@ module RSpec
56
56
  end
57
57
 
58
58
  unless last_cause.backtrace.nil? || last_cause.backtrace.empty?
59
- cause << (" #{backtrace_formatter.format_backtrace(last_cause.backtrace, example.metadata).first}")
59
+ lines = backtrace_formatter.format_backtrace(last_cause.backtrace, example.metadata)
60
+ lines = [lines[0]] unless RSpec.configuration.full_cause_backtrace # rubocop:disable Metrics/BlockNesting
61
+
62
+ lines.each do |line|
63
+ cause << (" #{line}")
64
+ end
60
65
  end
61
66
  end
62
67
 
@@ -175,10 +180,22 @@ module RSpec
175
180
  end
176
181
 
177
182
  # rubocop:disable Lint/RescueException
178
- def exception_message_string(exception)
179
- exception.message.to_s
180
- rescue Exception => other
181
- "A #{exception.class} for which `exception.message.to_s` raises #{other.class}."
183
+ if SyntaxError.instance_methods.include?(:detailed_message)
184
+ def exception_message_string(exception)
185
+ case exception
186
+ when SyntaxError then exception.detailed_message.to_s
187
+ else
188
+ exception.message.to_s
189
+ end
190
+ rescue Exception => other
191
+ "A #{exception.class} for which `exception.message.to_s` raises #{other.class}."
192
+ end
193
+ else
194
+ def exception_message_string(exception)
195
+ exception.message.to_s
196
+ rescue Exception => other
197
+ "A #{exception.class} for which `exception.message.to_s` raises #{other.class}."
198
+ end
182
199
  end
183
200
  # rubocop:enable Lint/RescueException
184
201
 
@@ -197,8 +214,8 @@ module RSpec
197
214
  @extra_failure_lines ||= begin
198
215
  lines = Array(example.metadata[:extra_failure_lines])
199
216
  unless lines.empty?
200
- lines.unshift('')
201
- lines.push('')
217
+ lines.unshift('') unless lines.first == ''
218
+ lines.push('') unless lines.last == ''
202
219
  end
203
220
  lines
204
221
  end
@@ -312,10 +329,14 @@ module RSpec
312
329
  ]
313
330
  }
314
331
  elsif @execution_result.status == :pending
315
- {
332
+ options = {
316
333
  :message_color => RSpec.configuration.pending_color,
317
334
  :detail_formatter => PENDING_DETAIL_FORMATTER
318
335
  }
336
+ if RSpec.configuration.pending_failure_output == :no_backtrace
337
+ options[:backtrace_formatter] = EmptyBacktraceFormatter
338
+ end
339
+ options
319
340
  end
320
341
  end
321
342
 
@@ -43,7 +43,7 @@ module RSpec
43
43
  #
44
44
  # @param backtrace [String] the backtrace from a test failure
45
45
  # @return [String] highlighted code snippet indicating where the test
46
- # failure occured
46
+ # failure occurred
47
47
  #
48
48
  # @see #post_process
49
49
  def snippet(backtrace)
@@ -103,7 +103,7 @@ module RSpec
103
103
  #
104
104
  # @param highlighted [String] syntax-highlighted snippet surrounding the
105
105
  # offending line of code
106
- # @param offending_line [Fixnum] line where failure occured
106
+ # @param offending_line [Fixnum] line where failure occurred
107
107
  # @return [String] completed snippet
108
108
  def post_process(highlighted, offending_line)
109
109
  new_lines = []
@@ -32,15 +32,16 @@ module RSpec
32
32
  @output_hash[:summary_line] = summary.totals_line
33
33
  end
34
34
 
35
- def stop(notification)
36
- @output_hash[:examples] = notification.examples.map do |example|
37
- format_example(example).tap do |hash|
38
- e = example.exception
35
+ def stop(group_notification)
36
+ @output_hash[:examples] = group_notification.notifications.map do |notification|
37
+ format_example(notification.example).tap do |hash|
38
+ e = notification.example.exception
39
+
39
40
  if e
40
- hash[:exception] = {
41
+ hash[:exception] = {
41
42
  :class => e.class.name,
42
43
  :message => e.message,
43
- :backtrace => e.backtrace,
44
+ :backtrace => notification.formatted_backtrace,
44
45
  }
45
46
  end
46
47
  end
@@ -92,7 +92,7 @@ module RSpec
92
92
  #
93
93
  # This is ideal for use by a example or example group, which may
94
94
  # be updated multiple times with globally configured hooks, etc,
95
- # but will not be queried frequently by other examples or examle
95
+ # but will not be queried frequently by other examples or example
96
96
  # groups.
97
97
  # @private
98
98
  class UpdateOptimized
@@ -120,6 +120,8 @@ module RSpec::Core
120
120
  # @return [String] The list of pending examples, fully formatted in the
121
121
  # way that RSpec's built-in formatters emit.
122
122
  def fully_formatted_pending_examples(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
123
+ return if RSpec.configuration.pending_failure_output == :skip
124
+
123
125
  formatted = "\nPending: (Failures listed here are expected and do not affect your suite's status)\n".dup
124
126
 
125
127
  pending_notifications.each_with_index do |notification, index|
@@ -78,6 +78,30 @@ module RSpec
78
78
  end
79
79
  end
80
80
 
81
+ # @private
82
+ # A strategy which delays looking up the ordering until needed
83
+ class Delayed
84
+ def initialize(registry, name)
85
+ @registry = registry
86
+ @name = name
87
+ end
88
+
89
+ def order(list)
90
+ strategy.order(list)
91
+ end
92
+
93
+ private
94
+
95
+ def strategy
96
+ @strategy ||= lookup_strategy
97
+ end
98
+
99
+ def lookup_strategy
100
+ raise "Undefined ordering strategy #{@name.inspect}" unless @registry.has_strategy?(@name)
101
+ @registry.fetch(@name)
102
+ end
103
+ end
104
+
81
105
  # @private
82
106
  # Stores the different ordering strategies.
83
107
  class Registry
@@ -99,6 +123,10 @@ module RSpec
99
123
  @strategies.fetch(name, &fallback)
100
124
  end
101
125
 
126
+ def has_strategy?(name)
127
+ @strategies.key?(name)
128
+ end
129
+
102
130
  def register(sym, strategy)
103
131
  @strategies[sym] = strategy
104
132
  end
@@ -143,9 +171,20 @@ module RSpec
143
171
  :defined
144
172
  elsif order == 'recently-modified'
145
173
  :recently_modified
174
+ else
175
+ order.to_sym
146
176
  end
147
177
 
148
- register_ordering(:global, ordering_registry.fetch(ordering_name)) if ordering_name
178
+ if ordering_name
179
+ strategy =
180
+ if ordering_registry.has_strategy?(ordering_name)
181
+ ordering_registry.fetch(ordering_name)
182
+ else
183
+ Delayed.new(ordering_registry, ordering_name)
184
+ end
185
+
186
+ register_ordering(:global, strategy)
187
+ end
149
188
  end
150
189
 
151
190
  def force(hash)
@@ -15,13 +15,13 @@ module RSpec
15
15
  end
16
16
 
17
17
  def method_missing(name, *args, &block)
18
- output.send(name, *args, &block)
18
+ output.__send__(name, *args, &block)
19
19
  end
20
20
 
21
21
  # Redirect calls for IO interface methods
22
22
  IO.instance_methods(false).each do |method|
23
23
  define_method(method) do |*args, &block|
24
- output.send(method, *args, &block)
24
+ output.__send__(method, *args, &block)
25
25
  end
26
26
  end
27
27
  end
@@ -61,7 +61,7 @@ RSpec.configure do |config|
61
61
 
62
62
  # Limits the available syntax to the non-monkey patched syntax that is
63
63
  # recommended. For more details, see:
64
- # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode
64
+ # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
65
65
  config.disable_monkey_patching!
66
66
 
67
67
  # This setting enables warnings. It's recommended, but in some cases may
@@ -30,7 +30,7 @@ module RSpec::Core
30
30
  # Registers a listener to a list of notifications. The reporter will send
31
31
  # notification of events to all registered listeners.
32
32
  #
33
- # @param listener [Object] An obect that wishes to be notified of reporter
33
+ # @param listener [Object] An object that wishes to be notified of reporter
34
34
  # events
35
35
  # @param notifications [Array] Array of symbols represents the events a
36
36
  # listener wishes to subscribe too
@@ -182,7 +182,11 @@ module RSpec
182
182
  exit!(1)
183
183
  else
184
184
  RSpec.world.wants_to_quit = true
185
- $stderr.puts "\nRSpec is shutting down and will print the summary report... Interrupt again to force quit."
185
+
186
+ $stderr.puts(
187
+ "\nRSpec is shutting down and will print the summary report... Interrupt again to force quit " \
188
+ "(warning: at_exit hooks will be skipped if you force quit)."
189
+ )
186
190
  end
187
191
  end
188
192
 
@@ -3,7 +3,7 @@ module RSpec
3
3
  # Version information for RSpec Core.
4
4
  module Version
5
5
  # Current version of RSpec Core, in semantic versioning format.
6
- STRING = '3.12.0'
6
+ STRING = '3.13.0'
7
7
  end
8
8
  end
9
9
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.12.0
4
+ version: 3.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Baker
@@ -46,7 +46,7 @@ cert_chain:
46
46
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
47
47
  F3MdtaDehhjC
48
48
  -----END CERTIFICATE-----
49
- date: 2022-10-26 00:00:00.000000000 Z
49
+ date: 2024-02-04 00:00:00.000000000 Z
50
50
  dependencies:
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: rspec-support
@@ -54,14 +54,14 @@ dependencies:
54
54
  requirements:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: 3.12.0
57
+ version: 3.13.0
58
58
  type: :runtime
59
59
  prerelease: false
60
60
  version_requirements: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: 3.12.0
64
+ version: 3.13.0
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: cucumber
67
67
  requirement: !ruby/object:Gem::Requirement
@@ -267,7 +267,7 @@ licenses:
267
267
  - MIT
268
268
  metadata:
269
269
  bug_tracker_uri: https://github.com/rspec/rspec-core/issues
270
- changelog_uri: https://github.com/rspec/rspec-core/blob/v3.12.0/Changelog.md
270
+ changelog_uri: https://github.com/rspec/rspec-core/blob/v3.13.0/Changelog.md
271
271
  documentation_uri: https://rspec.info/documentation/
272
272
  mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
273
273
  source_code_uri: https://github.com/rspec/rspec-core
@@ -287,8 +287,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
287
  - !ruby/object:Gem::Version
288
288
  version: '0'
289
289
  requirements: []
290
- rubygems_version: 3.3.3
290
+ rubygems_version: 3.4.10
291
291
  signing_key:
292
292
  specification_version: 4
293
- summary: rspec-core-3.12.0
293
+ summary: rspec-core-3.13.0
294
294
  test_files: []
metadata.gz.sig CHANGED
Binary file