rspec-core 3.5.2 → 3.5.4

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: 5dc4950a038b0b14b369336c70d967455853128a
4
+ data.tar.gz: 2b2dcb195a0493c6876dbeceb8d6a8adfd643283
5
5
  SHA512:
6
- metadata.gz: 61c37f52ef3408f9c4a6813708fb6e5785a87e8d610e25398b0a1ab0264de42afd008f1ff621d55b253b59718cf52a29862458fdc7db55647d6d91704be3d6cf
7
- data.tar.gz: d1baf10d2a985bff5b8b9af2ed77be391c0a30ff77ced7b13d4b837b78c4b6c263c7de3b61878282734d3c06ee51ff09643a27549b3f6c81ce5c045e420e9131
6
+ metadata.gz: 6cffc5f291e3a7187971a0da4fc6d9900b3022717dbbc4787843510362e6876914e0785011b2e91de4d0a2d48061866b1127acba386be59d00cc157243e6d8f1
7
+ data.tar.gz: 8a347a71f03c00256b9725fa300ea3fdb23999adf48f1984ce144bbbfff08d830dc5f9391a4930afe8f9ce8981efc5a1c59caea6ae5fd79fbff0498dc124b93d
checksums.yaml.gz.sig CHANGED
Binary file
data/Changelog.md CHANGED
@@ -1,3 +1,25 @@
1
+ ### 3.5.4 / 2016-09-30
2
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.5.3...v3.5.4)
3
+
4
+ Bug Fixes:
5
+
6
+ * Remove accumulated `ExampleGroup` constants when reseting RSpec,
7
+ preventing a memory leak. (TravisSpangle, #2328)
8
+
9
+ ### 3.5.3 / 2016-09-02
10
+ [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.5.2...v3.5.3)
11
+
12
+ Bug Fixes:
13
+
14
+ * When applying shared group metadata to a host group, overwrite
15
+ conflicting keys if the value in the host group was inherited from
16
+ a parent group instead of being specified at that level.
17
+ (Myron Marston, #2307)
18
+ * Handle errors in `:suite` hooks and provide the same nicely formatted
19
+ output as errors that happen in examples. (Myron Marston, #2316)
20
+ * Set the exit status to non-zero when an error occurs in an
21
+ `after(:context)` hook. (Myron Marston, #2320)
22
+
1
23
  ### 3.5.2 / 2016-07-28
2
24
  [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.5.1...v3.5.2)
3
25
 
@@ -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)
@@ -827,6 +827,12 @@ module RSpec
827
827
  const_scope
828
828
  end
829
829
 
830
+ def self.remove_all_constants
831
+ constants.each do |constant|
832
+ __send__(:remove_const, constant)
833
+ end
834
+ end
835
+
830
836
  def self.base_name_for(group)
831
837
  return "Anonymous" if group.description.empty?
832
838
 
@@ -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
@@ -93,11 +93,6 @@ module RSpec::Core
93
93
  options[:failure_exit_code] = code
94
94
  end
95
95
 
96
- parser.on('--dry-run', 'Print the formatter output of your suite without',
97
- ' running any examples or hooks') do |_o|
98
- options[:dry_run] = true
99
- end
100
-
101
96
  parser.on('-X', '--[no-]drb', 'Run examples via DRb.') do |use_drb|
102
97
  options[:drb] = use_drb
103
98
  options[:runner] = RSpec::Core::Invocations::DRbWithFallback.new if use_drb
@@ -107,10 +102,6 @@ module RSpec::Core
107
102
  options[:drb_port] = o.to_i
108
103
  end
109
104
 
110
- parser.on('--init', 'Initialize your project with RSpec.') do |_cmd|
111
- options[:runner] = RSpec::Core::Invocations::InitializeProject.new
112
- end
113
-
114
105
  parser.separator("\n **** Output ****\n\n")
115
106
 
116
107
  parser.on('-f', '--format FORMATTER', 'Choose a formatter.',
@@ -163,6 +154,11 @@ module RSpec::Core
163
154
  end
164
155
  end
165
156
 
157
+ parser.on('--dry-run', 'Print the formatter output of your suite without',
158
+ ' running any examples or hooks') do |_o|
159
+ options[:dry_run] = true
160
+ end
161
+
166
162
  parser.on('-w', '--warnings', 'Enable ruby warnings') do
167
163
  $VERBOSE = true
168
164
  end
@@ -244,6 +240,10 @@ FILTERING
244
240
 
245
241
  parser.separator("\n **** Utility ****\n\n")
246
242
 
243
+ parser.on('--init', 'Initialize your project with RSpec.') do |_cmd|
244
+ options[:runner] = RSpec::Core::Invocations::InitializeProject.new
245
+ end
246
+
247
247
  parser.on('-v', '--version', 'Display the version.') do
248
248
  options[:runner] = RSpec::Core::Invocations::PrintVersion.new
249
249
  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.4'
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
@@ -32,6 +38,7 @@ module RSpec
32
38
  #
33
39
  # Reset world to 'scratch' before running suite.
34
40
  def reset
41
+ RSpec::ExampleGroups.remove_all_constants
35
42
  example_groups.clear
36
43
  @shared_example_group_registry = nil
37
44
  end
@@ -224,6 +231,9 @@ module RSpec
224
231
  # @private
225
232
  # Provides a null implementation for initial use by configuration.
226
233
  module Null
234
+ def self.non_example_failure; end
235
+ def self.non_example_failure=(_); end
236
+
227
237
  def self.registered_example_group_files
228
238
  []
229
239
  end
data/lib/rspec/core.rb CHANGED
@@ -56,6 +56,7 @@ module RSpec
56
56
  # they use the runner multiple times within the same process. Users must deal
57
57
  # themselves with re-configuration of RSpec before run.
58
58
  def self.reset
59
+ RSpec::ExampleGroups.remove_all_constants
59
60
  @world = nil
60
61
  @configuration = nil
61
62
  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.5.2
4
+ version: 3.5.4
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-10-01 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.4
287
287
  test_files: []
288
288
  has_rdoc:
metadata.gz.sig CHANGED
Binary file