rspec-core 3.9.2 → 3.10.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
  SHA256:
3
- metadata.gz: 2cc9f19659522abe89f981dabbc306e49bcdc46e4d4093e775ccfc1854a4423c
4
- data.tar.gz: 972c6d305095d83813cea29b0aa13d67b7376ac02b4bc41833e9a1f7a3339dfc
3
+ metadata.gz: 0117b5c68702f84872a6b528a286040ebad81a5201912cf75add518b16391fd8
4
+ data.tar.gz: 6a744e765c464099b304f42223079af2133ee5e278ffa3f3f3c5118f0ccdae54
5
5
  SHA512:
6
- metadata.gz: ca5855df2623196df34c3de4edcfa634e83a3204b3b637a7358b488b92c0c71791512b3da22da8517ab898205b644438187e9fb81846284a1b679537697f05cb
7
- data.tar.gz: 4abca9be9bb867bb3456b6b91ea0b16c8a665e2b4e89dcae0003e435a0e1e7995c63484af9eadbcfdf8454ff955a2b82a3acf180235d06a4f9cc402a5d6fde33
6
+ metadata.gz: d659433a8e529d32ef874d0e6c6d100a5482f1dbb1bcc00a65daccbdfd23fd16307f6938b01fada58609ea828f7215992574dd7fda7f1c2873763f9abbf77574
7
+ data.tar.gz: bdec2aae3e9a5a0c34ccba2bb97a3f4480fa8400f605bb0625b609ebb90a3abf77bfcdbe247f0137d00a2d69f26c3e9ee1565a7a653afe3d14376b3eb97f6ac4
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,30 @@
1
+ ### 3.10.0 / 2020-10-30
2
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.9.3...v3.10.0)
3
+
4
+ Enhancements:
5
+
6
+ * Memoize `RSpec::Core::Formatters::ExceptionPresenter#exception_lines` to improve performance
7
+ with slow exception messages. (Maxime Lapointe, #2743)
8
+ * Add configuration for an error exit code (to disambiguate errored builds from failed builds
9
+ by exit status). (Dana Sherson, #2749)
10
+
11
+ # 3.9.3 / 2020-09-30
12
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.9.2...v3.9.3)
13
+
14
+ Bug Fixes:
15
+
16
+ * Declare `ruby2_keywords` on `method_missing` for other gems. (Jon Rowe, #2731)
17
+ * Ensure custom error codes are returned from bisect runs. (Jon Rowe, #2732)
18
+ * Ensure `RSpec::Core::Configuration` predicate config methods return booleans.
19
+ (Marc-André Lafortune, #2736)
20
+ * Prevent `rspec --bisect` from generating zombie processes while executing
21
+ bisect runs. (Benoit Tigeot, Jon Rowe, #2739)
22
+ * Predicates for pending examples, (in `RSpec::Core::Example`, `#pending?`, `#skipped?` and
23
+ `#pending_fixed?`) now return boolean values rather than truthy values.
24
+ (Marc-André Lafortune, #2756, #2758)
25
+ * Exceptions which have a message which cannot be cast to a string will no longer
26
+ cause a crash. (Jon Rowe, #2761)
27
+
1
28
  ### 3.9.2 / 2020-05-02
2
29
  [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.9.1...v3.9.2)
3
30
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # rspec-core [![Build Status](https://secure.travis-ci.org/rspec/rspec-core.svg?branch=master)](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://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)
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
@@ -10,12 +10,12 @@ examples get run and tailor the output.
10
10
  gem install rspec-core # for rspec-core only
11
11
  rspec --help
12
12
 
13
- Want to run against the `master` branch? You'll need to include the dependent
13
+ Want to run against the `main` branch? You'll need to include the dependent
14
14
  RSpec repos as well. Add the following to your `Gemfile`:
15
15
 
16
16
  ```ruby
17
17
  %w[rspec rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
18
- gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'master'
18
+ gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'main'
19
19
  end
20
20
  ```
21
21
 
@@ -6,7 +6,7 @@ module RSpec
6
6
  module Core
7
7
  module Bisect
8
8
  # A Bisect runner that runs requested subsets of the suite by forking
9
- # sub-processes. The master process bootstraps RSpec and the application
9
+ # sub-processes. The main process bootstraps RSpec and the application
10
10
  # environment (including preloading files specified via `--require`) so
11
11
  # that the individual spec runs do not have to re-pay that cost. Each
12
12
  # spec run happens in a forked process, ensuring that the spec files are
@@ -91,9 +91,12 @@ module RSpec
91
91
  end
92
92
 
93
93
  def dispatch_specs(run_descriptor)
94
- fork { run_specs(run_descriptor) }
94
+ pid = fork { run_specs(run_descriptor) }
95
95
  # We don't use Process.waitpid here as it was causing bisects to
96
- # block due to the file descriptor limit on OSX / Linux.
96
+ # block due to the file descriptor limit on OSX / Linux. We need
97
+ # to detach the process to avoid having zombie processes
98
+ # consuming slots in the kernel process table during bisect runs.
99
+ Process.detach(pid)
97
100
  end
98
101
 
99
102
  private
@@ -67,15 +67,17 @@ module RSpec
67
67
  end
68
68
 
69
69
  # @private
70
- def self.define_aliases(name, alias_name)
70
+ def self.define_alias(name, alias_name)
71
71
  alias_method alias_name, name
72
72
  alias_method "#{alias_name}=", "#{name}="
73
- define_predicate_for alias_name
73
+ define_predicate alias_name
74
74
  end
75
75
 
76
76
  # @private
77
- def self.define_predicate_for(*names)
78
- names.each { |name| alias_method "#{name}?", name }
77
+ def self.define_predicate(name)
78
+ define_method "#{name}?" do
79
+ !!send(name)
80
+ end
79
81
  end
80
82
 
81
83
  # @private
@@ -88,7 +90,7 @@ module RSpec
88
90
  add_read_only_setting name
89
91
 
90
92
  Array(opts[:alias_with]).each do |alias_name|
91
- define_aliases(name, alias_name)
93
+ define_alias(name, alias_name)
92
94
  end
93
95
  end
94
96
 
@@ -98,7 +100,7 @@ module RSpec
98
100
  def self.add_read_only_setting(name, opts={})
99
101
  raise "Use the instance add_setting method if you want to set a default" if opts.key?(:default)
100
102
  define_reader name
101
- define_predicate_for name
103
+ define_predicate name
102
104
  end
103
105
 
104
106
  # @macro [attach] add_setting
@@ -240,6 +242,11 @@ module RSpec
240
242
  # @return [Integer]
241
243
  add_setting :failure_exit_code
242
244
 
245
+ # @macro add_setting
246
+ # The exit code to return if there are any errors outside examples (default: failure_exit_code)
247
+ # @return [Integer]
248
+ add_setting :error_exit_code
249
+
243
250
  # @macro add_setting
244
251
  # Whether or not to fail when there are no RSpec examples (default: false).
245
252
  # @return [Boolean]
@@ -312,7 +319,8 @@ module RSpec
312
319
  # Report the times for the slowest examples (default: `false`).
313
320
  # Use this to specify the number of examples to include in the profile.
314
321
  # @return [Boolean]
315
- add_setting :profile_examples
322
+ attr_writer :profile_examples
323
+ define_predicate :profile_examples
316
324
 
317
325
  # @macro add_setting
318
326
  # Run all examples if none match the configured filters
@@ -520,6 +528,7 @@ module RSpec
520
528
  @pattern = '**{,/*/**}/*_spec.rb'
521
529
  @exclude_pattern = ''
522
530
  @failure_exit_code = 1
531
+ @error_exit_code = nil # so it can be overridden by failure exit code
523
532
  @fail_if_no_examples = false
524
533
  @spec_files_loaded = false
525
534
 
@@ -51,6 +51,7 @@ module RSpec
51
51
  argv << "--order" << @submitted_options[:order] if @submitted_options[:order]
52
52
 
53
53
  add_failure_exit_code(argv)
54
+ add_error_exit_code(argv)
54
55
  add_full_description(argv)
55
56
  add_filter(argv, :inclusion, @filter_manager.inclusions)
56
57
  add_filter(argv, :exclusion, @filter_manager.exclusions)
@@ -67,6 +68,12 @@ module RSpec
67
68
  argv << "--failure-exit-code" << @submitted_options[:failure_exit_code].to_s
68
69
  end
69
70
 
71
+ def add_error_exit_code(argv)
72
+ return unless @submitted_options[:error_exit_code]
73
+
74
+ argv << "--error-exit-code" << @submitted_options[:error_exit_code].to_s
75
+ end
76
+
70
77
  def add_full_description(argv)
71
78
  return unless @submitted_options[:full_description]
72
79
 
@@ -231,8 +231,13 @@ module RSpec
231
231
  @example_group_class
232
232
  end
233
233
 
234
- alias_method :pending?, :pending
235
- alias_method :skipped?, :skip
234
+ def pending?
235
+ !!pending
236
+ end
237
+
238
+ def skipped?
239
+ !!skip
240
+ end
236
241
 
237
242
  # @api private
238
243
  # instance_execs the block passed to the constructor in the context of
@@ -577,7 +582,9 @@ module RSpec
577
582
  # this indicates whether or not it now passes.
578
583
  attr_accessor :pending_fixed
579
584
 
580
- alias pending_fixed? pending_fixed
585
+ def pending_fixed?
586
+ !!pending_fixed
587
+ end
581
588
 
582
589
  # @return [Boolean] Indicates if the example was completely skipped
583
590
  # (typically done via `:skip` metadata or the `skip` method). Skipped examples
@@ -761,8 +761,9 @@ module RSpec
761
761
  "on an example group (e.g. a `describe` or `context` block)."
762
762
  end
763
763
 
764
- super
764
+ super(name, *args)
765
765
  end
766
+ ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)
766
767
  end
767
768
  # rubocop:enable Metrics/ClassLength
768
769
 
@@ -51,7 +51,7 @@ module RSpec
51
51
  cause << '--- Caused by: ---'
52
52
  cause << "#{exception_class_name(last_cause)}:" unless exception_class_name(last_cause) =~ /RSpec/
53
53
 
54
- encoded_string(last_cause.message.to_s).split("\n").each do |line|
54
+ encoded_string(exception_message_string(last_cause)).split("\n").each do |line|
55
55
  cause << " #{line}"
56
56
  end
57
57
 
@@ -174,13 +174,23 @@ module RSpec
174
174
  lines
175
175
  end
176
176
 
177
+ # 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}."
182
+ end
183
+ # rubocop:enable Lint/RescueException
184
+
177
185
  def exception_lines
178
- lines = []
179
- lines << "#{exception_class_name}:" unless exception_class_name =~ /RSpec/
180
- encoded_string(exception.message.to_s).split("\n").each do |line|
181
- lines << (line.empty? ? line : " #{line}")
186
+ @exception_lines ||= begin
187
+ lines = []
188
+ lines << "#{exception_class_name}:" unless exception_class_name =~ /RSpec/
189
+ encoded_string(exception_message_string(exception)).split("\n").each do |line|
190
+ lines << (line.empty? ? line : " #{line}")
191
+ end
192
+ lines
182
193
  end
183
- lines
184
194
  end
185
195
 
186
196
  def extra_failure_lines
@@ -60,9 +60,10 @@ module RSpec
60
60
  # before(:example) # Declared in a parent group.
61
61
  # before(:example) # Declared in the current group.
62
62
  #
63
- # If more than one `before` is declared within any one scope, they are run
64
- # in the order in which they are declared. Any `around` hooks will execute
65
- # later than any `before` hook regardless of scope.
63
+ # If more than one `before` is declared within any one example group, they
64
+ # are run in the order in which they are declared. Any `around` hooks will
65
+ # execute after `before` context hooks but before any `before` example
66
+ # hook regardless of where they are declared.
66
67
  #
67
68
  # ### Conditions
68
69
  #
@@ -263,9 +264,10 @@ module RSpec
263
264
  # after(:suite) # Declared in RSpec.configure.
264
265
  #
265
266
  # This is the reverse of the order in which `before` hooks are run.
266
- # Similarly, if more than one `after` is declared within any one scope,
267
- # they are run in reverse order of that in which they are declared. Also
268
- # `around` hooks will all have run before any after hooks are invoked.
267
+ # Similarly, if more than one `after` is declared within any example
268
+ # group, they are run in reverse order of that in which they are declared.
269
+ # Also `around` hooks will run after any `after` example hooks are
270
+ # invoked but before any `after` context hooks.
269
271
  #
270
272
  # @note The `:example` and `:context` scopes are also available as
271
273
  # `:each` and `:all`, respectively. Use whichever you prefer.
@@ -310,7 +312,7 @@ module RSpec
310
312
  #
311
313
  # @note the syntax of `around` is similar to that of `before` and `after`
312
314
  # but the semantics are quite different. `before` and `after` hooks are
313
- # run in the context of of the examples with which they are associated,
315
+ # run in the context of the examples with which they are associated,
314
316
  # whereas `around` hooks are actually responsible for running the
315
317
  # examples. Consequently, `around` hooks do not have direct access to
316
318
  # resources that are made available within the examples and their
@@ -337,8 +339,11 @@ module RSpec
337
339
  #
338
340
  # ### Order
339
341
  #
340
- # All `around` hooks execute immediately surrounding an example, this means
341
- # that all `before` hooks will have run and no `after` hooks will have run yet.
342
+ # The `around` hooks execute surrounding an example and its hooks.
343
+ #
344
+ # This means after any `before` context hooks, but before any `before`
345
+ # example hooks, and similarly after any `after` example hooks but before
346
+ # any `after` context hooks.
342
347
  #
343
348
  # They are not a synonym for `before`/`after`.
344
349
  def around(*args, &block)
@@ -37,7 +37,7 @@ module RSpec
37
37
  runner, options.args, formatter
38
38
  )
39
39
 
40
- success ? 0 : 1
40
+ runner.exit_code(success)
41
41
  end
42
42
 
43
43
  private
@@ -95,6 +95,11 @@ module RSpec::Core
95
95
  options[:failure_exit_code] = code
96
96
  end
97
97
 
98
+ parser.on('--error-exit-code CODE', Integer,
99
+ 'Override the exit code used when there are errors loading or running specs outside of examples.') do |code|
100
+ options[:error_exit_code] = code
101
+ end
102
+
98
103
  parser.on('-X', '--[no-]drb', 'Run examples via DRb.') do |use_drb|
99
104
  options[:drb] = use_drb
100
105
  options[:runner] = RSpec::Core::Invocations::DRbWithFallback.new if use_drb
@@ -84,7 +84,7 @@ module RSpec
84
84
  # @param out [IO] output stream
85
85
  def run(err, out)
86
86
  setup(err, out)
87
- return @configuration.reporter.exit_early(@configuration.failure_exit_code) if RSpec.world.wants_to_quit
87
+ return @configuration.reporter.exit_early(exit_code) if RSpec.world.wants_to_quit
88
88
 
89
89
  run_specs(@world.ordered_example_groups).tap do
90
90
  persist_example_statuses
@@ -112,7 +112,7 @@ module RSpec
112
112
  # failed.
113
113
  def run_specs(example_groups)
114
114
  examples_count = @world.example_count(example_groups)
115
- success = @configuration.reporter.report(examples_count) do |reporter|
115
+ examples_passed = @configuration.reporter.report(examples_count) do |reporter|
116
116
  @configuration.with_suite_hooks do
117
117
  if examples_count == 0 && @configuration.fail_if_no_examples
118
118
  return @configuration.failure_exit_code
@@ -120,9 +120,9 @@ module RSpec
120
120
 
121
121
  example_groups.map { |g| g.run(reporter) }.all?
122
122
  end
123
- end && !@world.non_example_failure
123
+ end
124
124
 
125
- success ? 0 : @configuration.failure_exit_code
125
+ exit_code(examples_passed)
126
126
  end
127
127
 
128
128
  # @private
@@ -186,6 +186,14 @@ module RSpec
186
186
  end
187
187
  end
188
188
 
189
+ # @private
190
+ def exit_code(examples_passed=false)
191
+ return @configuration.error_exit_code || @configuration.failure_exit_code if @world.non_example_failure
192
+ return @configuration.failure_exit_code unless examples_passed
193
+
194
+ 0
195
+ end
196
+
189
197
  private
190
198
 
191
199
  def persist_example_statuses
@@ -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.9.2'
6
+ STRING = '3.10.0'
7
7
  end
8
8
  end
9
9
  end
@@ -17,6 +17,7 @@ module RSpec
17
17
  attr_accessor :non_example_failure
18
18
 
19
19
  def initialize(configuration=RSpec.configuration)
20
+ @wants_to_quit = false
20
21
  @configuration = configuration
21
22
  configuration.world = self
22
23
  @example_groups = []
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.2
4
+ version: 3.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Baker
8
8
  - David Chelimsky
9
9
  - Chad Humphries
10
10
  - Myron Marston
11
- autorequire:
11
+ autorequire:
12
12
  bindir: exe
13
13
  cert_chain:
14
14
  - |
@@ -46,7 +46,7 @@ cert_chain:
46
46
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
47
47
  F3MdtaDehhjC
48
48
  -----END CERTIFICATE-----
49
- date: 2020-05-02 00:00:00.000000000 Z
49
+ date: 2020-10-30 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.9.3
57
+ version: 3.10.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.9.3
64
+ version: 3.10.0
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: cucumber
67
67
  requirement: !ruby/object:Gem::Requirement
@@ -267,11 +267,11 @@ 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.9.2/Changelog.md
270
+ changelog_uri: https://github.com/rspec/rspec-core/blob/v3.10.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
274
- post_install_message:
274
+ post_install_message:
275
275
  rdoc_options:
276
276
  - "--charset=UTF-8"
277
277
  require_paths:
@@ -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.1.2
291
- signing_key:
290
+ rubygems_version: 3.1.3
291
+ signing_key:
292
292
  specification_version: 4
293
- summary: rspec-core-3.9.2
293
+ summary: rspec-core-3.10.0
294
294
  test_files: []
metadata.gz.sig CHANGED
Binary file