rspec-core 3.8.2 → 3.10.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Changelog.md +76 -1
- data/README.md +4 -4
- data/lib/rspec/core.rb +1 -0
- data/lib/rspec/core/bisect/fork_runner.rb +6 -2
- data/lib/rspec/core/bisect/server.rb +1 -1
- data/lib/rspec/core/configuration.rb +88 -24
- data/lib/rspec/core/did_you_mean.rb +46 -0
- data/lib/rspec/core/drb.rb +7 -0
- data/lib/rspec/core/example.rb +10 -3
- data/lib/rspec/core/example_group.rb +27 -15
- data/lib/rspec/core/filter_manager.rb +1 -1
- data/lib/rspec/core/formatters.rb +4 -0
- data/lib/rspec/core/formatters/documentation_formatter.rb +35 -3
- data/lib/rspec/core/formatters/exception_presenter.rb +22 -9
- data/lib/rspec/core/formatters/failure_list_formatter.rb +23 -0
- data/lib/rspec/core/hooks.rb +43 -21
- data/lib/rspec/core/invocations.rb +1 -1
- data/lib/rspec/core/memoized_helpers.rb +11 -11
- data/lib/rspec/core/metadata.rb +1 -1
- data/lib/rspec/core/option_parser.rb +15 -3
- data/lib/rspec/core/rake_task.rb +22 -2
- data/lib/rspec/core/reporter.rb +8 -0
- data/lib/rspec/core/runner.rb +16 -3
- data/lib/rspec/core/shared_example_group.rb +4 -2
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +3 -1
- metadata +14 -12
- metadata.gz.sig +0 -0
@@ -10,7 +10,7 @@ module RSpec
|
|
10
10
|
# @note `subject` was contributed by Joe Ferris to support the one-liner
|
11
11
|
# syntax embraced by shoulda matchers:
|
12
12
|
#
|
13
|
-
# describe Widget do
|
13
|
+
# RSpec.describe Widget do
|
14
14
|
# it { is_expected.to validate_presence_of(:name) }
|
15
15
|
# # or
|
16
16
|
# it { should validate_presence_of(:name) }
|
@@ -23,7 +23,7 @@ module RSpec
|
|
23
23
|
# @example
|
24
24
|
#
|
25
25
|
# # Explicit declaration of subject.
|
26
|
-
# describe Person do
|
26
|
+
# RSpec.describe Person do
|
27
27
|
# subject { Person.new(:birthdate => 19.years.ago) }
|
28
28
|
# it "should be eligible to vote" do
|
29
29
|
# subject.should be_eligible_to_vote
|
@@ -32,7 +32,7 @@ module RSpec
|
|
32
32
|
# end
|
33
33
|
#
|
34
34
|
# # Implicit subject => { Person.new }.
|
35
|
-
# describe Person do
|
35
|
+
# RSpec.describe Person do
|
36
36
|
# it "should be eligible to vote" do
|
37
37
|
# subject.should be_eligible_to_vote
|
38
38
|
# # ^ ^ explicit reference to subject not recommended
|
@@ -40,7 +40,7 @@ module RSpec
|
|
40
40
|
# end
|
41
41
|
#
|
42
42
|
# # One-liner syntax - expectation is set on the subject.
|
43
|
-
# describe Person do
|
43
|
+
# RSpec.describe Person do
|
44
44
|
# it { is_expected.to be_eligible_to_vote }
|
45
45
|
# # or
|
46
46
|
# it { should be_eligible_to_vote }
|
@@ -67,7 +67,7 @@ module RSpec
|
|
67
67
|
#
|
68
68
|
# @example
|
69
69
|
#
|
70
|
-
# describe Person do
|
70
|
+
# RSpec.describe Person do
|
71
71
|
# it { should be_eligible_to_vote }
|
72
72
|
# end
|
73
73
|
#
|
@@ -86,7 +86,7 @@ module RSpec
|
|
86
86
|
#
|
87
87
|
# @example
|
88
88
|
#
|
89
|
-
# describe Person do
|
89
|
+
# RSpec.describe Person do
|
90
90
|
# it { should_not be_eligible_to_vote }
|
91
91
|
# end
|
92
92
|
#
|
@@ -270,7 +270,7 @@ EOS
|
|
270
270
|
#
|
271
271
|
# @example
|
272
272
|
#
|
273
|
-
# describe Thing do
|
273
|
+
# RSpec.describe Thing do
|
274
274
|
# let(:thing) { Thing.new }
|
275
275
|
#
|
276
276
|
# it "does something" do
|
@@ -342,7 +342,7 @@ EOS
|
|
342
342
|
# end
|
343
343
|
# end
|
344
344
|
#
|
345
|
-
# describe Thing do
|
345
|
+
# RSpec.describe Thing do
|
346
346
|
# after(:example) { Thing.reset_count }
|
347
347
|
#
|
348
348
|
# context "using let" do
|
@@ -398,13 +398,13 @@ EOS
|
|
398
398
|
#
|
399
399
|
# @example
|
400
400
|
#
|
401
|
-
# describe CheckingAccount, "with $50" do
|
401
|
+
# RSpec.describe CheckingAccount, "with $50" do
|
402
402
|
# subject { CheckingAccount.new(Money.new(50, :USD)) }
|
403
403
|
# it { is_expected.to have_a_balance_of(Money.new(50, :USD)) }
|
404
404
|
# it { is_expected.not_to be_overdrawn }
|
405
405
|
# end
|
406
406
|
#
|
407
|
-
# describe CheckingAccount, "with a non-zero starting balance" do
|
407
|
+
# RSpec.describe CheckingAccount, "with a non-zero starting balance" do
|
408
408
|
# subject(:account) { CheckingAccount.new(Money.new(50, :USD)) }
|
409
409
|
# it { is_expected.not_to be_overdrawn }
|
410
410
|
# it "has a balance equal to the starting balance" do
|
@@ -452,7 +452,7 @@ EOS
|
|
452
452
|
# end
|
453
453
|
# end
|
454
454
|
#
|
455
|
-
# describe Thing do
|
455
|
+
# RSpec.describe Thing do
|
456
456
|
# after(:example) { Thing.reset_count }
|
457
457
|
#
|
458
458
|
# context "using subject" do
|
data/lib/rspec/core/metadata.rb
CHANGED
@@ -7,7 +7,7 @@ module RSpec
|
|
7
7
|
# In addition to metadata that is used internally, this also stores
|
8
8
|
# user-supplied metadata, e.g.
|
9
9
|
#
|
10
|
-
# describe Something, :type => :ui do
|
10
|
+
# RSpec.describe Something, :type => :ui do
|
11
11
|
# it "does something", :slow => true do
|
12
12
|
# # ...
|
13
13
|
# end
|
@@ -22,9 +22,8 @@ module RSpec::Core
|
|
22
22
|
begin
|
23
23
|
parser(options).parse!(args)
|
24
24
|
rescue OptionParser::InvalidOption => e
|
25
|
-
|
26
|
-
|
27
|
-
abort "#{failure}\n\nPlease use --help for a listing of valid options"
|
25
|
+
abort "#{e.message}#{" (defined in #{source})" if source}\n\n" \
|
26
|
+
"Please use --help for a listing of valid options"
|
28
27
|
end
|
29
28
|
|
30
29
|
options[:files_or_directories_to_run] = args
|
@@ -37,6 +36,7 @@ module RSpec::Core
|
|
37
36
|
# rubocop:disable Metrics/AbcSize
|
38
37
|
# rubocop:disable CyclomaticComplexity
|
39
38
|
# rubocop:disable PerceivedComplexity
|
39
|
+
# rubocop:disable Metrics/BlockLength
|
40
40
|
def parser(options)
|
41
41
|
OptionParser.new do |parser|
|
42
42
|
parser.summary_width = 34
|
@@ -95,6 +95,11 @@ module RSpec::Core
|
|
95
95
|
options[:failure_exit_code] = code
|
96
96
|
end
|
97
97
|
|
98
|
+
parser.on('--error-exit-code CODE', Integer,
|
99
|
+
'Override the exit code used when there are errors loading or running specs outside of examples.') do |code|
|
100
|
+
options[:error_exit_code] = code
|
101
|
+
end
|
102
|
+
|
98
103
|
parser.on('-X', '--[no-]drb', 'Run examples via DRb.') do |use_drb|
|
99
104
|
options[:drb] = use_drb
|
100
105
|
options[:runner] = RSpec::Core::Invocations::DRbWithFallback.new if use_drb
|
@@ -111,6 +116,7 @@ module RSpec::Core
|
|
111
116
|
' [d]ocumentation (group and example names)',
|
112
117
|
' [h]tml',
|
113
118
|
' [j]son',
|
119
|
+
' [f]ailures ("file:line:reason", suitable for editors integration)',
|
114
120
|
' custom formatter class name') do |o|
|
115
121
|
options[:formatters] ||= []
|
116
122
|
options[:formatters] << [o]
|
@@ -226,6 +232,11 @@ FILTERING
|
|
226
232
|
(options[:full_description] ||= []) << Regexp.compile(Regexp.escape(o))
|
227
233
|
end
|
228
234
|
|
235
|
+
parser.on('-E', '--example-matches REGEX', "Run examples whose full nested names match REGEX (may be",
|
236
|
+
" used more than once)") do |o|
|
237
|
+
(options[:full_description] ||= []) << Regexp.compile(o)
|
238
|
+
end
|
239
|
+
|
229
240
|
parser.on('-t', '--tag TAG[:VALUE]',
|
230
241
|
'Run examples with the specified tag, or exclude examples',
|
231
242
|
'by adding ~ before the tag.',
|
@@ -288,6 +299,7 @@ FILTERING
|
|
288
299
|
end
|
289
300
|
end
|
290
301
|
end
|
302
|
+
# rubocop:enable Metrics/BlockLength
|
291
303
|
# rubocop:enable Metrics/AbcSize
|
292
304
|
# rubocop:enable MethodLength
|
293
305
|
# rubocop:enable CyclomaticComplexity
|
data/lib/rspec/core/rake_task.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/rspec/core/reporter.rb
CHANGED
@@ -77,6 +77,14 @@ module RSpec::Core
|
|
77
77
|
end
|
78
78
|
end
|
79
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
|
+
|
80
88
|
# @private
|
81
89
|
def start(expected_example_count, time=RSpec::Core::Time.now)
|
82
90
|
@start = time
|
data/lib/rspec/core/runner.rb
CHANGED
@@ -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(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
|
@@ -95,7 +97,10 @@ module RSpec
|
|
95
97
|
# @param out [IO] output stream
|
96
98
|
def setup(err, out)
|
97
99
|
configure(err, out)
|
100
|
+
return if RSpec.world.wants_to_quit
|
101
|
+
|
98
102
|
@configuration.load_spec_files
|
103
|
+
ensure
|
99
104
|
@world.announce_filters
|
100
105
|
end
|
101
106
|
|
@@ -107,7 +112,7 @@ module RSpec
|
|
107
112
|
# failed.
|
108
113
|
def run_specs(example_groups)
|
109
114
|
examples_count = @world.example_count(example_groups)
|
110
|
-
|
115
|
+
examples_passed = @configuration.reporter.report(examples_count) do |reporter|
|
111
116
|
@configuration.with_suite_hooks do
|
112
117
|
if examples_count == 0 && @configuration.fail_if_no_examples
|
113
118
|
return @configuration.failure_exit_code
|
@@ -115,9 +120,9 @@ module RSpec
|
|
115
120
|
|
116
121
|
example_groups.map { |g| g.run(reporter) }.all?
|
117
122
|
end
|
118
|
-
end
|
123
|
+
end
|
119
124
|
|
120
|
-
|
125
|
+
exit_code(examples_passed)
|
121
126
|
end
|
122
127
|
|
123
128
|
# @private
|
@@ -181,6 +186,14 @@ module RSpec
|
|
181
186
|
end
|
182
187
|
end
|
183
188
|
|
189
|
+
# @private
|
190
|
+
def exit_code(examples_passed=false)
|
191
|
+
return @configuration.error_exit_code || @configuration.failure_exit_code if @world.non_example_failure
|
192
|
+
return @configuration.failure_exit_code unless examples_passed
|
193
|
+
|
194
|
+
0
|
195
|
+
end
|
196
|
+
|
184
197
|
private
|
185
198
|
|
186
199
|
def persist_example_statuses
|
@@ -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
|
-
|
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
|
data/lib/rspec/core/version.rb
CHANGED
data/lib/rspec/core/world.rb
CHANGED
@@ -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,6 +17,7 @@ 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 = []
|
@@ -53,6 +54,7 @@ module RSpec
|
|
53
54
|
example_groups.clear
|
54
55
|
@sources_by_path.clear if defined?(@sources_by_path)
|
55
56
|
@syntax_highlighter = nil
|
57
|
+
@example_group_counts_by_spec_file = Hash.new(0)
|
56
58
|
end
|
57
59
|
|
58
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.
|
4
|
+
version: 3.10.0
|
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:
|
49
|
+
date: 2020-10-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.
|
57
|
+
version: 3.10.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.
|
64
|
+
version: 3.10.0
|
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.
|
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.
|
106
|
+
version: 0.14.9
|
107
107
|
- !ruby/object:Gem::Dependency
|
108
108
|
name: coderay
|
109
109
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,6 +199,7 @@ files:
|
|
199
199
|
- lib/rspec/core/bisect/utilities.rb
|
200
200
|
- lib/rspec/core/configuration.rb
|
201
201
|
- lib/rspec/core/configuration_options.rb
|
202
|
+
- lib/rspec/core/did_you_mean.rb
|
202
203
|
- lib/rspec/core/drb.rb
|
203
204
|
- lib/rspec/core/dsl.rb
|
204
205
|
- lib/rspec/core/example.rb
|
@@ -216,6 +217,7 @@ files:
|
|
216
217
|
- lib/rspec/core/formatters/deprecation_formatter.rb
|
217
218
|
- lib/rspec/core/formatters/documentation_formatter.rb
|
218
219
|
- lib/rspec/core/formatters/exception_presenter.rb
|
220
|
+
- lib/rspec/core/formatters/failure_list_formatter.rb
|
219
221
|
- lib/rspec/core/formatters/fallback_message_formatter.rb
|
220
222
|
- lib/rspec/core/formatters/helpers.rb
|
221
223
|
- lib/rspec/core/formatters/html_formatter.rb
|
@@ -265,11 +267,11 @@ licenses:
|
|
265
267
|
- MIT
|
266
268
|
metadata:
|
267
269
|
bug_tracker_uri: https://github.com/rspec/rspec-core/issues
|
268
|
-
changelog_uri: https://github.com/rspec/rspec-core/blob/v3.
|
270
|
+
changelog_uri: https://github.com/rspec/rspec-core/blob/v3.10.0/Changelog.md
|
269
271
|
documentation_uri: https://rspec.info/documentation/
|
270
272
|
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
271
273
|
source_code_uri: https://github.com/rspec/rspec-core
|
272
|
-
post_install_message:
|
274
|
+
post_install_message:
|
273
275
|
rdoc_options:
|
274
276
|
- "--charset=UTF-8"
|
275
277
|
require_paths:
|
@@ -285,8 +287,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
285
287
|
- !ruby/object:Gem::Version
|
286
288
|
version: '0'
|
287
289
|
requirements: []
|
288
|
-
rubygems_version: 3.
|
289
|
-
signing_key:
|
290
|
+
rubygems_version: 3.1.3
|
291
|
+
signing_key:
|
290
292
|
specification_version: 4
|
291
|
-
summary: rspec-core-3.
|
293
|
+
summary: rspec-core-3.10.0
|
292
294
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|