rspec-core 3.7.1 → 3.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) 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 +116 -0
  5. data/README.md +18 -18
  6. data/lib/rspec/core.rb +1 -0
  7. data/lib/rspec/core/bisect/coordinator.rb +26 -30
  8. data/lib/rspec/core/bisect/example_minimizer.rb +12 -8
  9. data/lib/rspec/core/bisect/fork_runner.rb +138 -0
  10. data/lib/rspec/core/bisect/server.rb +5 -14
  11. data/lib/rspec/core/bisect/{runner.rb → shell_command.rb} +27 -70
  12. data/lib/rspec/core/bisect/shell_runner.rb +73 -0
  13. data/lib/rspec/core/bisect/utilities.rb +58 -0
  14. data/lib/rspec/core/configuration.rb +236 -79
  15. data/lib/rspec/core/configuration_options.rb +41 -4
  16. data/lib/rspec/core/did_you_mean.rb +46 -0
  17. data/lib/rspec/core/example.rb +18 -8
  18. data/lib/rspec/core/example_group.rb +33 -16
  19. data/lib/rspec/core/filter_manager.rb +1 -1
  20. data/lib/rspec/core/formatters.rb +14 -6
  21. data/lib/rspec/core/formatters/base_bisect_formatter.rb +45 -0
  22. data/lib/rspec/core/formatters/bisect_drb_formatter.rb +29 -0
  23. data/lib/rspec/core/formatters/bisect_progress_formatter.rb +29 -16
  24. data/lib/rspec/core/formatters/deprecation_formatter.rb +3 -1
  25. data/lib/rspec/core/formatters/documentation_formatter.rb +35 -3
  26. data/lib/rspec/core/formatters/exception_presenter.rb +29 -6
  27. data/lib/rspec/core/formatters/failure_list_formatter.rb +23 -0
  28. data/lib/rspec/core/formatters/html_printer.rb +0 -2
  29. data/lib/rspec/core/formatters/protocol.rb +17 -17
  30. data/lib/rspec/core/formatters/syntax_highlighter.rb +19 -19
  31. data/lib/rspec/core/hooks.rb +44 -24
  32. data/lib/rspec/core/invocations.rb +9 -7
  33. data/lib/rspec/core/memoized_helpers.rb +33 -14
  34. data/lib/rspec/core/metadata.rb +2 -3
  35. data/lib/rspec/core/option_parser.rb +10 -3
  36. data/lib/rspec/core/profiler.rb +3 -1
  37. data/lib/rspec/core/rake_task.rb +22 -2
  38. data/lib/rspec/core/reporter.rb +11 -6
  39. data/lib/rspec/core/runner.rb +25 -14
  40. data/lib/rspec/core/shared_example_group.rb +5 -5
  41. data/lib/rspec/core/shell_escape.rb +2 -2
  42. data/lib/rspec/core/version.rb +1 -1
  43. data/lib/rspec/core/world.rb +14 -1
  44. metadata +25 -15
  45. metadata.gz.sig +0 -0
  46. data/lib/rspec/core/formatters/bisect_formatter.rb +0 -69
@@ -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)
@@ -45,6 +45,21 @@ module RSpec
45
45
  # A message to print to stderr when there are failures.
46
46
  attr_accessor :failure_message
47
47
 
48
+ if RUBY_VERSION < "1.9.0" || Support::Ruby.jruby?
49
+ # Run RSpec with a clean (empty) environment is not supported
50
+ def with_clean_environment=(_value)
51
+ raise ArgumentError, "Running in a clean environment is not supported on Ruby versions before 1.9.0"
52
+ end
53
+
54
+ # Run RSpec with a clean (empty) environment is not supported
55
+ def with_clean_environment
56
+ false
57
+ end
58
+ else
59
+ # Run RSpec with a clean (empty) environment.
60
+ attr_accessor :with_clean_environment
61
+ end
62
+
48
63
  # Use verbose output. If this is set to true, the task will print the
49
64
  # executed spec command to stdout. Defaults to `true`.
50
65
  attr_accessor :verbose
@@ -76,7 +91,12 @@ module RSpec
76
91
  command = spec_command
77
92
  puts command if verbose
78
93
 
79
- return if system(command)
94
+ if with_clean_environment
95
+ return if system({}, command, :unsetenv_others => true)
96
+ else
97
+ return if system(command)
98
+ end
99
+
80
100
  puts failure_message if failure_message
81
101
 
82
102
  return unless fail_on_error
@@ -102,7 +122,7 @@ module RSpec
102
122
  if ENV['SPEC']
103
123
  FileList[ENV['SPEC']].sort
104
124
  elsif String === pattern && !File.exist?(pattern)
105
- return if rspec_opts =~ /--pattern/
125
+ return if [*rspec_opts].any? { |opt| opt =~ /--pattern/ }
106
126
  "--pattern #{escape pattern}"
107
127
  else
108
128
  # Before RSpec 3.1, we used `FileList` to get the list of matched
@@ -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
  #
@@ -82,6 +77,14 @@ module RSpec::Core
82
77
  end
83
78
  end
84
79
 
80
+ # @param exit_code [Integer] the exit_code to be return by the reporter
81
+ #
82
+ # Reports a run that exited early without having run any examples.
83
+ #
84
+ def exit_early(exit_code)
85
+ report(0) { exit_code }
86
+ end
87
+
85
88
  # @private
86
89
  def start(expected_example_count, time=RSpec::Core::Time.now)
87
90
  @start = time
@@ -231,6 +234,8 @@ module RSpec::Core
231
234
  return if @setup
232
235
 
233
236
  @setup_default.call
237
+ @profiler = Profiler.new
238
+ register_listener @profiler, *Profiler::NOTIFICATIONS
234
239
  @setup = true
235
240
  end
236
241
 
@@ -84,6 +84,8 @@ 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
88
+
87
89
  run_specs(@world.ordered_example_groups).tap do
88
90
  persist_example_statuses
89
91
  end
@@ -94,10 +96,11 @@ module RSpec
94
96
  # @param err [IO] error stream
95
97
  # @param out [IO] output stream
96
98
  def setup(err, out)
97
- @configuration.error_stream = err
98
- @configuration.output_stream = out if @configuration.output_stream == $stdout
99
- @options.configure(@configuration)
99
+ configure(err, out)
100
+ return if RSpec.world.wants_to_quit
101
+
100
102
  @configuration.load_spec_files
103
+ ensure
101
104
  @world.announce_filters
102
105
  end
103
106
 
@@ -122,17 +125,11 @@ module RSpec
122
125
  success ? 0 : @configuration.failure_exit_code
123
126
  end
124
127
 
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
128
+ # @private
129
+ def configure(err, out)
130
+ @configuration.error_stream = err
131
+ @configuration.output_stream = out if @configuration.output_stream == $stdout
132
+ @options.configure(@configuration)
136
133
  end
137
134
 
138
135
  # @private
@@ -188,6 +185,20 @@ module RSpec
188
185
  $stderr.puts "\nRSpec is shutting down and will print the summary report... Interrupt again to force quit."
189
186
  end
190
187
  end
188
+
189
+ private
190
+
191
+ def persist_example_statuses
192
+ return if @configuration.dry_run
193
+ return unless (path = @configuration.example_status_persistence_file_path)
194
+
195
+ ExampleStatusPersister.persist(@world.all_examples, path)
196
+ rescue SystemCallError => e
197
+ RSpec.warning "Could not write example statuses to #{path} (configured as " \
198
+ "`config.example_status_persistence_file_path`) due to a " \
199
+ "system error: #{e.inspect}. Please check that the config " \
200
+ "option is set to an accessible, valid file path", :call_site => nil
201
+ end
191
202
  end
192
203
  end
193
204
  end
@@ -1,3 +1,5 @@
1
+ RSpec::Support.require_rspec_support "with_keywords_when_needed"
2
+
1
3
  module RSpec
2
4
  module Core
3
5
  # Represents some functionality that is shared with multiple example groups.
@@ -33,7 +35,7 @@ module RSpec
33
35
  klass.update_inherited_metadata(@metadata) unless @metadata.empty?
34
36
 
35
37
  SharedExampleGroupInclusionStackFrame.with_frame(@description, inclusion_line) do
36
- klass.class_exec(*args, &@definition)
38
+ RSpec::Support::WithKeywordsWhenNeeded.class_exec(klass, *args, &@definition)
37
39
  klass.class_exec(&customization_block) if customization_block
38
40
  end
39
41
  end
@@ -76,7 +78,7 @@ module RSpec
76
78
  # end
77
79
  # end
78
80
  #
79
- # describe Account do
81
+ # RSpec.describe Account do
80
82
  # it_behaves_like "auditable" do
81
83
  # let(:auditable) { Account.new }
82
84
  # end
@@ -103,7 +105,6 @@ module RSpec
103
105
  # Shared examples top level DSL.
104
106
  module TopLevelDSL
105
107
  # @private
106
- # rubocop:disable Lint/NestedMethodDefinition
107
108
  def self.definitions
108
109
  proc do
109
110
  def shared_examples(name, *args, &block)
@@ -113,7 +114,6 @@ module RSpec
113
114
  alias shared_examples_for shared_examples
114
115
  end
115
116
  end
116
- # rubocop:enable Lint/NestedMethodDefinition
117
117
 
118
118
  # @private
119
119
  def self.exposed_globally?
@@ -259,7 +259,7 @@ module RSpec
259
259
  # :nocov:
260
260
  def ensure_block_has_source_location(block)
261
261
  source_location = yield.split(':')
262
- block.extend Module.new { define_method(:source_location) { source_location } }
262
+ block.extend(Module.new { define_method(:source_location) { source_location } })
263
263
  end
264
264
  # :nocov:
265
265
  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.9.3'
7
7
  end
8
8
  end
9
9
  end
@@ -5,7 +5,7 @@ module RSpec
5
5
  # Internal container for global non-configuration data.
6
6
  class World
7
7
  # @private
8
- attr_reader :example_groups, :filtered_examples
8
+ attr_reader :example_groups, :filtered_examples, :example_group_counts_by_spec_file
9
9
 
10
10
  # Used internally to determine what to do when a SIGINT is received.
11
11
  attr_accessor :wants_to_quit
@@ -17,10 +17,22 @@ 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 = []
23
24
  @example_group_counts_by_spec_file = Hash.new(0)
25
+ prepare_example_filtering
26
+ end
27
+
28
+ # @api public
29
+ #
30
+ # Prepares filters so that they apply to example groups when they run.
31
+ #
32
+ # This is a separate method so that filters can be modified/replaced and
33
+ # examples refiltered during a process's lifetime, which can be useful for
34
+ # a custom runner.
35
+ def prepare_example_filtering
24
36
  @filtered_examples = Hash.new do |hash, group|
25
37
  hash[group] = filter_manager.prune(group.examples)
26
38
  end
@@ -42,6 +54,7 @@ module RSpec
42
54
  example_groups.clear
43
55
  @sources_by_path.clear if defined?(@sources_by_path)
44
56
  @syntax_highlighter = nil
57
+ @example_group_counts_by_spec_file = Hash.new(0)
45
58
  end
46
59
 
47
60
  # @private
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.7.1
4
+ version: 3.9.3
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: 2018-01-03 00:00:00.000000000 Z
49
+ date: 2020-09-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.7.0
57
+ version: 3.9.3
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.9.3
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: cucumber
67
67
  requirement: !ruby/object:Gem::Requirement
@@ -96,14 +96,14 @@ dependencies:
96
96
  requirements:
97
97
  - - "~>"
98
98
  - !ruby/object:Gem::Version
99
- version: 0.6.2
99
+ version: 0.14.9
100
100
  type: :development
101
101
  prerelease: false
102
102
  version_requirements: !ruby/object:Gem::Requirement
103
103
  requirements:
104
104
  - - "~>"
105
105
  - !ruby/object:Gem::Version
106
- version: 0.6.2
106
+ version: 0.14.9
107
107
  - !ruby/object:Gem::Dependency
108
108
  name: coderay
109
109
  requirement: !ruby/object:Gem::Requirement
@@ -192,10 +192,14 @@ 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
202
+ - lib/rspec/core/did_you_mean.rb
199
203
  - lib/rspec/core/drb.rb
200
204
  - lib/rspec/core/dsl.rb
201
205
  - lib/rspec/core/example.rb
@@ -204,14 +208,16 @@ files:
204
208
  - lib/rspec/core/filter_manager.rb
205
209
  - lib/rspec/core/flat_map.rb
206
210
  - lib/rspec/core/formatters.rb
211
+ - lib/rspec/core/formatters/base_bisect_formatter.rb
207
212
  - lib/rspec/core/formatters/base_formatter.rb
208
213
  - lib/rspec/core/formatters/base_text_formatter.rb
209
- - lib/rspec/core/formatters/bisect_formatter.rb
214
+ - lib/rspec/core/formatters/bisect_drb_formatter.rb
210
215
  - lib/rspec/core/formatters/bisect_progress_formatter.rb
211
216
  - lib/rspec/core/formatters/console_codes.rb
212
217
  - lib/rspec/core/formatters/deprecation_formatter.rb
213
218
  - lib/rspec/core/formatters/documentation_formatter.rb
214
219
  - lib/rspec/core/formatters/exception_presenter.rb
220
+ - lib/rspec/core/formatters/failure_list_formatter.rb
215
221
  - lib/rspec/core/formatters/fallback_message_formatter.rb
216
222
  - lib/rspec/core/formatters/helpers.rb
217
223
  - lib/rspec/core/formatters/html_formatter.rb
@@ -259,8 +265,13 @@ files:
259
265
  homepage: https://github.com/rspec/rspec-core
260
266
  licenses:
261
267
  - MIT
262
- metadata: {}
263
- post_install_message:
268
+ metadata:
269
+ bug_tracker_uri: https://github.com/rspec/rspec-core/issues
270
+ changelog_uri: https://github.com/rspec/rspec-core/blob/v3.9.3/Changelog.md
271
+ documentation_uri: https://rspec.info/documentation/
272
+ mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
273
+ source_code_uri: https://github.com/rspec/rspec-core
274
+ post_install_message:
264
275
  rdoc_options:
265
276
  - "--charset=UTF-8"
266
277
  require_paths:
@@ -276,9 +287,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
287
  - !ruby/object:Gem::Version
277
288
  version: '0'
278
289
  requirements: []
279
- rubyforge_project:
280
- rubygems_version: 2.7.3
281
- signing_key:
290
+ rubygems_version: 3.1.3
291
+ signing_key:
282
292
  specification_version: 4
283
- summary: rspec-core-3.7.1
293
+ summary: rspec-core-3.9.3
284
294
  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