rspec-core 3.5.2 → 3.5.3

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
  SHA1:
3
- metadata.gz: cec44daa280723490f842a4f70fc2155a28379c0
4
- data.tar.gz: 3d74dfc5863a12e75a5d5ff591ecdba51f399489
3
+ metadata.gz: c9ac822b43683de914c3aa410444eb1c169d0f2d
4
+ data.tar.gz: ac809f4a29ae13c01faf12e9da68cebb52382be0
5
5
  SHA512:
6
- metadata.gz: 61c37f52ef3408f9c4a6813708fb6e5785a87e8d610e25398b0a1ab0264de42afd008f1ff621d55b253b59718cf52a29862458fdc7db55647d6d91704be3d6cf
7
- data.tar.gz: d1baf10d2a985bff5b8b9af2ed77be391c0a30ff77ced7b13d4b837b78c4b6c263c7de3b61878282734d3c06ee51ff09643a27549b3f6c81ce5c045e420e9131
6
+ metadata.gz: 810b2232c50232d568af42436cb1b81dc5b109b9534f8d82a554a069713ce23b0775f8c24eb9edb42f9b51590db57804fe0d2dce55a5af473da81c4dd94b9c9f
7
+ data.tar.gz: a0e5e3b3f939ac9518d3b527b40e576ea221f80b66f37fada8f122f960b1720035330fa6c28c3ca583f19ba60ef117ca16a8d0ac15750228d0fe71b0e53d26e1
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,17 @@
1
+ ### 3.5.3 / 2016-09-02
2
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.5.2...v3.5.3)
3
+
4
+ Bug Fixes:
5
+
6
+ * When applying shared group metadata to a host group, overwrite
7
+ conflicting keys if the value in the host group was inherited from
8
+ a parent group instead of being specified at that level.
9
+ (Myron Marston, #2307)
10
+ * Handle errors in `:suite` hooks and provide the same nicely formatted
11
+ output as errors that happen in examples. (Myron Marston, #2316)
12
+ * Set the exit status to non-zero when an error occurs in an
13
+ `after(:context)` hook. (Myron Marston, #2320)
14
+
1
15
  ### 3.5.2 / 2016-07-28
2
16
  [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.5.1...v3.5.2)
3
17
 
@@ -1830,12 +1830,11 @@ module RSpec
1830
1830
  def with_suite_hooks
1831
1831
  return yield if dry_run?
1832
1832
 
1833
- hook_context = SuiteHookContext.new
1834
1833
  begin
1835
- run_hooks_with(@before_suite_hooks, hook_context)
1834
+ run_suite_hooks("a `before(:suite)` hook", @before_suite_hooks)
1836
1835
  yield
1837
1836
  ensure
1838
- run_hooks_with(@after_suite_hooks, hook_context)
1837
+ run_suite_hooks("an `after(:suite)` hook", @after_suite_hooks)
1839
1838
  end
1840
1839
  end
1841
1840
 
@@ -1875,8 +1874,16 @@ module RSpec
1875
1874
  yield
1876
1875
  end
1877
1876
 
1878
- def run_hooks_with(hooks, hook_context)
1879
- hooks.each { |h| h.run(hook_context) }
1877
+ def run_suite_hooks(hook_description, hooks)
1878
+ context = SuiteHookContext.new(hook_description, reporter)
1879
+
1880
+ hooks.each do |hook|
1881
+ begin
1882
+ hook.run(context)
1883
+ rescue Support::AllExceptionsExceptOnesWeMustNotRescue => ex
1884
+ context.set_exception(ex)
1885
+ end
1886
+ end
1880
1887
  end
1881
1888
 
1882
1889
  def get_files_to_run(paths)
@@ -632,16 +632,16 @@ module RSpec
632
632
  # @private
633
633
  # Provides an execution context for before/after :suite hooks.
634
634
  class SuiteHookContext < Example
635
- def initialize
636
- super(AnonymousExampleGroup, "", {})
635
+ def initialize(hook_description, reporter)
636
+ super(AnonymousExampleGroup, hook_description, {})
637
637
  @example_group_instance = AnonymousExampleGroup.new
638
+ @reporter = reporter
638
639
  end
639
640
 
640
641
  # rubocop:disable Style/AccessorMethodName
641
-
642
- # To ensure we don't silence errors.
643
642
  def set_exception(exception)
644
- raise exception
643
+ reporter.notify_non_example_exception(exception, "An error occurred in #{description}.")
644
+ RSpec.world.wants_to_quit = true
645
645
  end
646
646
  # rubocop:enable Style/AccessorMethodName
647
647
  end
@@ -415,10 +415,10 @@ module RSpec
415
415
  # not be applied where they should.
416
416
  registration_collection << self
417
417
 
418
- user_metadata = Metadata.build_hash_from(args)
418
+ @user_metadata = Metadata.build_hash_from(args)
419
419
 
420
420
  @metadata = Metadata::ExampleGroupHash.create(
421
- superclass_metadata, user_metadata,
421
+ superclass_metadata, @user_metadata,
422
422
  superclass.method(:next_runnable_index_for),
423
423
  description, *args, &example_group_block
424
424
  )
@@ -705,8 +705,8 @@ module RSpec
705
705
 
706
706
  # @private
707
707
  def self.update_inherited_metadata(updates)
708
- metadata.update(updates) do |_key, existing_group_value, _new_inherited_value|
709
- existing_group_value
708
+ metadata.update(updates) do |key, existing_group_value, new_inherited_value|
709
+ @user_metadata.key?(key) ? existing_group_value : new_inherited_value
710
710
  end
711
711
 
712
712
  RSpec.configuration.configure_group(self)
@@ -122,7 +122,8 @@ module RSpec
122
122
  end
123
123
 
124
124
  def indent_lines(lines, failure_number)
125
- alignment_basis = "#{' ' * @indentation}#{failure_number}) "
125
+ alignment_basis = ' ' * @indentation
126
+ alignment_basis << "#{failure_number}) " if failure_number
126
127
  indentation = ' ' * alignment_basis.length
127
128
 
128
129
  lines.each_with_index.map do |line, index|
@@ -365,14 +365,7 @@ module RSpec
365
365
  def run(example)
366
366
  example.instance_exec(example, &block)
367
367
  rescue Support::AllExceptionsExceptOnesWeMustNotRescue => e
368
- # TODO: Come up with a better solution for this.
369
- RSpec.configuration.reporter.message <<-EOS
370
-
371
- An error occurred in an `after(:context)` hook.
372
- #{e.class}: #{e.message}
373
- occurred at #{e.backtrace.first}
374
-
375
- EOS
368
+ RSpec.configuration.reporter.notify_non_example_exception(e, "An error occurred in an `after(:context)` hook.")
376
369
  end
377
370
  end
378
371
 
@@ -178,6 +178,7 @@ module RSpec
178
178
 
179
179
  def build_description_from(parent_description=nil, my_description=nil)
180
180
  return parent_description.to_s unless my_description
181
+ return my_description.to_s if parent_description.to_s == ''
181
182
  separator = description_separator(parent_description, my_description)
182
183
  (parent_description.to_s + separator) << my_description.to_s
183
184
  end
@@ -51,8 +51,7 @@ module RSpec::Core
51
51
  FailedExampleNotification
52
52
  end
53
53
 
54
- exception_presenter = Formatters::ExceptionPresenter::Factory.new(example).build
55
- klass.new(example, exception_presenter)
54
+ klass.new(example)
56
55
  end
57
56
 
58
57
  private_class_method :new
@@ -202,7 +201,7 @@ module RSpec::Core
202
201
 
203
202
  private
204
203
 
205
- def initialize(example, exception_presenter)
204
+ def initialize(example, exception_presenter=Formatters::ExceptionPresenter::Factory.new(example).build)
206
205
  @exception_presenter = exception_presenter
207
206
  super(example)
208
207
  end
@@ -151,6 +151,18 @@ module RSpec::Core
151
151
  notify :deprecation, Notifications::DeprecationNotification.from_hash(hash)
152
152
  end
153
153
 
154
+ # @private
155
+ # Provides a way to notify of an exception that is not tied to any
156
+ # particular exception (such as an exception encountered in a :suite hook).
157
+ # Exceptions will be formatted the same way they normally are.
158
+ def notify_non_example_exception(exception, context_description)
159
+ @configuration.world.non_example_failure = true
160
+
161
+ example = Example.new(AnonymousExampleGroup, context_description, {})
162
+ presenter = Formatters::ExceptionPresenter.new(exception, example, :indentation => 0)
163
+ message presenter.fully_formatted(nil)
164
+ end
165
+
154
166
  # @private
155
167
  def finish
156
168
  close_after do
@@ -108,11 +108,13 @@ module RSpec
108
108
  # or the configured failure exit code (1 by default) if specs
109
109
  # failed.
110
110
  def run_specs(example_groups)
111
- @configuration.reporter.report(@world.example_count(example_groups)) do |reporter|
111
+ success = @configuration.reporter.report(@world.example_count(example_groups)) do |reporter|
112
112
  @configuration.with_suite_hooks do
113
- example_groups.map { |g| g.run(reporter) }.all? ? 0 : @configuration.failure_exit_code
113
+ example_groups.map { |g| g.run(reporter) }.all?
114
114
  end
115
- end
115
+ end && !@world.non_example_failure
116
+
117
+ success ? 0 : @configuration.failure_exit_code
116
118
  end
117
119
 
118
120
  private
@@ -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.5.2'
6
+ STRING = '3.5.3'
7
7
  end
8
8
  end
9
9
  end
@@ -10,6 +10,12 @@ 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 signal that a failure outside of an example
14
+ # has occurred, and that therefore the exit status should indicate
15
+ # the run failed.
16
+ # @private
17
+ attr_accessor :non_example_failure
18
+
13
19
  def initialize(configuration=RSpec.configuration)
14
20
  @configuration = configuration
15
21
  configuration.world = self
@@ -224,6 +230,9 @@ module RSpec
224
230
  # @private
225
231
  # Provides a null implementation for initial use by configuration.
226
232
  module Null
233
+ def self.non_example_failure; end
234
+ def self.non_example_failure=(_); end
235
+
227
236
  def self.registered_example_group_files
228
237
  []
229
238
  end
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.5.2
4
+ version: 3.5.3
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: 2016-07-28 00:00:00.000000000 Z
49
+ date: 2016-09-02 00:00:00.000000000 Z
50
50
  dependencies:
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: rspec-support
@@ -283,6 +283,6 @@ rubyforge_project:
283
283
  rubygems_version: 2.2.2
284
284
  signing_key:
285
285
  specification_version: 4
286
- summary: rspec-core-3.5.2
286
+ summary: rspec-core-3.5.3
287
287
  test_files: []
288
288
  has_rdoc:
metadata.gz.sig CHANGED
Binary file