rspec-core 3.6.0.beta2 → 3.7.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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/Changelog.md +48 -0
  5. data/lib/rspec/core.rb +1 -1
  6. data/lib/rspec/core/configuration.rb +34 -9
  7. data/lib/rspec/core/configuration_options.rb +2 -0
  8. data/lib/rspec/core/drb.rb +1 -1
  9. data/lib/rspec/core/example.rb +11 -7
  10. data/lib/rspec/core/example_group.rb +3 -2
  11. data/lib/rspec/core/formatters.rb +14 -4
  12. data/lib/rspec/core/formatters/base_formatter.rb +1 -1
  13. data/lib/rspec/core/formatters/base_text_formatter.rb +3 -4
  14. data/lib/rspec/core/formatters/deprecation_formatter.rb +6 -8
  15. data/lib/rspec/core/formatters/documentation_formatter.rb +1 -1
  16. data/lib/rspec/core/formatters/exception_presenter.rb +3 -2
  17. data/lib/rspec/core/formatters/html_printer.rb +3 -1
  18. data/lib/rspec/core/formatters/html_snippet_extractor.rb +4 -2
  19. data/lib/rspec/core/formatters/json_formatter.rb +9 -3
  20. data/lib/rspec/core/formatters/protocol.rb +3 -2
  21. data/lib/rspec/core/formatters/snippet_extractor.rb +1 -3
  22. data/lib/rspec/core/{source → formatters}/syntax_highlighter.rb +1 -1
  23. data/lib/rspec/core/hooks.rb +3 -1
  24. data/lib/rspec/core/memoized_helpers.rb +3 -0
  25. data/lib/rspec/core/metadata_filter.rb +17 -0
  26. data/lib/rspec/core/notifications.rb +20 -13
  27. data/lib/rspec/core/option_parser.rb +1 -1
  28. data/lib/rspec/core/output_wrapper.rb +29 -0
  29. data/lib/rspec/core/project_initializer/spec/spec_helper.rb +0 -3
  30. data/lib/rspec/core/reporter.rb +17 -8
  31. data/lib/rspec/core/set.rb +5 -0
  32. data/lib/rspec/core/shared_example_group.rb +0 -5
  33. data/lib/rspec/core/version.rb +1 -1
  34. data/lib/rspec/core/world.rb +13 -5
  35. metadata +14 -17
  36. metadata.gz.sig +0 -0
  37. data/lib/rspec/core/source.rb +0 -86
  38. data/lib/rspec/core/source/location.rb +0 -13
  39. data/lib/rspec/core/source/node.rb +0 -93
  40. data/lib/rspec/core/source/token.rb +0 -87
@@ -59,7 +59,9 @@ module RSpec
59
59
  end
60
60
 
61
61
  def print_summary(duration, example_count, failure_count, pending_count)
62
- totals = "#{example_count} example#{'s' unless example_count == 1}, "
62
+ totals = String.new(
63
+ "#{example_count} example#{'s' unless example_count == 1}, "
64
+ )
63
65
  totals << "#{failure_count} failure#{'s' unless failure_count == 1}"
64
66
  totals << ", #{pending_count} pending" if pending_count > 0
65
67
 
@@ -21,11 +21,13 @@ module RSpec
21
21
  end
22
22
 
23
23
  # rubocop:disable Style/ClassVars
24
+ # @private
24
25
  @@converter = NullConverter
26
+
25
27
  begin
26
28
  require 'coderay'
27
- RSpec::Support.require_rspec_core 'source/syntax_highlighter'
28
- RSpec::Core::Source::SyntaxHighlighter.attempt_to_add_rspec_terms_to_coderay_keywords
29
+ RSpec::Support.require_rspec_core 'formatters/syntax_highlighter'
30
+ RSpec::Core::Formatters::SyntaxHighlighter.attempt_to_add_rspec_terms_to_coderay_keywords
29
31
  @@converter = CoderayConverter
30
32
  # rubocop:disable Lint/HandleExceptions
31
33
  rescue LoadError
@@ -6,7 +6,7 @@ module RSpec
6
6
  module Formatters
7
7
  # @private
8
8
  class JsonFormatter < BaseFormatter
9
- Formatters.register self, :message, :dump_summary, :dump_profile, :stop, :close
9
+ Formatters.register self, :message, :dump_summary, :dump_profile, :stop, :seed, :close
10
10
 
11
11
  attr_reader :output_hash
12
12
 
@@ -26,7 +26,8 @@ module RSpec
26
26
  :duration => summary.duration,
27
27
  :example_count => summary.example_count,
28
28
  :failure_count => summary.failure_count,
29
- :pending_count => summary.pending_count
29
+ :pending_count => summary.pending_count,
30
+ :errors_outside_of_examples_count => summary.errors_outside_of_examples_count
30
31
  }
31
32
  @output_hash[:summary_line] = summary.totals_line
32
33
  end
@@ -46,9 +47,13 @@ module RSpec
46
47
  end
47
48
  end
48
49
 
50
+ def seed(notification)
51
+ return unless notification.seed_used?
52
+ @output_hash[:seed] = notification.seed
53
+ end
54
+
49
55
  def close(_notification)
50
56
  output.write @output_hash.to_json
51
- output.close if IO === output && output != $stdout
52
57
  end
53
58
 
54
59
  def dump_profile(profile)
@@ -81,6 +86,7 @@ module RSpec
81
86
 
82
87
  def format_example(example)
83
88
  {
89
+ :id => example.id,
84
90
  :description => example.description,
85
91
  :full_description => example.full_description,
86
92
  :status => example.execution_result.status.to_s,
@@ -171,8 +171,9 @@ module RSpec
171
171
  # @api public
172
172
  # @group Suite Notifications
173
173
  #
174
- # Invoked at the very end, `close` allows the formatter to clean
175
- # up resources, e.g. open streams, etc.
174
+ # Invoked at the end of a suite run. Allows the formatter to do any
175
+ # tidying up, but be aware that formatter output streams may be used
176
+ # elsewhere so don't actually close them.
176
177
  #
177
178
  # @param notification [Notifications::NullNotification]
178
179
  end
@@ -1,5 +1,3 @@
1
- RSpec::Support.require_rspec_core "source"
2
-
3
1
  module RSpec
4
2
  module Core
5
3
  module Formatters
@@ -17,7 +15,7 @@ module RSpec
17
15
 
18
16
  def self.source_from_file(path)
19
17
  raise NoSuchFileError unless File.exist?(path)
20
- RSpec.world.source_cache.source_from_file(path)
18
+ RSpec.world.source_from_file(path)
21
19
  end
22
20
 
23
21
  if RSpec::Support::RubyFeatures.ripper_supported?
@@ -1,6 +1,6 @@
1
1
  module RSpec
2
2
  module Core
3
- class Source
3
+ module Formatters
4
4
  # @private
5
5
  # Provides terminal syntax highlighting of code snippets
6
6
  # when coderay is available.
@@ -456,7 +456,9 @@ module RSpec
456
456
  return if RSpec.configuration.dry_run?
457
457
 
458
458
  if scope == :context
459
- run_owned_hooks_for(position, :context, example_or_group)
459
+ unless example_or_group.class.metadata[:skip]
460
+ run_owned_hooks_for(position, :context, example_or_group)
461
+ end
460
462
  else
461
463
  case position
462
464
  when :before then run_example_hooks_for(example_or_group, :before, :reverse_each)
@@ -285,6 +285,9 @@ EOS
285
285
  # We have to pass the block directly to `define_method` to
286
286
  # allow it to use method constructs like `super` and `return`.
287
287
  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
288
291
  MemoizedHelpers.module_for(self).__send__(:define_method, name, &block)
289
292
 
290
293
  # Apply the memoization. The method has been defined in an ancestor
@@ -111,6 +111,10 @@ module RSpec
111
111
  @items_and_filters.unshift [item, metadata]
112
112
  end
113
113
 
114
+ def delete(item, metadata)
115
+ @items_and_filters.delete [item, metadata]
116
+ end
117
+
114
118
  def items_for(request_meta)
115
119
  @items_and_filters.each_with_object([]) do |(item, item_meta), to_return|
116
120
  to_return << item if item_meta.empty? ||
@@ -167,6 +171,11 @@ module RSpec
167
171
  handle_mutation(metadata)
168
172
  end
169
173
 
174
+ def delete(item, metadata)
175
+ super
176
+ reconstruct_caches
177
+ end
178
+
170
179
  def items_for(metadata)
171
180
  # The filtering of `metadata` to `applicable_metadata` is the key thing
172
181
  # that makes the memoization actually useful in practice, since each
@@ -191,6 +200,14 @@ module RSpec
191
200
 
192
201
  private
193
202
 
203
+ def reconstruct_caches
204
+ @applicable_keys.clear
205
+ @proc_keys.clear
206
+ @items_and_filters.each do |_item, metadata|
207
+ handle_mutation(metadata)
208
+ end
209
+ end
210
+
194
211
  def handle_mutation(metadata)
195
212
  @applicable_keys.merge(metadata.keys)
196
213
  @proc_keys.merge(proc_keys_from metadata)
@@ -111,7 +111,7 @@ module RSpec::Core
111
111
  formatted = "\nFailures:\n"
112
112
 
113
113
  failure_notifications.each_with_index do |failure, index|
114
- formatted << failure.fully_formatted(index.next, colorizer)
114
+ formatted += failure.fully_formatted(index.next, colorizer)
115
115
  end
116
116
 
117
117
  formatted
@@ -120,7 +120,7 @@ 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
- formatted = "\nPending: (Failures listed here are expected and do not affect your suite's status)\n"
123
+ formatted = "\nPending: (Failures listed here are expected and do not affect your suite's status)\n".dup
124
124
 
125
125
  pending_notifications.each_with_index do |notification, index|
126
126
  formatted << notification.fully_formatted(index.next, colorizer)
@@ -232,9 +232,14 @@ module RSpec::Core
232
232
  # RSpec's built-in formatters emit.
233
233
  def fully_formatted(pending_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes)
234
234
  formatted_caller = RSpec.configuration.backtrace_formatter.backtrace_line(example.location)
235
- colorizer.wrap("\n #{pending_number}) #{example.full_description}", :pending) << "\n " <<
236
- Formatters::ExceptionPresenter::PENDING_DETAIL_FORMATTER.call(example, colorizer) <<
237
- "\n" << colorizer.wrap(" # #{formatted_caller}\n", :detail)
235
+
236
+ [
237
+ colorizer.wrap("\n #{pending_number}) #{example.full_description}", :pending),
238
+ "\n ",
239
+ Formatters::ExceptionPresenter::PENDING_DETAIL_FORMATTER.call(example, colorizer),
240
+ "\n",
241
+ colorizer.wrap(" # #{formatted_caller}\n", :detail)
242
+ ].join("")
238
243
  end
239
244
  end
240
245
 
@@ -315,13 +320,15 @@ module RSpec::Core
315
320
  # @api
316
321
  # @return [String] A line summarising the result totals of the spec run.
317
322
  def totals_line
318
- summary = Formatters::Helpers.pluralize(example_count, "example")
319
- summary << ", " << Formatters::Helpers.pluralize(failure_count, "failure")
320
- summary << ", #{pending_count} pending" if pending_count > 0
323
+ summary = Formatters::Helpers.pluralize(example_count, "example") +
324
+ ", " + Formatters::Helpers.pluralize(failure_count, "failure")
325
+ summary += ", #{pending_count} pending" if pending_count > 0
321
326
  if errors_outside_of_examples_count > 0
322
- summary << ", "
323
- summary << Formatters::Helpers.pluralize(errors_outside_of_examples_count, "error")
324
- summary << " occurred outside of examples"
327
+ summary += (
328
+ ", " +
329
+ Formatters::Helpers.pluralize(errors_outside_of_examples_count, "error") +
330
+ " occurred outside of examples"
331
+ )
325
332
  end
326
333
  summary
327
334
  end
@@ -336,7 +343,7 @@ module RSpec::Core
336
343
  # specific colors.
337
344
  # @return [String] A colorized results line.
338
345
  def colorized_totals_line(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
339
- if failure_count > 0
346
+ if failure_count > 0 || errors_outside_of_examples_count > 0
340
347
  colorizer.wrap(totals_line, RSpec.configuration.failure_color)
341
348
  elsif pending_count > 0
342
349
  colorizer.wrap(totals_line, RSpec.configuration.pending_color)
@@ -380,7 +387,7 @@ module RSpec::Core
380
387
  "#{colorized_totals_line(colorizer)}\n"
381
388
 
382
389
  unless failed_examples.empty?
383
- formatted << colorized_rerun_commands(colorizer) << "\n"
390
+ formatted += (colorized_rerun_commands(colorizer) + "\n")
384
391
  end
385
392
 
386
393
  formatted
@@ -201,7 +201,7 @@ FILTERING
201
201
  configure_only_failures(options)
202
202
  end
203
203
 
204
- parser.on("--next-failure", "Apply `--only-failures` and abort after one failure.",
204
+ parser.on("-n", "--next-failure", "Apply `--only-failures` and abort after one failure.",
205
205
  " (Equivalent to `--only-failures --fail-fast --order defined`)") do
206
206
  configure_only_failures(options)
207
207
  set_fail_fast(options, 1)
@@ -0,0 +1,29 @@
1
+ module RSpec
2
+ module Core
3
+ # @private
4
+ class OutputWrapper
5
+ # @private
6
+ attr_accessor :output
7
+
8
+ # @private
9
+ def initialize(output)
10
+ @output = output
11
+ end
12
+
13
+ def respond_to?(name, priv=false)
14
+ output.respond_to?(name, priv)
15
+ end
16
+
17
+ def method_missing(name, *args, &block)
18
+ output.send(name, *args, &block)
19
+ end
20
+
21
+ # Redirect calls for IO interface methods
22
+ IO.instance_methods(false).each do |method|
23
+ define_method(method) do |*args, &block|
24
+ output.send(method, *args, &block)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -12,9 +12,6 @@
12
12
  # the additional setup, and require it from the spec files that actually need
13
13
  # it.
14
14
  #
15
- # The `.rspec` file also contains a few flags that are not defaults but that
16
- # users commonly want.
17
- #
18
15
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
16
  RSpec.configure do |config|
20
17
  # rspec-expectations config goes here. You can use an alternate
@@ -19,19 +19,13 @@ module RSpec::Core
19
19
  @pending_examples = []
20
20
  @duration = @start = @load_time = nil
21
21
  @non_example_exception_count = 0
22
+ @setup_default = lambda {}
23
+ @setup = false
22
24
  end
23
25
 
24
26
  # @private
25
27
  attr_reader :examples, :failed_examples, :pending_examples
26
28
 
27
- # @private
28
- def reset
29
- @examples = []
30
- @failed_examples = []
31
- @pending_examples = []
32
- @profiler = Profiler.new if defined?(@profiler)
33
- end
34
-
35
29
  # @private
36
30
  def setup_profiler
37
31
  @profiler = Profiler.new
@@ -52,6 +46,13 @@ module RSpec::Core
52
46
  true
53
47
  end
54
48
 
49
+ # @private
50
+ def prepare_default(loader, output_stream, deprecation_stream)
51
+ @setup_default = lambda do
52
+ loader.setup_default output_stream, deprecation_stream
53
+ end
54
+ end
55
+
55
56
  # @private
56
57
  def registered_listeners(notification)
57
58
  @listeners[notification].to_a
@@ -200,6 +201,7 @@ module RSpec::Core
200
201
 
201
202
  # @private
202
203
  def notify(event, notification)
204
+ ensure_listeners_ready
203
205
  registered_listeners(event).each do |formatter|
204
206
  formatter.__send__(event, notification)
205
207
  end
@@ -225,6 +227,13 @@ module RSpec::Core
225
227
 
226
228
  private
227
229
 
230
+ def ensure_listeners_ready
231
+ return if @setup
232
+
233
+ @setup_default.call
234
+ @setup = true
235
+ end
236
+
228
237
  def close
229
238
  notify :close, Notifications::NullNotification
230
239
  end
@@ -44,6 +44,11 @@ module RSpec
44
44
  end
45
45
  self
46
46
  end
47
+
48
+ def clear
49
+ @values.clear
50
+ self
51
+ end
47
52
  end
48
53
  end
49
54
  end
@@ -64,11 +64,6 @@ module RSpec
64
64
  # group; any example group or example with matching metadata will
65
65
  # automatically include this shared example group.
66
66
  # @param block The block to be eval'd
67
- # @overload shared_examples(metadata, &block)
68
- # @param metadata [Array<Symbol>, Hash] metadata to attach to this
69
- # group; any example group or example with matching metadata will
70
- # automatically include this shared example group.
71
- # @param block The block to be eval'd
72
67
  #
73
68
  # Stores the block for later use. The block will be evaluated
74
69
  # in the context of an example group via `include_examples`,
@@ -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.6.0.beta2'
6
+ STRING = '3.7.0'
7
7
  end
8
8
  end
9
9
  end
@@ -40,7 +40,8 @@ module RSpec
40
40
  def reset
41
41
  RSpec::ExampleGroups.remove_all_constants
42
42
  example_groups.clear
43
- @shared_example_group_registry = nil
43
+ @sources_by_path.clear if defined?(@sources_by_path)
44
+ @syntax_highlighter = nil
44
45
  end
45
46
 
46
47
  # @private
@@ -129,11 +130,18 @@ module RSpec
129
130
  end
130
131
 
131
132
  # @private
132
- def source_cache
133
- @source_cache ||= begin
134
- RSpec::Support.require_rspec_core "source"
135
- Source::Cache.new(@configuration)
133
+ def source_from_file(path)
134
+ unless defined?(@sources_by_path)
135
+ RSpec::Support.require_rspec_support 'source'
136
+ @sources_by_path = {}
136
137
  end
138
+
139
+ @sources_by_path[path] ||= Support::Source.from_file(path)
140
+ end
141
+
142
+ # @private
143
+ def syntax_highlighter
144
+ @syntax_highlighter ||= Formatters::SyntaxHighlighter.new(@configuration)
137
145
  end
138
146
 
139
147
  # @api private
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.6.0.beta2
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Baker
@@ -46,22 +46,22 @@ cert_chain:
46
46
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
47
47
  F3MdtaDehhjC
48
48
  -----END CERTIFICATE-----
49
- date: 2016-12-12 00:00:00.000000000 Z
49
+ date: 2017-10-17 00:00:00.000000000 Z
50
50
  dependencies:
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: rspec-support
53
53
  requirement: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - '='
55
+ - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: 3.6.0.beta2
57
+ version: 3.7.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.6.0.beta2
64
+ version: 3.7.0
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: cucumber
67
67
  requirement: !ruby/object:Gem::Requirement
@@ -110,14 +110,14 @@ dependencies:
110
110
  requirements:
111
111
  - - "~>"
112
112
  - !ruby/object:Gem::Version
113
- version: 1.0.9
113
+ version: 1.1.1
114
114
  type: :development
115
115
  prerelease: false
116
116
  version_requirements: !ruby/object:Gem::Requirement
117
117
  requirements:
118
118
  - - "~>"
119
119
  - !ruby/object:Gem::Version
120
- version: 1.0.9
120
+ version: 1.1.1
121
121
  - !ruby/object:Gem::Dependency
122
122
  name: mocha
123
123
  requirement: !ruby/object:Gem::Requirement
@@ -222,6 +222,7 @@ files:
222
222
  - lib/rspec/core/formatters/progress_formatter.rb
223
223
  - lib/rspec/core/formatters/protocol.rb
224
224
  - lib/rspec/core/formatters/snippet_extractor.rb
225
+ - lib/rspec/core/formatters/syntax_highlighter.rb
225
226
  - lib/rspec/core/hooks.rb
226
227
  - lib/rspec/core/invocations.rb
227
228
  - lib/rspec/core/memoized_helpers.rb
@@ -236,6 +237,7 @@ files:
236
237
  - lib/rspec/core/notifications.rb
237
238
  - lib/rspec/core/option_parser.rb
238
239
  - lib/rspec/core/ordering.rb
240
+ - lib/rspec/core/output_wrapper.rb
239
241
  - lib/rspec/core/pending.rb
240
242
  - lib/rspec/core/profiler.rb
241
243
  - lib/rspec/core/project_initializer.rb
@@ -250,11 +252,6 @@ files:
250
252
  - lib/rspec/core/shared_context.rb
251
253
  - lib/rspec/core/shared_example_group.rb
252
254
  - lib/rspec/core/shell_escape.rb
253
- - lib/rspec/core/source.rb
254
- - lib/rspec/core/source/location.rb
255
- - lib/rspec/core/source/node.rb
256
- - lib/rspec/core/source/syntax_highlighter.rb
257
- - lib/rspec/core/source/token.rb
258
255
  - lib/rspec/core/test_unit_assertions_adapter.rb
259
256
  - lib/rspec/core/version.rb
260
257
  - lib/rspec/core/warnings.rb
@@ -275,14 +272,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
275
272
  version: 1.8.7
276
273
  required_rubygems_version: !ruby/object:Gem::Requirement
277
274
  requirements:
278
- - - ">"
275
+ - - ">="
279
276
  - !ruby/object:Gem::Version
280
- version: 1.3.1
277
+ version: '0'
281
278
  requirements: []
282
279
  rubyforge_project:
283
- rubygems_version: 2.5.1
280
+ rubygems_version: 2.6.14
284
281
  signing_key:
285
282
  specification_version: 4
286
- summary: rspec-core-3.6.0.beta2
283
+ summary: rspec-core-3.7.0
287
284
  test_files: []
288
285
  has_rdoc: