rspec-core 3.7.1 → 3.8.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 (38) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/Changelog.md +29 -0
  5. data/README.md +1 -1
  6. data/lib/rspec/core/bisect/coordinator.rb +26 -30
  7. data/lib/rspec/core/bisect/example_minimizer.rb +12 -8
  8. data/lib/rspec/core/bisect/fork_runner.rb +134 -0
  9. data/lib/rspec/core/bisect/server.rb +4 -13
  10. data/lib/rspec/core/bisect/{runner.rb → shell_command.rb} +27 -70
  11. data/lib/rspec/core/bisect/shell_runner.rb +73 -0
  12. data/lib/rspec/core/bisect/utilities.rb +58 -0
  13. data/lib/rspec/core/configuration.rb +133 -53
  14. data/lib/rspec/core/configuration_options.rb +41 -4
  15. data/lib/rspec/core/example.rb +4 -4
  16. data/lib/rspec/core/example_group.rb +1 -0
  17. data/lib/rspec/core/formatters.rb +10 -6
  18. data/lib/rspec/core/formatters/base_bisect_formatter.rb +45 -0
  19. data/lib/rspec/core/formatters/bisect_drb_formatter.rb +29 -0
  20. data/lib/rspec/core/formatters/bisect_progress_formatter.rb +29 -16
  21. data/lib/rspec/core/formatters/deprecation_formatter.rb +3 -1
  22. data/lib/rspec/core/formatters/exception_presenter.rb +1 -0
  23. data/lib/rspec/core/formatters/html_printer.rb +0 -2
  24. data/lib/rspec/core/formatters/protocol.rb +17 -17
  25. data/lib/rspec/core/formatters/syntax_highlighter.rb +19 -19
  26. data/lib/rspec/core/hooks.rb +1 -3
  27. data/lib/rspec/core/invocations.rb +8 -6
  28. data/lib/rspec/core/memoized_helpers.rb +2 -2
  29. data/lib/rspec/core/profiler.rb +3 -1
  30. data/lib/rspec/core/reporter.rb +3 -6
  31. data/lib/rspec/core/runner.rb +20 -14
  32. data/lib/rspec/core/shared_example_group.rb +1 -3
  33. data/lib/rspec/core/shell_escape.rb +2 -2
  34. data/lib/rspec/core/version.rb +1 -1
  35. data/lib/rspec/core/world.rb +11 -0
  36. metadata +12 -8
  37. metadata.gz.sig +0 -0
  38. data/lib/rspec/core/formatters/bisect_formatter.rb +0 -69
@@ -13,6 +13,25 @@ module RSpec
13
13
  implementation.highlight_syntax(lines)
14
14
  end
15
15
 
16
+ # rubocop:disable Lint/RescueException
17
+ # rubocop:disable Lint/HandleExceptions
18
+ def self.attempt_to_add_rspec_terms_to_coderay_keywords
19
+ CodeRay::Scanners::Ruby::Patterns::IDENT_KIND.add(%w[
20
+ describe context
21
+ it specify
22
+ before after around
23
+ let subject
24
+ expect allow
25
+ ], :keyword)
26
+ rescue Exception
27
+ # Mutating CodeRay's contants like this is not a public API
28
+ # and might not always work. If we cannot add our keywords
29
+ # to CodeRay it is not a big deal and not worth raising an
30
+ # error over, so we ignore it.
31
+ end
32
+ # rubocop:enable Lint/HandleExceptions
33
+ # rubocop:enable Lint/RescueException
34
+
16
35
  private
17
36
 
18
37
  if RSpec::Support::OS.windows?
@@ -38,25 +57,6 @@ module RSpec
38
57
  end
39
58
  end
40
59
 
41
- # rubocop:disable Lint/RescueException
42
- # rubocop:disable Lint/HandleExceptions
43
- def self.attempt_to_add_rspec_terms_to_coderay_keywords
44
- CodeRay::Scanners::Ruby::Patterns::IDENT_KIND.add(%w[
45
- describe context
46
- it specify
47
- before after around
48
- let subject
49
- expect allow
50
- ], :keyword)
51
- rescue Exception
52
- # Mutating CodeRay's contants like this is not a public API
53
- # and might not always work. If we cannot add our keywords
54
- # to CodeRay it is not a big deal and not worth raising an
55
- # error over, so we ignore it.
56
- end
57
- # rubocop:enable Lint/HandleExceptions
58
- # rubocop:enable Lint/RescueException
59
-
60
60
  # @private
61
61
  module CodeRayImplementation
62
62
  RESET_CODE = "\e[0m"
@@ -322,7 +322,7 @@ module RSpec
322
322
  # end
323
323
  #
324
324
  # The yielded example aliases `run` with `call`, which lets you treat it
325
- # like a `Proc`. This is especially handy when working with libaries
325
+ # like a `Proc`. This is especially handy when working with libraries
326
326
  # that manage their own setup and teardown using a block or proc syntax,
327
327
  # e.g.
328
328
  #
@@ -339,8 +339,6 @@ module RSpec
339
339
  @hooks ||= HookCollections.new(self, FilterableItemRepository::UpdateOptimized)
340
340
  end
341
341
 
342
- private
343
-
344
342
  # @private
345
343
  Hook = Struct.new(:block, :options)
346
344
 
@@ -26,21 +26,23 @@ module RSpec
26
26
 
27
27
  # @private
28
28
  class Bisect
29
- def call(options, _err, _out)
29
+ def call(options, err, out)
30
30
  RSpec::Support.require_rspec_core "bisect/coordinator"
31
+ runner = Runner.new(options).tap { |r| r.configure(err, out) }
32
+ formatter = bisect_formatter_klass_for(options.options[:bisect]).new(
33
+ out, runner.configuration.bisect_runner
34
+ )
31
35
 
32
36
  success = RSpec::Core::Bisect::Coordinator.bisect_with(
33
- options.args,
34
- RSpec.configuration,
35
- bisect_formatter_for(options.options[:bisect])
37
+ runner, options.args, formatter
36
38
  )
37
39
 
38
40
  success ? 0 : 1
39
41
  end
40
42
 
41
- private
43
+ private
42
44
 
43
- def bisect_formatter_for(argument)
45
+ def bisect_formatter_klass_for(argument)
44
46
  return Formatters::BisectDebugFormatter if argument == "verbose"
45
47
  Formatters::BisectProgressFormatter
46
48
  end
@@ -483,9 +483,9 @@ EOS
483
483
  def self.module_for(example_group)
484
484
  get_constant_or_yield(example_group, :LetDefinitions) do
485
485
  mod = Module.new do
486
- include Module.new {
486
+ include(Module.new {
487
487
  example_group.const_set(:NamedSubjectPreventSuper, self)
488
- }
488
+ })
489
489
  end
490
490
 
491
491
  example_group.const_set(:LetDefinitions, mod)
@@ -20,7 +20,9 @@ module RSpec
20
20
  def example_group_finished(notification)
21
21
  return unless notification.group.top_level?
22
22
 
23
- @example_groups[notification.group][:total_time] = Time.now - @example_groups[notification.group][:start]
23
+ group = @example_groups[notification.group]
24
+ return unless group.key?(:start)
25
+ group[:total_time] = Time.now - group[:start]
24
26
  end
25
27
 
26
28
  def example_started(notification)
@@ -21,17 +21,12 @@ module RSpec::Core
21
21
  @non_example_exception_count = 0
22
22
  @setup_default = lambda {}
23
23
  @setup = false
24
+ @profiler = nil
24
25
  end
25
26
 
26
27
  # @private
27
28
  attr_reader :examples, :failed_examples, :pending_examples
28
29
 
29
- # @private
30
- def setup_profiler
31
- @profiler = Profiler.new
32
- register_listener @profiler, *Profiler::NOTIFICATIONS
33
- end
34
-
35
30
  # Registers a listener to a list of notifications. The reporter will send
36
31
  # notification of events to all registered listeners.
37
32
  #
@@ -231,6 +226,8 @@ module RSpec::Core
231
226
  return if @setup
232
227
 
233
228
  @setup_default.call
229
+ @profiler = Profiler.new
230
+ register_listener @profiler, *Profiler::NOTIFICATIONS
234
231
  @setup = true
235
232
  end
236
233
 
@@ -94,9 +94,7 @@ module RSpec
94
94
  # @param err [IO] error stream
95
95
  # @param out [IO] output stream
96
96
  def setup(err, out)
97
- @configuration.error_stream = err
98
- @configuration.output_stream = out if @configuration.output_stream == $stdout
99
- @options.configure(@configuration)
97
+ configure(err, out)
100
98
  @configuration.load_spec_files
101
99
  @world.announce_filters
102
100
  end
@@ -122,17 +120,11 @@ module RSpec
122
120
  success ? 0 : @configuration.failure_exit_code
123
121
  end
124
122
 
125
- private
126
-
127
- def persist_example_statuses
128
- return unless (path = @configuration.example_status_persistence_file_path)
129
-
130
- ExampleStatusPersister.persist(@world.all_examples, path)
131
- rescue SystemCallError => e
132
- RSpec.warning "Could not write example statuses to #{path} (configured as " \
133
- "`config.example_status_persistence_file_path`) due to a " \
134
- "system error: #{e.inspect}. Please check that the config " \
135
- "option is set to an accessible, valid file path", :call_site => nil
123
+ # @private
124
+ def configure(err, out)
125
+ @configuration.error_stream = err
126
+ @configuration.output_stream = out if @configuration.output_stream == $stdout
127
+ @options.configure(@configuration)
136
128
  end
137
129
 
138
130
  # @private
@@ -188,6 +180,20 @@ module RSpec
188
180
  $stderr.puts "\nRSpec is shutting down and will print the summary report... Interrupt again to force quit."
189
181
  end
190
182
  end
183
+
184
+ private
185
+
186
+ def persist_example_statuses
187
+ return if @configuration.dry_run
188
+ return unless (path = @configuration.example_status_persistence_file_path)
189
+
190
+ ExampleStatusPersister.persist(@world.all_examples, path)
191
+ rescue SystemCallError => e
192
+ RSpec.warning "Could not write example statuses to #{path} (configured as " \
193
+ "`config.example_status_persistence_file_path`) due to a " \
194
+ "system error: #{e.inspect}. Please check that the config " \
195
+ "option is set to an accessible, valid file path", :call_site => nil
196
+ end
191
197
  end
192
198
  end
193
199
  end
@@ -103,7 +103,6 @@ module RSpec
103
103
  # Shared examples top level DSL.
104
104
  module TopLevelDSL
105
105
  # @private
106
- # rubocop:disable Lint/NestedMethodDefinition
107
106
  def self.definitions
108
107
  proc do
109
108
  def shared_examples(name, *args, &block)
@@ -113,7 +112,6 @@ module RSpec
113
112
  alias shared_examples_for shared_examples
114
113
  end
115
114
  end
116
- # rubocop:enable Lint/NestedMethodDefinition
117
115
 
118
116
  # @private
119
117
  def self.exposed_globally?
@@ -259,7 +257,7 @@ module RSpec
259
257
  # :nocov:
260
258
  def ensure_block_has_source_location(block)
261
259
  source_location = yield.split(':')
262
- block.extend Module.new { define_method(:source_location) { source_location } }
260
+ block.extend(Module.new { define_method(:source_location) { source_location } })
263
261
  end
264
262
  # :nocov:
265
263
  end
@@ -6,7 +6,7 @@ module RSpec
6
6
  module_function
7
7
 
8
8
  def quote(argument)
9
- "'#{argument.gsub("'", "\\\\'")}'"
9
+ "'#{argument.to_s.gsub("'", "\\\\'")}'"
10
10
  end
11
11
 
12
12
  if RSpec::Support::OS.windows?
@@ -17,7 +17,7 @@ module RSpec
17
17
  require 'shellwords'
18
18
 
19
19
  def escape(shell_command)
20
- shell_command.shellescape
20
+ Shellwords.escape(shell_command.to_s)
21
21
  end
22
22
  end
23
23
 
@@ -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.7.1'
6
+ STRING = '3.8.0'
7
7
  end
8
8
  end
9
9
  end
@@ -21,6 +21,17 @@ module RSpec
21
21
  configuration.world = self
22
22
  @example_groups = []
23
23
  @example_group_counts_by_spec_file = Hash.new(0)
24
+ prepare_example_filtering
25
+ end
26
+
27
+ # @api public
28
+ #
29
+ # Prepares filters so that they apply to example groups when they run.
30
+ #
31
+ # This is a separate method so that filters can be modified/replaced and
32
+ # examples refiltered during a process's lifetime, which can be useful for
33
+ # a custom runner.
34
+ def prepare_example_filtering
24
35
  @filtered_examples = Hash.new do |hash, group|
25
36
  hash[group] = filter_manager.prune(group.examples)
26
37
  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.7.1
4
+ version: 3.8.0
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: 2018-01-03 00:00:00.000000000 Z
49
+ date: 2018-08-04 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.7.0
57
+ version: 3.8.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.7.0
64
+ version: 3.8.0
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: cucumber
67
67
  requirement: !ruby/object:Gem::Requirement
@@ -192,8 +192,11 @@ files:
192
192
  - lib/rspec/core/backtrace_formatter.rb
193
193
  - lib/rspec/core/bisect/coordinator.rb
194
194
  - lib/rspec/core/bisect/example_minimizer.rb
195
- - lib/rspec/core/bisect/runner.rb
195
+ - lib/rspec/core/bisect/fork_runner.rb
196
196
  - lib/rspec/core/bisect/server.rb
197
+ - lib/rspec/core/bisect/shell_command.rb
198
+ - lib/rspec/core/bisect/shell_runner.rb
199
+ - lib/rspec/core/bisect/utilities.rb
197
200
  - lib/rspec/core/configuration.rb
198
201
  - lib/rspec/core/configuration_options.rb
199
202
  - lib/rspec/core/drb.rb
@@ -204,9 +207,10 @@ files:
204
207
  - lib/rspec/core/filter_manager.rb
205
208
  - lib/rspec/core/flat_map.rb
206
209
  - lib/rspec/core/formatters.rb
210
+ - lib/rspec/core/formatters/base_bisect_formatter.rb
207
211
  - lib/rspec/core/formatters/base_formatter.rb
208
212
  - lib/rspec/core/formatters/base_text_formatter.rb
209
- - lib/rspec/core/formatters/bisect_formatter.rb
213
+ - lib/rspec/core/formatters/bisect_drb_formatter.rb
210
214
  - lib/rspec/core/formatters/bisect_progress_formatter.rb
211
215
  - lib/rspec/core/formatters/console_codes.rb
212
216
  - lib/rspec/core/formatters/deprecation_formatter.rb
@@ -277,8 +281,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
277
281
  version: '0'
278
282
  requirements: []
279
283
  rubyforge_project:
280
- rubygems_version: 2.7.3
284
+ rubygems_version: 2.6.13
281
285
  signing_key:
282
286
  specification_version: 4
283
- summary: rspec-core-3.7.1
287
+ summary: rspec-core-3.8.0
284
288
  test_files: []
metadata.gz.sig CHANGED
Binary file
@@ -1,69 +0,0 @@
1
- require 'drb/drb'
2
-
3
- module RSpec
4
- module Core
5
- module Formatters
6
- # Used by `--bisect`. When it shells out and runs a portion of the suite, it uses
7
- # this formatter as a means to have the status reported back to it, via DRb.
8
- #
9
- # Note that since DRb calls carry considerable overhead compared to normal
10
- # method calls, we try to minimize the number of DRb calls for perf reasons,
11
- # opting to communicate only at the start and the end of the run, rather than
12
- # after each example.
13
- # @private
14
- class BisectFormatter
15
- Formatters.register self, :start, :start_dump, :example_started,
16
- :example_failed, :example_passed, :example_pending
17
-
18
- def initialize(_output)
19
- port = RSpec.configuration.drb_port
20
- drb_uri = "druby://localhost:#{port}"
21
- @all_example_ids = []
22
- @failed_example_ids = []
23
- @bisect_server = DRbObject.new_with_uri(drb_uri)
24
- @remaining_failures = []
25
- RSpec.configuration.files_or_directories_to_run = @bisect_server.files_or_directories_to_run
26
- end
27
-
28
- def start(_notification)
29
- @remaining_failures = Set.new(@bisect_server.expected_failures)
30
- end
31
-
32
- def example_started(notification)
33
- @all_example_ids << notification.example.id
34
- end
35
-
36
- def example_failed(notification)
37
- @failed_example_ids << notification.example.id
38
- example_finished(notification, :failed)
39
- end
40
-
41
- def example_passed(notification)
42
- example_finished(notification, :passed)
43
- end
44
-
45
- def example_pending(notification)
46
- example_finished(notification, :pending)
47
- end
48
-
49
- def start_dump(_notification)
50
- @bisect_server.latest_run_results = RunResults.new(
51
- @all_example_ids, @failed_example_ids
52
- )
53
- end
54
-
55
- RunResults = Struct.new(:all_example_ids, :failed_example_ids)
56
-
57
- private
58
-
59
- def example_finished(notification, status)
60
- return unless @remaining_failures.include?(notification.example.id)
61
- @remaining_failures.delete(notification.example.id)
62
-
63
- return if status == :failed && !@remaining_failures.empty?
64
- RSpec.world.wants_to_quit = true
65
- end
66
- end
67
- end
68
- end
69
- end