rspec-core 3.5.2 → 3.6.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/Changelog.md +89 -2
- data/lib/rspec/core/bisect/server.rb +6 -1
- data/lib/rspec/core/configuration.rb +110 -26
- data/lib/rspec/core/configuration_options.rb +2 -0
- data/lib/rspec/core/drb.rb +2 -0
- data/lib/rspec/core/example.rb +14 -10
- data/lib/rspec/core/example_group.rb +16 -6
- data/lib/rspec/core/formatters/base_text_formatter.rb +3 -5
- data/lib/rspec/core/formatters/console_codes.rb +7 -4
- data/lib/rspec/core/formatters/documentation_formatter.rb +2 -1
- data/lib/rspec/core/formatters/exception_presenter.rb +10 -4
- data/lib/rspec/core/formatters/html_formatter.rb +4 -2
- data/lib/rspec/core/formatters/html_snippet_extractor.rb +2 -0
- data/lib/rspec/core/formatters/json_formatter.rb +7 -2
- data/lib/rspec/core/formatters/progress_formatter.rb +1 -0
- data/lib/rspec/core/formatters/protocol.rb +26 -25
- data/lib/rspec/core/formatters/snippet_extractor.rb +1 -3
- data/lib/rspec/core/{source → formatters}/syntax_highlighter.rb +21 -1
- data/lib/rspec/core/formatters.rb +15 -5
- data/lib/rspec/core/hooks.rb +1 -8
- data/lib/rspec/core/invocations.rb +22 -4
- data/lib/rspec/core/memoized_helpers.rb +3 -0
- data/lib/rspec/core/metadata.rb +1 -0
- data/lib/rspec/core/metadata_filter.rb +29 -17
- data/lib/rspec/core/notifications.rb +20 -5
- data/lib/rspec/core/option_parser.rb +32 -12
- data/lib/rspec/core/output_wrapper.rb +29 -0
- data/lib/rspec/core/project_initializer/.rspec +0 -1
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +1 -4
- data/lib/rspec/core/reporter.rb +33 -9
- data/lib/rspec/core/runner.rb +10 -3
- data/lib/rspec/core/set.rb +5 -0
- data/lib/rspec/core/shared_example_group.rb +39 -15
- data/lib/rspec/core/version.rb +1 -1
- data/lib/rspec/core/world.rb +23 -5
- data/lib/rspec/core.rb +2 -1
- data.tar.gz.sig +3 -4
- metadata +8 -11
- metadata.gz.sig +0 -0
- data/lib/rspec/core/source/location.rb +0 -13
- data/lib/rspec/core/source/node.rb +0 -93
- data/lib/rspec/core/source/token.rb +0 -87
- data/lib/rspec/core/source.rb +0 -86
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
RSpec::Support.require_rspec_core "formatters/console_codes"
|
|
2
3
|
RSpec::Support.require_rspec_core "formatters/snippet_extractor"
|
|
4
|
+
RSpec::Support.require_rspec_core 'formatters/syntax_highlighter'
|
|
3
5
|
RSpec::Support.require_rspec_support "encoded_string"
|
|
4
6
|
|
|
5
7
|
module RSpec
|
|
@@ -122,7 +124,8 @@ module RSpec
|
|
|
122
124
|
end
|
|
123
125
|
|
|
124
126
|
def indent_lines(lines, failure_number)
|
|
125
|
-
alignment_basis =
|
|
127
|
+
alignment_basis = ' ' * @indentation
|
|
128
|
+
alignment_basis << "#{failure_number}) " if failure_number
|
|
126
129
|
indentation = ' ' * alignment_basis.length
|
|
127
130
|
|
|
128
131
|
lines.each_with_index.map do |line, index|
|
|
@@ -213,7 +216,7 @@ module RSpec
|
|
|
213
216
|
file_path, line_number = file_and_line_number[1..2]
|
|
214
217
|
max_line_count = RSpec.configuration.max_displayed_failure_line_count
|
|
215
218
|
lines = SnippetExtractor.extract_expression_lines_at(file_path, line_number.to_i, max_line_count)
|
|
216
|
-
RSpec.world.
|
|
219
|
+
RSpec.world.syntax_highlighter.highlight(lines)
|
|
217
220
|
rescue SnippetExtractor::NoSuchFileError
|
|
218
221
|
["Unable to find #{file_path} to read failed line"]
|
|
219
222
|
rescue SnippetExtractor::NoSuchLineError
|
|
@@ -277,7 +280,7 @@ module RSpec
|
|
|
277
280
|
:description => "#{@example.full_description} FIXED",
|
|
278
281
|
:message_color => RSpec.configuration.fixed_color,
|
|
279
282
|
:failure_lines => [
|
|
280
|
-
"Expected pending '#{@execution_result.pending_message}' to fail. No
|
|
283
|
+
"Expected pending '#{@execution_result.pending_message}' to fail. No error was raised."
|
|
281
284
|
]
|
|
282
285
|
}
|
|
283
286
|
elsif @execution_result.status == :pending
|
|
@@ -344,7 +347,10 @@ module RSpec
|
|
|
344
347
|
|
|
345
348
|
failure = common_backtrace_truncater.with_truncated_backtrace(failure)
|
|
346
349
|
presenter = ExceptionPresenter.new(failure, @example, options)
|
|
347
|
-
presenter.fully_formatted_lines(
|
|
350
|
+
presenter.fully_formatted_lines(
|
|
351
|
+
"#{failure_number ? "#{failure_number}." : ''}#{index + 1}",
|
|
352
|
+
colorizer
|
|
353
|
+
)
|
|
348
354
|
end
|
|
349
355
|
end
|
|
350
356
|
end
|
|
@@ -69,10 +69,12 @@ module RSpec
|
|
|
69
69
|
example = failure.example
|
|
70
70
|
|
|
71
71
|
exception = failure.exception
|
|
72
|
+
message_lines = failure.fully_formatted_lines(nil, RSpec::Core::Notifications::NullColorizer)
|
|
72
73
|
exception_details = if exception
|
|
73
74
|
{
|
|
74
|
-
|
|
75
|
-
:
|
|
75
|
+
# drop 2 removes the description (regardless of newlines) and leading blank line
|
|
76
|
+
:message => message_lines.drop(2).join("\n"),
|
|
77
|
+
:backtrace => failure.formatted_backtrace.join("\n"),
|
|
76
78
|
}
|
|
77
79
|
end
|
|
78
80
|
extra = extra_failure_content(failure)
|
|
@@ -24,6 +24,8 @@ module RSpec
|
|
|
24
24
|
@@converter = NullConverter
|
|
25
25
|
begin
|
|
26
26
|
require 'coderay'
|
|
27
|
+
RSpec::Support.require_rspec_core 'formatters/syntax_highlighter'
|
|
28
|
+
RSpec::Core::Formatters::SyntaxHighlighter.attempt_to_add_rspec_terms_to_coderay_keywords
|
|
27
29
|
@@converter = CoderayConverter
|
|
28
30
|
# rubocop:disable Lint/HandleExceptions
|
|
29
31
|
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
|
|
|
@@ -46,9 +46,13 @@ module RSpec
|
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
+
def seed(notification)
|
|
50
|
+
return unless notification.seed_used?
|
|
51
|
+
@output_hash[:seed] = notification.seed
|
|
52
|
+
end
|
|
53
|
+
|
|
49
54
|
def close(_notification)
|
|
50
55
|
output.write @output_hash.to_json
|
|
51
|
-
output.close if IO === output && output != $stdout
|
|
52
56
|
end
|
|
53
57
|
|
|
54
58
|
def dump_profile(profile)
|
|
@@ -81,6 +85,7 @@ module RSpec
|
|
|
81
85
|
|
|
82
86
|
def format_example(example)
|
|
83
87
|
{
|
|
88
|
+
:id => example.id,
|
|
84
89
|
:description => example.description,
|
|
85
90
|
:full_description => example.full_description,
|
|
86
91
|
:status => example.execution_result.status.to_s,
|
|
@@ -33,7 +33,7 @@ module RSpec
|
|
|
33
33
|
# This will only be invoked once, and the next one to be invoked
|
|
34
34
|
# is {#example_group_started}.
|
|
35
35
|
#
|
|
36
|
-
# @param notification [StartNotification]
|
|
36
|
+
# @param notification [Notifications::StartNotification]
|
|
37
37
|
|
|
38
38
|
# @method example_group_started
|
|
39
39
|
# @api public
|
|
@@ -45,8 +45,8 @@ module RSpec
|
|
|
45
45
|
# The next method to be invoked after this is {#example_passed},
|
|
46
46
|
# {#example_pending}, or {#example_group_finished}.
|
|
47
47
|
#
|
|
48
|
-
# @param notification [GroupNotification] containing example_group
|
|
49
|
-
# subclass of
|
|
48
|
+
# @param notification [Notifications::GroupNotification] containing example_group
|
|
49
|
+
# subclass of {ExampleGroup}
|
|
50
50
|
|
|
51
51
|
# @method example_group_finished
|
|
52
52
|
# @api public
|
|
@@ -54,8 +54,8 @@ module RSpec
|
|
|
54
54
|
#
|
|
55
55
|
# Invoked at the end of the execution of each example group.
|
|
56
56
|
#
|
|
57
|
-
# @param notification [GroupNotification] containing example_group
|
|
58
|
-
# subclass of
|
|
57
|
+
# @param notification [Notifications::GroupNotification] containing example_group
|
|
58
|
+
# subclass of {ExampleGroup}
|
|
59
59
|
|
|
60
60
|
# @method example_started
|
|
61
61
|
# @api public
|
|
@@ -63,8 +63,8 @@ module RSpec
|
|
|
63
63
|
#
|
|
64
64
|
# Invoked at the beginning of the execution of each example.
|
|
65
65
|
#
|
|
66
|
-
# @param notification [ExampleNotification] containing example subclass
|
|
67
|
-
# of
|
|
66
|
+
# @param notification [Notifications::ExampleNotification] containing example subclass
|
|
67
|
+
# of {Example}
|
|
68
68
|
|
|
69
69
|
# @method example_finished
|
|
70
70
|
# @api public
|
|
@@ -72,8 +72,8 @@ module RSpec
|
|
|
72
72
|
#
|
|
73
73
|
# Invoked at the end of the execution of each example.
|
|
74
74
|
#
|
|
75
|
-
# @param notification [ExampleNotification] containing example subclass
|
|
76
|
-
# of
|
|
75
|
+
# @param notification [Notifications::ExampleNotification] containing example subclass
|
|
76
|
+
# of {Example}
|
|
77
77
|
|
|
78
78
|
# @method example_passed
|
|
79
79
|
# @api public
|
|
@@ -81,8 +81,8 @@ module RSpec
|
|
|
81
81
|
#
|
|
82
82
|
# Invoked when an example passes.
|
|
83
83
|
#
|
|
84
|
-
# @param notification [ExampleNotification] containing example subclass
|
|
85
|
-
# of
|
|
84
|
+
# @param notification [Notifications::ExampleNotification] containing example subclass
|
|
85
|
+
# of {Example}
|
|
86
86
|
|
|
87
87
|
# @method example_pending
|
|
88
88
|
# @api public
|
|
@@ -90,8 +90,8 @@ module RSpec
|
|
|
90
90
|
#
|
|
91
91
|
# Invoked when an example is pending.
|
|
92
92
|
#
|
|
93
|
-
# @param notification [ExampleNotification] containing example subclass
|
|
94
|
-
# of
|
|
93
|
+
# @param notification [Notifications::ExampleNotification] containing example subclass
|
|
94
|
+
# of {Example}
|
|
95
95
|
|
|
96
96
|
# @method example_failed
|
|
97
97
|
# @api public
|
|
@@ -99,8 +99,8 @@ module RSpec
|
|
|
99
99
|
#
|
|
100
100
|
# Invoked when an example fails.
|
|
101
101
|
#
|
|
102
|
-
# @param notification [ExampleNotification] containing example subclass
|
|
103
|
-
# of
|
|
102
|
+
# @param notification [Notifications::ExampleNotification] containing example subclass
|
|
103
|
+
# of {Example}
|
|
104
104
|
|
|
105
105
|
# @method message
|
|
106
106
|
# @api public
|
|
@@ -108,7 +108,7 @@ module RSpec
|
|
|
108
108
|
#
|
|
109
109
|
# Used by the reporter to send messages to the output stream.
|
|
110
110
|
#
|
|
111
|
-
# @param notification [MessageNotification] containing message
|
|
111
|
+
# @param notification [Notifications::MessageNotification] containing message
|
|
112
112
|
|
|
113
113
|
# @method stop
|
|
114
114
|
# @api public
|
|
@@ -117,7 +117,7 @@ module RSpec
|
|
|
117
117
|
# Invoked after all examples have executed, before dumping post-run
|
|
118
118
|
# reports.
|
|
119
119
|
#
|
|
120
|
-
# @param notification [NullNotification]
|
|
120
|
+
# @param notification [Notifications::NullNotification]
|
|
121
121
|
|
|
122
122
|
# @method start_dump
|
|
123
123
|
# @api public
|
|
@@ -128,7 +128,7 @@ module RSpec
|
|
|
128
128
|
# (BaseTextFormatter then calls {#dump_failures} once for each failed
|
|
129
129
|
# example).
|
|
130
130
|
#
|
|
131
|
-
# @param notification [NullNotification]
|
|
131
|
+
# @param notification [Notifications::NullNotification]
|
|
132
132
|
|
|
133
133
|
# @method dump_failures
|
|
134
134
|
# @api public
|
|
@@ -136,7 +136,7 @@ module RSpec
|
|
|
136
136
|
#
|
|
137
137
|
# Dumps detailed information about each example failure.
|
|
138
138
|
#
|
|
139
|
-
# @param notification [NullNotification]
|
|
139
|
+
# @param notification [Notifications::NullNotification]
|
|
140
140
|
|
|
141
141
|
# @method dump_summary
|
|
142
142
|
# @api public
|
|
@@ -145,7 +145,7 @@ module RSpec
|
|
|
145
145
|
# This method is invoked after the dumping of examples and failures.
|
|
146
146
|
# Each parameter is assigned to a corresponding attribute.
|
|
147
147
|
#
|
|
148
|
-
# @param summary [SummaryNotification] containing duration,
|
|
148
|
+
# @param summary [Notifications::SummaryNotification] containing duration,
|
|
149
149
|
# example_count, failure_count and pending_count
|
|
150
150
|
|
|
151
151
|
# @method dump_profile
|
|
@@ -155,7 +155,7 @@ module RSpec
|
|
|
155
155
|
# This method is invoked after the dumping the summary if profiling is
|
|
156
156
|
# enabled.
|
|
157
157
|
#
|
|
158
|
-
# @param profile [ProfileNotification] containing duration,
|
|
158
|
+
# @param profile [Notifications::ProfileNotification] containing duration,
|
|
159
159
|
# slowest_examples and slowest_example_groups
|
|
160
160
|
|
|
161
161
|
# @method dump_pending
|
|
@@ -165,16 +165,17 @@ module RSpec
|
|
|
165
165
|
# Outputs a report of pending examples. This gets invoked
|
|
166
166
|
# after the summary if option is set to do so.
|
|
167
167
|
#
|
|
168
|
-
# @param notification [NullNotification]
|
|
168
|
+
# @param notification [Notifications::NullNotification]
|
|
169
169
|
|
|
170
170
|
# @method close
|
|
171
171
|
# @api public
|
|
172
172
|
# @group Suite Notifications
|
|
173
173
|
#
|
|
174
|
-
# Invoked at the
|
|
175
|
-
# up
|
|
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
|
-
# @param notification [NullNotification]
|
|
178
|
+
# @param notification [Notifications::NullNotification]
|
|
178
179
|
end
|
|
179
180
|
end
|
|
180
181
|
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.
|
|
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
|
-
|
|
3
|
+
module Formatters
|
|
4
4
|
# @private
|
|
5
5
|
# Provides terminal syntax highlighting of code snippets
|
|
6
6
|
# when coderay is available.
|
|
@@ -31,12 +31,32 @@ module RSpec
|
|
|
31
31
|
def color_enabled_implementation
|
|
32
32
|
@color_enabled_implementation ||= begin
|
|
33
33
|
require 'coderay'
|
|
34
|
+
self.class.attempt_to_add_rspec_terms_to_coderay_keywords
|
|
34
35
|
CodeRayImplementation
|
|
35
36
|
rescue LoadError
|
|
36
37
|
NoSyntaxHighlightingImplementation
|
|
37
38
|
end
|
|
38
39
|
end
|
|
39
40
|
|
|
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
|
+
|
|
40
60
|
# @private
|
|
41
61
|
module CodeRayImplementation
|
|
42
62
|
RESET_CODE = "\e[0m"
|
|
@@ -24,7 +24,7 @@ RSpec::Support.require_rspec_support "directory_maker"
|
|
|
24
24
|
# ## Custom Formatters
|
|
25
25
|
#
|
|
26
26
|
# You can tell RSpec to use a custom formatter by passing its path and name to
|
|
27
|
-
# the `rspec`
|
|
27
|
+
# the `rspec` command. For example, if you define MyCustomFormatter in
|
|
28
28
|
# path/to/my_custom_formatter.rb, you would type this command:
|
|
29
29
|
#
|
|
30
30
|
# rspec --require path/to/my_custom_formatter.rb --format MyCustomFormatter
|
|
@@ -115,6 +115,11 @@ module RSpec::Core::Formatters
|
|
|
115
115
|
# @return [String] the default formatter to setup, defaults to `progress`
|
|
116
116
|
attr_accessor :default_formatter
|
|
117
117
|
|
|
118
|
+
# @private
|
|
119
|
+
def prepare_default(output_stream, deprecation_stream)
|
|
120
|
+
reporter.prepare_default(self, output_stream, deprecation_stream)
|
|
121
|
+
end
|
|
122
|
+
|
|
118
123
|
# @private
|
|
119
124
|
def setup_default(output_stream, deprecation_stream)
|
|
120
125
|
add default_formatter, output_stream if @formatters.empty?
|
|
@@ -140,7 +145,7 @@ module RSpec::Core::Formatters
|
|
|
140
145
|
def add(formatter_to_use, *paths)
|
|
141
146
|
formatter_class = find_formatter(formatter_to_use)
|
|
142
147
|
|
|
143
|
-
args = paths.map { |p| p.respond_to?(:puts) ? p :
|
|
148
|
+
args = paths.map { |p| p.respond_to?(:puts) ? p : open_stream(p) }
|
|
144
149
|
|
|
145
150
|
if !Loader.formatters[formatter_class].nil?
|
|
146
151
|
formatter = formatter_class.new(*args)
|
|
@@ -247,9 +252,14 @@ module RSpec::Core::Formatters
|
|
|
247
252
|
word
|
|
248
253
|
end
|
|
249
254
|
|
|
250
|
-
def
|
|
251
|
-
RSpec::
|
|
252
|
-
|
|
255
|
+
def open_stream(path_or_wrapper)
|
|
256
|
+
if RSpec::Core::OutputWrapper === path_or_wrapper
|
|
257
|
+
path_or_wrapper.output = open_stream(path_or_wrapper.output)
|
|
258
|
+
path_or_wrapper
|
|
259
|
+
else
|
|
260
|
+
RSpec::Support::DirectoryMaker.mkdir_p(File.dirname(path_or_wrapper))
|
|
261
|
+
File.new(path_or_wrapper, 'w')
|
|
262
|
+
end
|
|
253
263
|
end
|
|
254
264
|
end
|
|
255
265
|
end
|
data/lib/rspec/core/hooks.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
|
|
@@ -49,16 +49,34 @@ module RSpec
|
|
|
49
49
|
# @private
|
|
50
50
|
class PrintVersion
|
|
51
51
|
def call(_options, _err, out)
|
|
52
|
-
|
|
52
|
+
overall_version = RSpec::Core::Version::STRING
|
|
53
|
+
unless overall_version =~ /[a-zA-Z]+/
|
|
54
|
+
overall_version = overall_version.split('.').first(2).join('.')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
out.puts "RSpec #{overall_version}"
|
|
58
|
+
|
|
59
|
+
[:Core, :Expectations, :Mocks, :Rails, :Support].each do |const_name|
|
|
60
|
+
lib_name = const_name.to_s.downcase
|
|
61
|
+
begin
|
|
62
|
+
require "rspec/#{lib_name}/version"
|
|
63
|
+
rescue LoadError
|
|
64
|
+
# Not worth mentioning libs that are not installed
|
|
65
|
+
nil
|
|
66
|
+
else
|
|
67
|
+
out.puts " - rspec-#{lib_name} #{RSpec.const_get(const_name)::Version::STRING}"
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
53
71
|
0
|
|
54
72
|
end
|
|
55
73
|
end
|
|
56
74
|
|
|
57
75
|
# @private
|
|
58
|
-
PrintHelp = Struct.new(:parser, :
|
|
76
|
+
PrintHelp = Struct.new(:parser, :hidden_options) do
|
|
59
77
|
def call(_options, _err, out)
|
|
60
|
-
# Removing the
|
|
61
|
-
out.puts parser.to_s.gsub(/^\s+(#{
|
|
78
|
+
# Removing the hidden options from the output.
|
|
79
|
+
out.puts parser.to_s.gsub(/^\s+(#{hidden_options.join('|')})\b.*$\n/, '')
|
|
62
80
|
0
|
|
63
81
|
end
|
|
64
82
|
end
|
|
@@ -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
|
data/lib/rspec/core/metadata.rb
CHANGED
|
@@ -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
|
|
@@ -13,24 +13,19 @@ module RSpec
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
# @private
|
|
16
|
-
def filter_applies?(key,
|
|
16
|
+
def filter_applies?(key, filter_value, metadata)
|
|
17
17
|
silence_metadata_example_group_deprecations do
|
|
18
|
-
return location_filter_applies?(
|
|
19
|
-
return id_filter_applies?(
|
|
20
|
-
return filters_apply?(key,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
when Proc
|
|
30
|
-
proc_filter_applies?(key, value, metadata)
|
|
31
|
-
else
|
|
32
|
-
metadata[key].to_s == value.to_s
|
|
33
|
-
end
|
|
18
|
+
return location_filter_applies?(filter_value, metadata) if key == :locations
|
|
19
|
+
return id_filter_applies?(filter_value, metadata) if key == :ids
|
|
20
|
+
return filters_apply?(key, filter_value, metadata) if Hash === filter_value
|
|
21
|
+
|
|
22
|
+
meta_value = metadata.fetch(key) { return false }
|
|
23
|
+
|
|
24
|
+
return true if TrueClass === filter_value && meta_value
|
|
25
|
+
return proc_filter_applies?(key, filter_value, metadata) if Proc === filter_value
|
|
26
|
+
return filter_applies_to_any_value?(key, filter_value, metadata) if Array === meta_value
|
|
27
|
+
|
|
28
|
+
filter_value === meta_value || filter_value.to_s == meta_value.to_s
|
|
34
29
|
end
|
|
35
30
|
end
|
|
36
31
|
|
|
@@ -116,6 +111,10 @@ module RSpec
|
|
|
116
111
|
@items_and_filters.unshift [item, metadata]
|
|
117
112
|
end
|
|
118
113
|
|
|
114
|
+
def delete(item, metadata)
|
|
115
|
+
@items_and_filters.delete [item, metadata]
|
|
116
|
+
end
|
|
117
|
+
|
|
119
118
|
def items_for(request_meta)
|
|
120
119
|
@items_and_filters.each_with_object([]) do |(item, item_meta), to_return|
|
|
121
120
|
to_return << item if item_meta.empty? ||
|
|
@@ -172,6 +171,11 @@ module RSpec
|
|
|
172
171
|
handle_mutation(metadata)
|
|
173
172
|
end
|
|
174
173
|
|
|
174
|
+
def delete(item, metadata)
|
|
175
|
+
super
|
|
176
|
+
reconstruct_caches
|
|
177
|
+
end
|
|
178
|
+
|
|
175
179
|
def items_for(metadata)
|
|
176
180
|
# The filtering of `metadata` to `applicable_metadata` is the key thing
|
|
177
181
|
# that makes the memoization actually useful in practice, since each
|
|
@@ -196,6 +200,14 @@ module RSpec
|
|
|
196
200
|
|
|
197
201
|
private
|
|
198
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
|
+
|
|
199
211
|
def handle_mutation(metadata)
|
|
200
212
|
@applicable_keys.merge(metadata.keys)
|
|
201
213
|
@proc_keys.merge(proc_keys_from metadata)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
RSpec::Support.require_rspec_core "formatters/console_codes"
|
|
1
2
|
RSpec::Support.require_rspec_core "formatters/exception_presenter"
|
|
2
3
|
RSpec::Support.require_rspec_core "formatters/helpers"
|
|
3
4
|
RSpec::Support.require_rspec_core "shell_escape"
|
|
@@ -51,8 +52,7 @@ module RSpec::Core
|
|
|
51
52
|
FailedExampleNotification
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
klass.new(example, exception_presenter)
|
|
55
|
+
klass.new(example)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
private_class_method :new
|
|
@@ -200,9 +200,15 @@ module RSpec::Core
|
|
|
200
200
|
@exception_presenter.fully_formatted(failure_number, colorizer)
|
|
201
201
|
end
|
|
202
202
|
|
|
203
|
+
# @return [Array<string>] The failure information fully formatted in the way that
|
|
204
|
+
# RSpec's built-in formatters emit, split by line.
|
|
205
|
+
def fully_formatted_lines(failure_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes)
|
|
206
|
+
@exception_presenter.fully_formatted_lines(failure_number, colorizer)
|
|
207
|
+
end
|
|
208
|
+
|
|
203
209
|
private
|
|
204
210
|
|
|
205
|
-
def initialize(example, exception_presenter)
|
|
211
|
+
def initialize(example, exception_presenter=Formatters::ExceptionPresenter::Factory.new(example).build)
|
|
206
212
|
@exception_presenter = exception_presenter
|
|
207
213
|
super(example)
|
|
208
214
|
end
|
|
@@ -281,8 +287,12 @@ module RSpec::Core
|
|
|
281
287
|
# @attr pending_examples [Array<RSpec::Core::Example>] the pending examples
|
|
282
288
|
# @attr load_time [Float] the number of seconds taken to boot RSpec
|
|
283
289
|
# and load the spec files
|
|
290
|
+
# @attr errors_outside_of_examples_count [Integer] the number of errors that
|
|
291
|
+
# have occurred processing
|
|
292
|
+
# the spec suite
|
|
284
293
|
SummaryNotification = Struct.new(:duration, :examples, :failed_examples,
|
|
285
|
-
:pending_examples, :load_time
|
|
294
|
+
:pending_examples, :load_time,
|
|
295
|
+
:errors_outside_of_examples_count)
|
|
286
296
|
class SummaryNotification
|
|
287
297
|
# @api
|
|
288
298
|
# @return [Fixnum] the number of examples run
|
|
@@ -308,6 +318,11 @@ module RSpec::Core
|
|
|
308
318
|
summary = Formatters::Helpers.pluralize(example_count, "example")
|
|
309
319
|
summary << ", " << Formatters::Helpers.pluralize(failure_count, "failure")
|
|
310
320
|
summary << ", #{pending_count} pending" if pending_count > 0
|
|
321
|
+
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"
|
|
325
|
+
end
|
|
311
326
|
summary
|
|
312
327
|
end
|
|
313
328
|
|
|
@@ -321,7 +336,7 @@ module RSpec::Core
|
|
|
321
336
|
# specific colors.
|
|
322
337
|
# @return [String] A colorized results line.
|
|
323
338
|
def colorized_totals_line(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
|
|
324
|
-
if failure_count > 0
|
|
339
|
+
if failure_count > 0 || errors_outside_of_examples_count > 0
|
|
325
340
|
colorizer.wrap(totals_line, RSpec.configuration.failure_color)
|
|
326
341
|
elsif pending_count > 0
|
|
327
342
|
colorizer.wrap(totals_line, RSpec.configuration.pending_color)
|