rspec-core 3.10.1 → 3.12.1

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: 5031b8b372bc9b1fa3c64a43825b270ba9af98511dc5309a4aa8a0089e247e6e
4
- data.tar.gz: ad0d74a416bed7deeba63aa52c83729cee3f13f6914f53869c9a282f02576968
3
+ metadata.gz: e01c33b1114655d8891136890c285805fe715c6167fdd8c00985064a179efa73
4
+ data.tar.gz: e11728db974b653edc413b7fdcfa4e63bb4946fbd3735513236e12ae3718916c
5
5
  SHA512:
6
- metadata.gz: 97f252e26aa47ebbffd427c93d91a3286a444c00db88d4ecfe3e01134a786e15c408082cb019df19babfb9fb4dba732c5bcc3cb29c46b12e570d2ce5f348c23c
7
- data.tar.gz: e5daef6dd940e5611c414225013fed21d99c015c71850b9b3f7522aff28334138316275eac5befcc3a87c8b8a928c7eaa208f70f738ea873aa5ea42427ffd1b5
6
+ metadata.gz: c0efeeb10be27c4870f0ef68196bfef4aca0b1c13cb0b3453071ff29a08de0cedcfd0f56d80d90ff71fffee275f30b8089b65fdcdd99398bfe6a16673ba5aff6
7
+ data.tar.gz: 2f8d22e60bbb22e2de141c4cf6d92cd6cccd4ad90d61d862aa35049d5e2d0636a92655800e64577091496df787217eecf433a8138c147e60aa373e8777b0c9a8
checksums.yaml.gz.sig CHANGED
Binary file
data/Changelog.md CHANGED
@@ -1,7 +1,48 @@
1
+ ### Development
2
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.1...3-12-maintenance)
3
+
4
+ ### 3.12.1 / 2023-02-03
5
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.12.0...v3.12.1)
6
+
7
+ Bug fixes:
8
+
9
+ * Prevent multiple calls to `extra_failure_lines` from adding additional whitespace
10
+ around them when the lines already contain whitespace. (Jon Rowe, #3006)
11
+
12
+ ### 3.12.0 / 2022-10-26
13
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.11.0...v3.12.0)
14
+
15
+ * No changes, released to support other gems.
16
+
17
+ ### 3.11.0 / 2022-02-09
18
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.10.2...v3.11.0)
19
+
20
+ Enhancements:
21
+
22
+ * Improve pluralisation of words ending with `s` (like process). (Joshua Pinter, #2779)
23
+ * Add ordering by file modification time (most recent first). (Matheus Richard, #2778)
24
+ * Add `to_s` to reserved names for #let and #subject. (Nick Flückiger, #2886)
25
+ * Introduce `RSpec.current_scope` to expose the current scope in which
26
+ RSpec is executing. e.g. `:before_example_hook`, `:example` etc. (@odinhb, #2895)
27
+ * Add named bold colours as options for custom colours. (#2913, #2914)
28
+ * Warn when (but not prevent) a `SystemExit` occurs. (Jared Beck, #2926)
29
+
30
+ ### 3.10.2 / 2022-01-27
31
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.10.1...v3.10.2)
32
+
33
+ Bug fixes:
34
+
35
+ * Ensure bisect communication uses consistent encoding. (Mike Jarema, #2852)
36
+ * Fix exception presenter when the root cause exception has nil backtrace.
37
+ (Zinovyev Ivan, #2903)
38
+ * Fix `inspect` output of `RSpec::Core::Example::Procsy` to namespace correctly.
39
+ (Keiko Kaneko, #2915)
40
+ * Ensure formatters not exposing `#output` will not crash duplicate check.
41
+ (@niceking, #2916)
42
+
1
43
  ### 3.10.1 / 2020-12-27
2
44
  [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.10.0...v3.10.1)
3
45
 
4
-
5
46
  Bug fixes:
6
47
 
7
48
  * RSpec warning output was missing deprecations from Ruby, these are now included.
@@ -17,7 +58,7 @@ Enhancements:
17
58
  * Add configuration for an error exit code (to disambiguate errored builds from failed builds
18
59
  by exit status). (Dana Sherson, #2749)
19
60
 
20
- # 3.9.3 / 2020-09-30
61
+ ### 3.9.3 / 2020-09-30
21
62
  [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.9.2...v3.9.3)
22
63
 
23
64
  Bug Fixes:
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # rspec-core [![Build Status](https://secure.travis-ci.org/rspec/rspec-core.svg?branch=main)](http://travis-ci.org/rspec/rspec-core) [![Code Climate](https://codeclimate.com/github/rspec/rspec-core.svg)](https://codeclimate.com/github/rspec/rspec-core)
1
+ # rspec-core [![Build Status](https://github.com/rspec/rspec-core/workflows/RSpec%20CI/badge.svg)](https://github.com/rspec/rspec-core/actions) [![Code Climate](https://codeclimate.com/github/rspec/rspec-core.svg)](https://codeclimate.com/github/rspec/rspec-core)
2
2
 
3
3
  rspec-core provides the structure for writing executable examples of how your
4
4
  code should behave, and an `rspec` command with tools to constrain which
@@ -322,14 +322,14 @@ Failures:
322
322
  got: nil
323
323
 
324
324
  (compared using ==)
325
- # ./spec/calcalator_spec.rb:6:in `block (3 levels) in <top (required)>'
325
+ # ./spec/calculator_spec.rb:6:in `block (3 levels) in <top (required)>'
326
326
 
327
327
  Finished in 0.00131 seconds (files took 0.10968 seconds to load)
328
328
  1 example, 1 failure
329
329
 
330
330
  Failed examples:
331
331
 
332
- rspec ./spec/calcalator_spec.rb:5 # Calculator#add returns the sum of its arguments
332
+ rspec ./spec/calculator_spec.rb:5 # Calculator#add returns the sum of its arguments
333
333
  ```
334
334
 
335
335
  Implement the simplest solution, by changing the definition of `Calculator#add` to:
@@ -29,11 +29,22 @@ module RSpec
29
29
  end
30
30
 
31
31
  # Wraps a pipe to support sending objects between a child and
32
- # parent process.
32
+ # parent process. Where supported, encoding is explicitly
33
+ # set to ensure binary data is able to pass from child to
34
+ # parent.
33
35
  # @private
34
36
  class Channel
37
+ if String.method_defined?(:encoding)
38
+ MARSHAL_DUMP_ENCODING = Marshal.dump("").encoding
39
+ end
40
+
35
41
  def initialize
36
42
  @read_io, @write_io = IO.pipe
43
+
44
+ if defined?(MARSHAL_DUMP_ENCODING) && IO.method_defined?(:set_encoding)
45
+ # Ensure the pipe can send any content produced by Marshal.dump
46
+ @write_io.set_encoding MARSHAL_DUMP_ENCODING
47
+ end
37
48
  end
38
49
 
39
50
  def send(message)
@@ -502,7 +502,8 @@ module RSpec
502
502
  # @private
503
503
  attr_reader :backtrace_formatter, :ordering_manager, :loaded_spec_files
504
504
 
505
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
505
+ # rubocop:disable Metrics/AbcSize
506
+ # rubocop:disable Metrics/MethodLength
506
507
 
507
508
  # Build an object to store runtime configuration options and set defaults
508
509
  def initialize
@@ -561,7 +562,8 @@ module RSpec
561
562
 
562
563
  define_built_in_hooks
563
564
  end
564
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
565
+ # rubocop:enable Metrics/AbcSize
566
+ # rubocop:enable Metrics/MethodLength
565
567
 
566
568
  # @private
567
569
  #
@@ -676,7 +678,7 @@ module RSpec
676
678
  end
677
679
 
678
680
  # Set regular expressions used to exclude lines in backtrace.
679
- # @param patterns [Array<Regexp>] set backtrace_formatter exlusion_patterns
681
+ # @param patterns [Array<Regexp>] set backtrace_formatter exclusion_patterns
680
682
  def backtrace_exclusion_patterns=(patterns)
681
683
  @backtrace_formatter.exclusion_patterns = patterns
682
684
  end
@@ -1818,7 +1820,7 @@ module RSpec
1818
1820
  # by not setting `mock_with` or `expect_with` to anything else).
1819
1821
  #
1820
1822
  # @note If the user uses this options with `mock_with :mocha`
1821
- # (or similiar) they will still have monkey patching active
1823
+ # (or similar) they will still have monkey patching active
1822
1824
  # in their test environment from mocha.
1823
1825
  #
1824
1826
  # @example
@@ -2063,10 +2065,13 @@ module RSpec
2063
2065
  return yield if dry_run?
2064
2066
 
2065
2067
  begin
2068
+ RSpec.current_scope = :before_suite_hook
2066
2069
  run_suite_hooks("a `before(:suite)` hook", @before_suite_hooks)
2067
2070
  yield
2068
2071
  ensure
2072
+ RSpec.current_scope = :after_suite_hook
2069
2073
  run_suite_hooks("an `after(:suite)` hook", @after_suite_hooks)
2074
+ RSpec.current_scope = :suite
2070
2075
  end
2071
2076
  end
2072
2077
 
@@ -2119,6 +2124,14 @@ module RSpec
2119
2124
  relative_file = Metadata.relative_path(file)
2120
2125
  reporter.notify_non_example_exception(ex, "An error occurred while loading #{relative_file}.")
2121
2126
  RSpec.world.wants_to_quit = true
2127
+ rescue SystemExit => ex
2128
+ relative_file = Metadata.relative_path(file)
2129
+ reporter.notify_non_example_exception(
2130
+ ex,
2131
+ "While loading #{relative_file} an `exit` / `raise SystemExit` occurred, RSpec will now quit."
2132
+ )
2133
+ RSpec.world.rspec_is_quitting = true
2134
+ raise ex
2122
2135
  end
2123
2136
 
2124
2137
  def handle_suite_hook(scope, meta)
@@ -259,6 +259,7 @@ module RSpec
259
259
  with_around_and_singleton_context_hooks do
260
260
  begin
261
261
  run_before_example
262
+ RSpec.current_scope = :example
262
263
  @example_group_instance.instance_exec(self, &@example_block)
263
264
 
264
265
  if pending?
@@ -278,6 +279,7 @@ module RSpec
278
279
  rescue AllExceptionsExcludingDangerousOnesOnRubiesThatAllowIt => e
279
280
  set_exception(e)
280
281
  ensure
282
+ RSpec.current_scope = :after_example_hook
281
283
  run_after_example
282
284
  end
283
285
  end
@@ -375,7 +377,7 @@ module RSpec
375
377
 
376
378
  # @private
377
379
  def inspect
378
- @example.inspect.gsub('Example', 'ExampleProcsy')
380
+ @example.inspect.gsub('Example', 'Example::Procsy')
379
381
  end
380
382
  end
381
383
 
@@ -462,6 +464,7 @@ module RSpec
462
464
  end
463
465
 
464
466
  def with_around_example_hooks
467
+ RSpec.current_scope = :before_example_hook
465
468
  hooks.run(:around, :example, self) { yield }
466
469
  rescue Support::AllExceptionsExceptOnesWeMustNotRescue => e
467
470
  set_exception(e)
@@ -602,6 +602,7 @@ module RSpec
602
602
 
603
603
  should_run_context_hooks = descendant_filtered_examples.any?
604
604
  begin
605
+ RSpec.current_scope = :before_context_hook
605
606
  run_before_context_hooks(new('before(:context) hook')) if should_run_context_hooks
606
607
  result_for_this_group = run_examples(reporter)
607
608
  results_for_descendants = ordering_strategy.order(children).map { |child| child.run(reporter) }.all?
@@ -614,6 +615,7 @@ module RSpec
614
615
  RSpec.world.wants_to_quit = true if reporter.fail_fast_limit_met?
615
616
  false
616
617
  ensure
618
+ RSpec.current_scope = :after_context_hook
617
619
  run_after_context_hooks(new('after(:context) hook')) if should_run_context_hooks
618
620
  reporter.example_group_finished(self)
619
621
  end
@@ -701,6 +703,7 @@ module RSpec
701
703
  end
702
704
  end
703
705
 
706
+ # @private
704
707
  def initialize(inspect_output=nil)
705
708
  @__inspect_output = inspect_output || '(no description provided)'
706
709
  super() # no args get passed
@@ -782,6 +785,7 @@ module RSpec
782
785
  # @return [String] the location where the shared example was included
783
786
  attr_reader :inclusion_location
784
787
 
788
+ # @private
785
789
  def initialize(shared_group_name, inclusion_location)
786
790
  @shared_group_name = shared_group_name
787
791
  @inclusion_location = inclusion_location
@@ -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
@@ -7,15 +7,23 @@ module RSpec
7
7
  # @private
8
8
  VT100_CODES =
9
9
  {
10
- :black => 30,
11
- :red => 31,
12
- :green => 32,
13
- :yellow => 33,
14
- :blue => 34,
15
- :magenta => 35,
16
- :cyan => 36,
17
- :white => 37,
18
- :bold => 1,
10
+ :black => 30,
11
+ :red => 31,
12
+ :green => 32,
13
+ :yellow => 33,
14
+ :blue => 34,
15
+ :magenta => 35,
16
+ :cyan => 36,
17
+ :white => 37,
18
+ :bold_black => '1;30',
19
+ :bold_red => '1;31',
20
+ :bold_green => '1;32',
21
+ :bold_yellow => '1;33',
22
+ :bold_blue => '1;34',
23
+ :bold_magenta => '1;35',
24
+ :bold_cyan => '1;36',
25
+ :bold_white => '1;37',
26
+ :bold => 1,
19
27
  }
20
28
  # @private
21
29
  VT100_CODE_VALUES = VT100_CODES.invert
@@ -55,7 +55,7 @@ module RSpec
55
55
  cause << " #{line}"
56
56
  end
57
57
 
58
- unless last_cause.backtrace.empty?
58
+ unless last_cause.backtrace.nil? || last_cause.backtrace.empty?
59
59
  cause << (" #{backtrace_formatter.format_backtrace(last_cause.backtrace, example.metadata).first}")
60
60
  end
61
61
  end
@@ -197,8 +197,8 @@ module RSpec
197
197
  @extra_failure_lines ||= begin
198
198
  lines = Array(example.metadata[:extra_failure_lines])
199
199
  unless lines.empty?
200
- lines.unshift('')
201
- lines.push('')
200
+ lines.unshift('') unless lines.first == ''
201
+ lines.push('') unless lines.last == ''
202
202
  end
203
203
  lines
204
204
  end
@@ -242,6 +242,10 @@ module RSpec
242
242
  line_regex = RSpec.configuration.in_project_source_dir_regex
243
243
  loaded_spec_files = RSpec.configuration.loaded_spec_files
244
244
 
245
+ exception_backtrace.reject! do |line|
246
+ line.start_with?("<internal:")
247
+ end
248
+
245
249
  exception_backtrace.find do |line|
246
250
  next unless (line_path = line[/(.+?):(\d+)(|:\d+)/, 1])
247
251
  path = File.expand_path(line_path)
@@ -86,7 +86,15 @@ module RSpec
86
86
  # @param string [String] word to be pluralized
87
87
  # @return [String] pluralized word
88
88
  def self.pluralize(count, string)
89
- "#{count} #{string}#{'s' unless count.to_f == 1}"
89
+ pluralized_string = if count.to_f == 1
90
+ string
91
+ elsif string.end_with?('s') # e.g. "process"
92
+ "#{string}es" # e.g. "processes"
93
+ else
94
+ "#{string}s"
95
+ end
96
+
97
+ "#{count} #{pluralized_string}"
90
98
  end
91
99
 
92
100
  # @api private
@@ -33,10 +33,8 @@ module RSpec
33
33
  "<span class='duration'>#{formatted_run_time}s</span></dd>"
34
34
  end
35
35
 
36
- # rubocop:disable Metrics/ParameterLists
37
36
  def print_example_failed(pending_fixed, description, run_time, failure_id,
38
37
  exception, extra_content)
39
- # rubocop:enable Metrics/ParameterLists
40
38
  formatted_run_time = "%.5f" % run_time
41
39
 
42
40
  @output.puts " <dd class=\"example #{pending_fixed ? 'pending_fixed' : 'failed'}\">"
@@ -215,7 +213,7 @@ function assign_display_style_for_group(classname, display_flag, subgroup_flag)
215
213
  }
216
214
  }
217
215
  EOF
218
- # rubocop:enable LineLength
216
+ # rubocop:enable Layout/LineLength
219
217
 
220
218
  GLOBAL_STYLES = <<-EOF
221
219
  #rspec-header {
@@ -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 = []
@@ -79,7 +79,7 @@ module RSpec::Core::Formatters
79
79
 
80
80
  # Register the formatter class
81
81
  # @param formatter_class [Class] formatter class to register
82
- # @param notifications [Symbol, ...] one or more notifications to be
82
+ # @param notifications [Array<Symbol>] one or more notifications to be
83
83
  # registered to the specified formatter
84
84
  #
85
85
  # @see RSpec::Core::Formatters::BaseFormatter
@@ -194,10 +194,16 @@ module RSpec::Core::Formatters
194
194
 
195
195
  def duplicate_formatter_exists?(new_formatter)
196
196
  @formatters.any? do |formatter|
197
- formatter.class == new_formatter.class && formatter.output == new_formatter.output
197
+ formatter.class == new_formatter.class &&
198
+ has_matching_output?(formatter, new_formatter)
198
199
  end
199
200
  end
200
201
 
202
+ def has_matching_output?(formatter, new_formatter)
203
+ return true unless formatter.respond_to?(:output) && new_formatter.respond_to?(:output)
204
+ formatter.output == new_formatter.output
205
+ end
206
+
201
207
  def existing_formatter_implements?(notification)
202
208
  @reporter.registered_listeners(notification).any?
203
209
  end
@@ -78,6 +78,7 @@ module RSpec
78
78
  # @note If you are using RSpec's newer expect-based syntax you may
79
79
  # want to use `is_expected.to` instead of `should`.
80
80
  def should(matcher=nil, message=nil)
81
+ enforce_value_expectation(matcher, 'should')
81
82
  RSpec::Expectations::PositiveExpectationHandler.handle_matcher(subject, matcher, message)
82
83
  end
83
84
 
@@ -97,6 +98,7 @@ module RSpec
97
98
  # @note If you are using RSpec's newer expect-based syntax you may
98
99
  # want to use `is_expected.to_not` instead of `should_not`.
99
100
  def should_not(matcher=nil, message=nil)
101
+ enforce_value_expectation(matcher, 'should_not')
100
102
  RSpec::Expectations::NegativeExpectationHandler.handle_matcher(subject, matcher, message)
101
103
  end
102
104
 
@@ -144,6 +146,26 @@ module RSpec
144
146
  end
145
147
  end
146
148
 
149
+ # @private
150
+ def enforce_value_expectation(matcher, method_name)
151
+ return if matcher_supports_value_expectations?(matcher)
152
+
153
+ RSpec.deprecate(
154
+ "#{method_name} #{RSpec::Support::ObjectFormatter.format(matcher)}",
155
+ :message =>
156
+ "The implicit block expectation syntax is deprecated, you should pass " \
157
+ "a block to `expect` to use the provided block expectation matcher " \
158
+ "(#{RSpec::Support::ObjectFormatter.format(matcher)}), " \
159
+ "or the matcher must implement `supports_value_expectations?`."
160
+ )
161
+ end
162
+
163
+ def matcher_supports_value_expectations?(matcher)
164
+ matcher.supports_value_expectations?
165
+ rescue
166
+ true
167
+ end
168
+
147
169
  # @private
148
170
  class ThreadsafeMemoized
149
171
  def initialize
@@ -285,9 +307,13 @@ EOS
285
307
  # We have to pass the block directly to `define_method` to
286
308
  # allow it to use method constructs like `super` and `return`.
287
309
  raise "#let or #subject called without a block" if block.nil?
288
- raise(
289
- "#let or #subject called with a reserved name #initialize"
290
- ) if :initialize == name
310
+
311
+ # A list of reserved words that can't be used as a name for a memoized helper
312
+ # Matches for both symbols and passed strings
313
+ if [:initialize, :to_s].include?(name.to_sym)
314
+ raise ArgumentError, "#let or #subject called with reserved name `#{name}`"
315
+ end
316
+
291
317
  our_module = MemoizedHelpers.module_for(self)
292
318
 
293
319
  # If we have a module clash in our helper module
@@ -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
@@ -32,11 +32,10 @@ module RSpec::Core
32
32
 
33
33
  private
34
34
 
35
- # rubocop:disable MethodLength
36
35
  # rubocop:disable Metrics/AbcSize
37
- # rubocop:disable CyclomaticComplexity
38
- # rubocop:disable PerceivedComplexity
39
- # rubocop:disable Metrics/BlockLength
36
+ # rubocop:disable Metrics/MethodLength
37
+ # rubocop:disable Metrics/CyclomaticComplexity
38
+ # rubocop:disable Metrics/PerceivedComplexity
40
39
  def parser(options)
41
40
  OptionParser.new do |parser|
42
41
  parser.summary_width = 34
@@ -58,10 +57,11 @@ module RSpec::Core
58
57
  end
59
58
 
60
59
  parser.on('--order TYPE[:SEED]', 'Run examples by the specified order type.',
61
- ' [defined] examples and groups are run in the order they are defined',
62
- ' [rand] randomize the order of groups and examples',
63
- ' [random] alias for rand',
64
- ' [random:SEED] e.g. --order random:123') do |o|
60
+ ' [defined] examples and groups are run in the order they are defined',
61
+ ' [rand] randomize the order of groups and examples',
62
+ ' [random] alias for rand',
63
+ ' [random:SEED] e.g. --order random:123',
64
+ ' [recently-modified] run the most recently modified files first') do |o|
65
65
  options[:order] = o
66
66
  end
67
67
 
@@ -302,11 +302,10 @@ FILTERING
302
302
  end
303
303
  end
304
304
  end
305
- # rubocop:enable Metrics/BlockLength
306
305
  # rubocop:enable Metrics/AbcSize
307
- # rubocop:enable MethodLength
308
- # rubocop:enable CyclomaticComplexity
309
- # rubocop:enable PerceivedComplexity
306
+ # rubocop:enable Metrics/MethodLength
307
+ # rubocop:enable Metrics/CyclomaticComplexity
308
+ # rubocop:enable Metrics/PerceivedComplexity
310
309
 
311
310
  def add_tag_filter(options, filter_type, tag_name, value=true)
312
311
  (options[filter_type] ||= {})[tag_name] = value
@@ -58,6 +58,14 @@ module RSpec
58
58
  MAX_32_BIT = 4_294_967_295
59
59
  end
60
60
 
61
+ # @private
62
+ # Orders items by modification time (most recent modified first).
63
+ class RecentlyModified
64
+ def order(list)
65
+ list.sort_by { |item| -File.mtime(item.metadata[:absolute_file_path]).to_i }
66
+ end
67
+ end
68
+
61
69
  # @private
62
70
  # Orders items based on a custom block.
63
71
  class Custom
@@ -77,7 +85,8 @@ module RSpec
77
85
  @configuration = configuration
78
86
  @strategies = {}
79
87
 
80
- register(:random, Random.new(configuration))
88
+ register(:random, Random.new(configuration))
89
+ register(:recently_modified, RecentlyModified.new)
81
90
 
82
91
  identity = Identity.new
83
92
  register(:defined, identity)
@@ -132,6 +141,8 @@ module RSpec
132
141
  :random
133
142
  elsif order == 'defined'
134
143
  :defined
144
+ elsif order == 'recently-modified'
145
+ :recently_modified
135
146
  end
136
147
 
137
148
  register_ordering(:global, ordering_registry.fetch(ordering_name)) if ordering_name
@@ -38,7 +38,7 @@ module RSpec
38
38
  # @param message [String] optional message to add to the summary report.
39
39
  #
40
40
  # @example
41
- # describe "an example" do
41
+ # describe "some behaviour" do
42
42
  # # reported as "Pending: no reason given"
43
43
  # it "is pending with no message" do
44
44
  # pending
@@ -52,21 +52,13 @@ module RSpec
52
52
  # end
53
53
  # end
54
54
  #
55
- # @note `before(:example)` hooks are eval'd when you use the `pending`
56
- # method within an example. If you want to declare an example `pending`
57
- # and bypass the `before` hooks as well, you can pass `:pending => true`
58
- # to the `it` method:
59
- #
60
- # it "does something", :pending => true do
61
- # # ...
62
- # end
63
- #
64
- # or pass `:pending => "something else getting finished"` to add a
65
- # message to the summary report:
66
- #
67
- # it "does something", :pending => "something else getting finished" do
68
- # # ...
69
- # end
55
+ # @note When using `pending` inside an example body using this method
56
+ # hooks, such as `before(:example)`, have already be run. This means that
57
+ # a failure from the code in the `before` hook will prevent the example
58
+ # from being considered pending, as the example body would not be
59
+ # executed. If you need to consider hooks as pending as well you can use
60
+ # the pending metadata as an alternative, e.g.
61
+ # `it "does something", pending: "message"`.
70
62
  def pending(message=nil)
71
63
  current_example = RSpec.current_example
72
64
 
@@ -12,7 +12,7 @@
12
12
  # the additional setup, and require it from the spec files that actually need
13
13
  # it.
14
14
  #
15
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
15
+ # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
16
  RSpec.configure do |config|
17
17
  # rspec-expectations config goes here. You can use an alternate
18
18
  # assertion/expectation library such as wrong or the stdlib/minitest
@@ -61,9 +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
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
65
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
66
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
64
+ # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode
67
65
  config.disable_monkey_patching!
68
66
 
69
67
  # This setting enables warnings. It's recommended, but in some cases may
@@ -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.10.1'
6
+ STRING = '3.12.1'
7
7
  end
8
8
  end
9
9
  end
@@ -10,6 +10,13 @@ module RSpec
10
10
  # Used internally to determine what to do when a SIGINT is received.
11
11
  attr_accessor :wants_to_quit
12
12
 
13
+ # Used internally to signify that a SystemExit occurred in
14
+ # `Configuration#load_file_handling_errors`, and thus examples cannot
15
+ # be counted accurately. Specifically, we cannot accurately report
16
+ # "No examples found".
17
+ # @private
18
+ attr_accessor :rspec_is_quitting
19
+
13
20
  # Used internally to signal that a failure outside of an example
14
21
  # has occurred, and that therefore the exit status should indicate
15
22
  # the run failed.
@@ -18,6 +25,7 @@ module RSpec
18
25
 
19
26
  def initialize(configuration=RSpec.configuration)
20
27
  @wants_to_quit = false
28
+ @rspec_is_quitting = false
21
29
  @configuration = configuration
22
30
  configuration.world = self
23
31
  @example_groups = []
@@ -184,10 +192,12 @@ module RSpec
184
192
  return unless example_count.zero?
185
193
 
186
194
  example_groups.clear
187
- if filter_manager.empty?
188
- report_filter_message("No examples found.")
189
- elsif exclusion_filter.empty? || inclusion_filter.empty?
190
- report_filter_message(everything_filtered_message)
195
+ unless rspec_is_quitting
196
+ if filter_manager.empty?
197
+ report_filter_message("No examples found.")
198
+ elsif exclusion_filter.empty? || inclusion_filter.empty?
199
+ report_filter_message(everything_filtered_message)
200
+ end
191
201
  end
192
202
  end
193
203
 
data/lib/rspec/core.rb CHANGED
@@ -129,6 +129,32 @@ module RSpec
129
129
  RSpec::Support.thread_local_data[:current_example] = example
130
130
  end
131
131
 
132
+ # Set the current scope rspec is executing in
133
+ # @api private
134
+ def self.current_scope=(scope)
135
+ RSpec::Support.thread_local_data[:current_scope] = scope
136
+ end
137
+ RSpec.current_scope = :suite
138
+
139
+ # Get the current RSpec execution scope
140
+ #
141
+ # Returns (in order of lifecycle):
142
+ # * `:suite` as an initial value, this is outside of the test lifecycle.
143
+ # * `:before_suite_hook` during `before(:suite)` hooks.
144
+ # * `:before_context_hook` during `before(:context)` hooks.
145
+ # * `:before_example_hook` during `before(:example)` hooks and `around(:example)` before `example.run`.
146
+ # * `:example` within the example run.
147
+ # * `:after_example_hook` during `after(:example)` hooks and `around(:example)` after `example.run`.
148
+ # * `:after_context_hook` during `after(:context)` hooks.
149
+ # * `:after_suite_hook` during `after(:suite)` hooks.
150
+ # * `:suite` as a final value, again this is outside of the test lifecycle.
151
+ #
152
+ # Reminder, `:context` hooks have `:all` alias and `:example` hooks have `:each` alias.
153
+ # @return [Symbol]
154
+ def self.current_scope
155
+ RSpec::Support.thread_local_data[:current_scope]
156
+ end
157
+
132
158
  # @private
133
159
  # Internal container for global non-configuration data.
134
160
  def self.world
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.10.1
4
+ version: 3.12.1
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: 2020-12-27 00:00:00.000000000 Z
49
+ date: 2023-02-03 00:00:00.000000000 Z
50
50
  dependencies:
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: rspec-support
@@ -54,26 +54,26 @@ dependencies:
54
54
  requirements:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: 3.10.0
57
+ version: 3.12.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.10.0
64
+ version: 3.12.0
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: cucumber
67
67
  requirement: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - "~>"
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '1.3'
72
72
  type: :development
73
73
  prerelease: false
74
74
  version_requirements: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - "~>"
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: '1.3'
79
79
  - !ruby/object:Gem::Dependency
@@ -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.10.1/Changelog.md
270
+ changelog_uri: https://github.com/rspec/rspec-core/blob/v3.12.1/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.2.3
290
+ rubygems_version: 3.3.26
291
291
  signing_key:
292
292
  specification_version: 4
293
- summary: rspec-core-3.10.1
293
+ summary: rspec-core-3.12.1
294
294
  test_files: []
metadata.gz.sig CHANGED
Binary file