rspec-core 3.0.0.beta2 → 3.0.0.rc1
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 +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.yardopts +1 -0
- data/Changelog.md +297 -57
- data/README.md +16 -13
- data/lib/rspec/core.rb +55 -84
- data/lib/rspec/core/backport_random.rb +35 -3
- data/lib/rspec/core/backtrace_formatter.rb +4 -13
- data/lib/rspec/core/configuration.rb +330 -114
- data/lib/rspec/core/configuration_options.rb +38 -22
- data/lib/rspec/core/drb.rb +111 -0
- data/lib/rspec/core/dsl.rb +8 -2
- data/lib/rspec/core/example.rb +203 -94
- data/lib/rspec/core/example_group.rb +344 -316
- data/lib/rspec/core/filter_manager.rb +135 -90
- data/lib/rspec/core/flat_map.rb +1 -0
- data/lib/rspec/core/formatters.rb +50 -14
- data/lib/rspec/core/formatters/base_formatter.rb +32 -138
- data/lib/rspec/core/formatters/base_text_formatter.rb +32 -253
- data/lib/rspec/core/formatters/console_codes.rb +65 -0
- data/lib/rspec/core/formatters/deprecation_formatter.rb +24 -15
- data/lib/rspec/core/formatters/documentation_formatter.rb +7 -10
- data/lib/rspec/core/formatters/helpers.rb +15 -9
- data/lib/rspec/core/formatters/html_formatter.rb +17 -16
- data/lib/rspec/core/formatters/html_printer.rb +1 -0
- data/lib/rspec/core/formatters/json_formatter.rb +18 -20
- data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +6 -7
- data/lib/rspec/core/formatters/snippet_extractor.rb +8 -6
- data/lib/rspec/core/hooks.rb +131 -125
- data/lib/rspec/core/memoized_helpers.rb +31 -26
- data/lib/rspec/core/metadata.rb +277 -184
- data/lib/rspec/core/metadata_filter.rb +86 -0
- data/lib/rspec/core/minitest_assertions_adapter.rb +28 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +1 -1
- data/lib/rspec/core/mocking_adapters/mocha.rb +1 -1
- data/lib/rspec/core/mocking_adapters/null.rb +1 -1
- data/lib/rspec/core/mocking_adapters/rr.rb +2 -1
- data/lib/rspec/core/mocking_adapters/rspec.rb +1 -1
- data/lib/rspec/core/notifications.rb +435 -24
- data/lib/rspec/core/option_parser.rb +16 -25
- data/lib/rspec/core/ordering.rb +3 -1
- data/lib/rspec/core/pending.rb +57 -33
- data/lib/rspec/core/project_initializer.rb +2 -0
- data/lib/rspec/core/project_initializer/spec_helper.rb +5 -4
- data/lib/rspec/core/rake_task.rb +45 -20
- data/lib/rspec/core/reporter.rb +50 -22
- data/lib/rspec/core/ruby_project.rb +1 -0
- data/lib/rspec/core/runner.rb +93 -39
- data/lib/rspec/core/shared_context.rb +7 -5
- data/lib/rspec/core/shared_example_group.rb +85 -77
- data/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
- data/lib/rspec/core/version.rb +3 -1
- data/lib/rspec/core/warnings.rb +35 -17
- data/lib/rspec/core/world.rb +57 -5
- metadata +56 -369
- metadata.gz.sig +3 -3
- data/features/README.md +0 -13
- data/features/Upgrade.md +0 -352
- data/features/command_line/README.md +0 -25
- data/features/command_line/dry_run.feature +0 -29
- data/features/command_line/example_name_option.feature +0 -97
- data/features/command_line/exit_status.feature +0 -82
- data/features/command_line/fail_fast.feature +0 -26
- data/features/command_line/format_option.feature +0 -75
- data/features/command_line/init.feature +0 -57
- data/features/command_line/line_number_appended_to_path.feature +0 -140
- data/features/command_line/line_number_option.feature +0 -58
- data/features/command_line/order.feature +0 -25
- data/features/command_line/pattern_option.feature +0 -49
- data/features/command_line/rake_task.feature +0 -122
- data/features/command_line/randomization.feature +0 -63
- data/features/command_line/require_option.feature +0 -43
- data/features/command_line/ruby.feature +0 -23
- data/features/command_line/tag.feature +0 -98
- data/features/command_line/warnings_option.feature +0 -29
- data/features/configuration/alias_example_to.feature +0 -39
- data/features/configuration/backtrace_exclusion_patterns.feature +0 -105
- data/features/configuration/custom_settings.feature +0 -84
- data/features/configuration/default_path.feature +0 -38
- data/features/configuration/deprecation_stream.feature +0 -58
- data/features/configuration/enable_global_dsl.feature +0 -54
- data/features/configuration/fail_fast.feature +0 -77
- data/features/configuration/failure_exit_code.feature +0 -36
- data/features/configuration/order_and_seed.feature +0 -3
- data/features/configuration/output_stream.feature +0 -24
- data/features/configuration/overriding_global_ordering.feature +0 -93
- data/features/configuration/pattern.feature +0 -38
- data/features/configuration/profile.feature +0 -220
- data/features/configuration/read_options_from_file.feature +0 -90
- data/features/configuration/run_all_when_everything_filtered.feature +0 -76
- data/features/example_groups/aliasing.feature +0 -48
- data/features/example_groups/basic_structure.feature +0 -55
- data/features/example_groups/shared_context.feature +0 -74
- data/features/example_groups/shared_examples.feature +0 -286
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
- data/features/filtering/exclusion_filters.feature +0 -135
- data/features/filtering/if_and_unless.feature +0 -138
- data/features/filtering/inclusion_filters.feature +0 -101
- data/features/formatters/configurable_colors.feature +0 -31
- data/features/formatters/custom_formatter.feature +0 -68
- data/features/formatters/json_formatter.feature +0 -30
- data/features/formatters/regression_tests.feature +0 -95
- data/features/formatters/text_formatter.feature +0 -46
- data/features/helper_methods/arbitrary_methods.feature +0 -40
- data/features/helper_methods/let.feature +0 -50
- data/features/helper_methods/modules.feature +0 -146
- data/features/hooks/around_hooks.feature +0 -344
- data/features/hooks/before_and_after_hooks.feature +0 -427
- data/features/hooks/filtering.feature +0 -232
- data/features/metadata/current_example.feature +0 -56
- data/features/metadata/described_class.feature +0 -17
- data/features/metadata/user_defined.feature +0 -100
- data/features/mock_framework_integration/use_any_framework.feature +0 -106
- data/features/mock_framework_integration/use_flexmock.feature +0 -94
- data/features/mock_framework_integration/use_mocha.feature +0 -95
- data/features/mock_framework_integration/use_rr.feature +0 -96
- data/features/mock_framework_integration/use_rspec.feature +0 -95
- data/features/pending_and_skipped_examples/README.md +0 -3
- data/features/pending_and_skipped_examples/pending_examples.feature +0 -118
- data/features/pending_and_skipped_examples/skipped_examples.feature +0 -106
- data/features/spec_files/arbitrary_file_suffix.feature +0 -13
- data/features/step_definitions/additional_cli_steps.rb +0 -83
- data/features/subject/explicit_subject.feature +0 -101
- data/features/subject/implicit_subject.feature +0 -63
- data/features/subject/one_liner_syntax.feature +0 -71
- data/features/support/env.rb +0 -21
- data/features/support/require_expect_syntax_in_aruba_specs.rb +0 -16
- data/features/support/rubinius.rb +0 -6
- data/lib/rspec/core/command_line.rb +0 -35
- data/lib/rspec/core/drb_command_line.rb +0 -26
- data/lib/rspec/core/drb_options.rb +0 -87
- data/lib/rspec/core/formatters/legacy_formatter.rb +0 -227
- data/lib/rspec/core/shared_example_group/collection.rb +0 -27
- data/spec/command_line/order_spec.rb +0 -211
- data/spec/rspec/core/backtrace_formatter_spec.rb +0 -230
- data/spec/rspec/core/command_line_spec.rb +0 -112
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -409
- data/spec/rspec/core/configuration_spec.rb +0 -1479
- data/spec/rspec/core/drb_command_line_spec.rb +0 -102
- data/spec/rspec/core/drb_options_spec.rb +0 -193
- data/spec/rspec/core/dsl_spec.rb +0 -88
- data/spec/rspec/core/example_group_spec.rb +0 -1533
- data/spec/rspec/core/example_spec.rb +0 -642
- data/spec/rspec/core/filter_manager_spec.rb +0 -229
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -64
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -303
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -208
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -75
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
- data/spec/rspec/core/formatters/html_formatted-2.1.0.html +0 -392
- data/spec/rspec/core/formatters/html_formatted.html +0 -397
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -122
- data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -206
- data/spec/rspec/core/formatters/legacy_formatter_spec.rb +0 -137
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -43
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
- data/spec/rspec/core/formatters_spec.rb +0 -120
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -294
- data/spec/rspec/core/memoized_helpers_spec.rb +0 -495
- data/spec/rspec/core/metadata_spec.rb +0 -491
- data/spec/rspec/core/option_parser_spec.rb +0 -262
- data/spec/rspec/core/ordering_spec.rb +0 -102
- data/spec/rspec/core/pending_example_spec.rb +0 -117
- data/spec/rspec/core/pending_spec.rb +0 -8
- data/spec/rspec/core/project_initializer_spec.rb +0 -73
- data/spec/rspec/core/rake_task_spec.rb +0 -146
- data/spec/rspec/core/random_spec.rb +0 -47
- data/spec/rspec/core/reporter_spec.rb +0 -155
- data/spec/rspec/core/resources/a_bar.rb +0 -0
- data/spec/rspec/core/resources/a_foo.rb +0 -0
- data/spec/rspec/core/resources/a_spec.rb +0 -1
- data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
- data/spec/rspec/core/resources/formatter_specs.rb +0 -58
- data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
- data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
- data/spec/rspec/core/ruby_project_spec.rb +0 -26
- data/spec/rspec/core/runner_spec.rb +0 -151
- data/spec/rspec/core/shared_context_spec.rb +0 -102
- data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -57
- data/spec/rspec/core/shared_example_group_spec.rb +0 -114
- data/spec/rspec/core/warnings_spec.rb +0 -29
- data/spec/rspec/core/world_spec.rb +0 -142
- data/spec/rspec/core_spec.rb +0 -91
- data/spec/spec_helper.rb +0 -160
- data/spec/support/config_options_helper.rb +0 -13
- data/spec/support/formatter_support.rb +0 -83
- data/spec/support/helper_methods.rb +0 -26
- data/spec/support/isolate_load_path_mutation.rb +0 -5
- data/spec/support/isolated_directory.rb +0 -10
- data/spec/support/isolated_home_directory.rb +0 -16
- data/spec/support/legacy_formatter_using_sub_classing_example.rb +0 -87
- data/spec/support/matchers.rb +0 -85
- data/spec/support/mathn_integration_support.rb +0 -12
- data/spec/support/old_style_formatter_example.rb +0 -69
- data/spec/support/shared_example_groups.rb +0 -13
- data/spec/support/spec_files.rb +0 -44
- data/spec/support/stderr_splitter.rb +0 -36
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
RSpec::Support.require_rspec_core "formatters/base_formatter"
|
2
|
+
RSpec::Support.require_rspec_core "formatters/console_codes"
|
3
3
|
|
4
4
|
module RSpec
|
5
5
|
module Core
|
@@ -12,284 +12,63 @@ module RSpec
|
|
12
12
|
# @see RSpec::Core::Reporter
|
13
13
|
class BaseTextFormatter < BaseFormatter
|
14
14
|
Formatters.register self, :message, :dump_summary, :dump_failures,
|
15
|
-
:
|
16
|
-
|
17
|
-
def message(notification)
|
18
|
-
output.puts notification.message
|
19
|
-
end
|
20
|
-
|
21
|
-
def dump_failures(notification)
|
22
|
-
return if failed_examples.empty?
|
23
|
-
output.puts
|
24
|
-
output.puts "Failures:"
|
25
|
-
failed_examples.each_with_index do |example, index|
|
26
|
-
output.puts
|
27
|
-
pending_fixed?(example) ? dump_pending_fixed(example, index) : dump_failure(example, index)
|
28
|
-
dump_backtrace(example)
|
29
|
-
end
|
30
|
-
end
|
15
|
+
:dump_pending, :seed
|
31
16
|
|
17
|
+
# @method message
|
32
18
|
# @api public
|
33
19
|
#
|
34
|
-
#
|
35
|
-
# pending, and green otherwise.
|
20
|
+
# Used by the reporter to send messages to the output stream.
|
36
21
|
#
|
37
|
-
# @param [
|
38
|
-
def
|
39
|
-
|
40
|
-
color(summary.summary_line, RSpec.configuration.failure_color)
|
41
|
-
elsif summary.pending_count > 0
|
42
|
-
color(summary.summary_line, RSpec.configuration.pending_color)
|
43
|
-
else
|
44
|
-
color(summary.summary_line, RSpec.configuration.success_color)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def dump_summary(summary)
|
49
|
-
dump_profile unless mute_profile_output?(summary.failure_count)
|
50
|
-
output.puts "\nFinished in #{format_duration(summary.duration)}\n"
|
51
|
-
output.puts colorise_summary(summary)
|
52
|
-
dump_commands_to_rerun_failed_examples
|
22
|
+
# @param notification [MessageNotification] containing message
|
23
|
+
def message(notification)
|
24
|
+
output.puts notification.message
|
53
25
|
end
|
54
26
|
|
27
|
+
# @method dump_failures
|
55
28
|
# @api public
|
56
29
|
#
|
57
|
-
#
|
30
|
+
# Dumps detailed information about each example failure.
|
58
31
|
#
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
output.puts
|
63
|
-
output.puts
|
64
|
-
|
65
|
-
failed_examples.each do |example|
|
66
|
-
output.puts(failure_color("rspec #{RSpec::Core::Metadata::relative_path(example.location)}") + " " + detail_color("# #{example.full_description}"))
|
67
|
-
end
|
32
|
+
# @param notification [NullNotification]
|
33
|
+
def dump_failures(notification)
|
34
|
+
return if notification.failure_notifications.empty?
|
35
|
+
output.puts notification.fully_formatted_failed_examples
|
68
36
|
end
|
69
37
|
|
38
|
+
# @method dump_summary
|
70
39
|
# @api public
|
71
40
|
#
|
72
|
-
#
|
41
|
+
# This method is invoked after the dumping of examples and failures. Each parameter
|
42
|
+
# is assigned to a corresponding attribute.
|
73
43
|
#
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
# @api private
|
80
|
-
def dump_profile_slowest_examples
|
81
|
-
sorted_examples = slowest_examples
|
82
|
-
|
83
|
-
time_taken = sorted_examples[:slows] / sorted_examples[:total]
|
84
|
-
percentage = '%.1f' % ((time_taken.nan? ? 0.0 : time_taken) * 100)
|
85
|
-
|
86
|
-
output.puts "\nTop #{sorted_examples[:examples].size} slowest examples (#{format_seconds(sorted_examples[:slows])} seconds, #{percentage}% of total time):\n"
|
87
|
-
|
88
|
-
sorted_examples[:examples].each do |example|
|
89
|
-
output.puts " #{example.full_description}"
|
90
|
-
output.puts " #{bold(format_seconds(example.execution_result[:run_time]))} #{bold("seconds")} #{format_caller(example.location)}"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# @api private
|
95
|
-
def dump_profile_slowest_example_groups
|
96
|
-
|
97
|
-
sorted_groups = slowest_groups
|
98
|
-
return if sorted_groups.empty?
|
99
|
-
|
100
|
-
output.puts "\nTop #{sorted_groups.size} slowest example groups:"
|
101
|
-
slowest_groups.each do |loc, hash|
|
102
|
-
average = "#{bold(format_seconds(hash[:average]))} #{bold("seconds")} average"
|
103
|
-
total = "#{format_seconds(hash[:total_time])} seconds"
|
104
|
-
count = pluralize(hash[:count], "example")
|
105
|
-
output.puts " #{hash[:description]}"
|
106
|
-
output.puts " #{average} (#{total} / #{count}) #{loc}"
|
107
|
-
end
|
44
|
+
# @param summary [SummaryNotification] containing duration, example_count,
|
45
|
+
# failure_count and pending_count
|
46
|
+
def dump_summary(summary)
|
47
|
+
output.puts summary.fully_formatted
|
108
48
|
end
|
109
49
|
|
50
|
+
# @private
|
110
51
|
def dump_pending(notification)
|
111
|
-
|
112
|
-
|
113
|
-
output.puts "Pending:"
|
114
|
-
pending_examples.each do |pending_example|
|
115
|
-
output.puts pending_color(" #{pending_example.full_description}")
|
116
|
-
output.puts detail_color(" # #{pending_example.execution_result[:pending_message]}")
|
117
|
-
output.puts detail_color(" # #{format_caller(pending_example.location)}")
|
118
|
-
end
|
119
|
-
end
|
52
|
+
return if notification.pending_examples.empty?
|
53
|
+
output.puts notification.fully_formatted_pending_examples
|
120
54
|
end
|
121
55
|
|
56
|
+
# @private
|
122
57
|
def seed(notification)
|
123
58
|
return unless notification.seed_used?
|
124
|
-
output.puts
|
125
|
-
output.puts "Randomized with seed #{notification.seed}"
|
126
|
-
output.puts
|
59
|
+
output.puts notification.fully_formatted
|
127
60
|
end
|
128
61
|
|
62
|
+
# @api public
|
63
|
+
#
|
64
|
+
# Invoked at the very end, `close` allows the formatter to clean
|
65
|
+
# up resources, e.g. open streams, etc.
|
66
|
+
#
|
67
|
+
# @param notification [NullNotification]
|
129
68
|
def close(notification)
|
130
69
|
output.close if IO === output && output != $stdout
|
131
70
|
end
|
132
71
|
|
133
|
-
VT100_COLORS = {
|
134
|
-
:black => 30,
|
135
|
-
:red => 31,
|
136
|
-
:green => 32,
|
137
|
-
:yellow => 33,
|
138
|
-
:blue => 34,
|
139
|
-
:magenta => 35,
|
140
|
-
:cyan => 36,
|
141
|
-
:white => 37
|
142
|
-
}
|
143
|
-
|
144
|
-
VT100_COLOR_CODES = VT100_COLORS.values.to_set
|
145
|
-
|
146
|
-
def color_code_for(code_or_symbol)
|
147
|
-
if VT100_COLOR_CODES.include?(code_or_symbol)
|
148
|
-
code_or_symbol
|
149
|
-
else
|
150
|
-
VT100_COLORS.fetch(code_or_symbol) do
|
151
|
-
color_code_for(:white)
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
def colorize(text, code_or_symbol)
|
157
|
-
"\e[#{color_code_for(code_or_symbol)}m#{text}\e[0m"
|
158
|
-
end
|
159
|
-
|
160
|
-
protected
|
161
|
-
|
162
|
-
def bold(text)
|
163
|
-
color_enabled? ? "\e[1m#{text}\e[0m" : text
|
164
|
-
end
|
165
|
-
|
166
|
-
def color(text, color_code)
|
167
|
-
color_enabled? ? colorize(text, color_code) : text
|
168
|
-
end
|
169
|
-
|
170
|
-
def failure_color(text)
|
171
|
-
color(text, RSpec.configuration.failure_color)
|
172
|
-
end
|
173
|
-
|
174
|
-
def success_color(text)
|
175
|
-
color(text, RSpec.configuration.success_color)
|
176
|
-
end
|
177
|
-
|
178
|
-
def pending_color(text)
|
179
|
-
color(text, RSpec.configuration.pending_color)
|
180
|
-
end
|
181
|
-
|
182
|
-
def fixed_color(text)
|
183
|
-
color(text, RSpec.configuration.fixed_color)
|
184
|
-
end
|
185
|
-
|
186
|
-
def detail_color(text)
|
187
|
-
color(text, RSpec.configuration.detail_color)
|
188
|
-
end
|
189
|
-
|
190
|
-
def default_color(text)
|
191
|
-
color(text, RSpec.configuration.default_color)
|
192
|
-
end
|
193
|
-
|
194
|
-
def red(text)
|
195
|
-
RSpec.deprecate("RSpec::Core::Formatters::BaseTextFormatter#red", :replacement => "#failure_color")
|
196
|
-
color(text, :red)
|
197
|
-
end
|
198
|
-
|
199
|
-
def green(text)
|
200
|
-
RSpec.deprecate("RSpec::Core::Formatters::BaseTextFormatter#green", :replacement => "#success_color")
|
201
|
-
color(text, :green)
|
202
|
-
end
|
203
|
-
|
204
|
-
def yellow(text)
|
205
|
-
RSpec.deprecate("RSpec::Core::Formatters::BaseTextFormatter#yellow", :replacement => "#pending_color")
|
206
|
-
color(text, :yellow)
|
207
|
-
end
|
208
|
-
|
209
|
-
def blue(text)
|
210
|
-
RSpec.deprecate("RSpec::Core::Formatters::BaseTextFormatter#blue", :replacement => "#fixed_color")
|
211
|
-
color(text, :blue)
|
212
|
-
end
|
213
|
-
|
214
|
-
def magenta(text)
|
215
|
-
RSpec.deprecate("RSpec::Core::Formatters::BaseTextFormatter#magenta")
|
216
|
-
color(text, :magenta)
|
217
|
-
end
|
218
|
-
|
219
|
-
def cyan(text)
|
220
|
-
RSpec.deprecate("RSpec::Core::Formatters::BaseTextFormatter#cyan", :replacement => "#detail_color")
|
221
|
-
color(text, :cyan)
|
222
|
-
end
|
223
|
-
|
224
|
-
def white(text)
|
225
|
-
RSpec.deprecate("RSpec::Core::Formatters::BaseTextFormatter#white", :replacement => "#default_color")
|
226
|
-
color(text, :white)
|
227
|
-
end
|
228
|
-
|
229
|
-
def short_padding
|
230
|
-
' '
|
231
|
-
end
|
232
|
-
|
233
|
-
def long_padding
|
234
|
-
' '
|
235
|
-
end
|
236
|
-
|
237
|
-
private
|
238
|
-
|
239
|
-
def format_caller(caller_info)
|
240
|
-
configuration.backtrace_formatter.backtrace_line(caller_info.to_s.split(':in `block').first)
|
241
|
-
end
|
242
|
-
|
243
|
-
def dump_backtrace(example, key = :exception)
|
244
|
-
format_backtrace(example.execution_result[key].backtrace, example).each do |backtrace_info|
|
245
|
-
output.puts detail_color("#{long_padding}# #{backtrace_info}")
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
def dump_pending_fixed(example, index)
|
250
|
-
output.puts "#{short_padding}#{index.next}) #{example.full_description} FIXED"
|
251
|
-
output.puts fixed_color("#{long_padding}Expected pending '#{example.metadata[:execution_result][:pending_message]}' to fail. No Error was raised.")
|
252
|
-
end
|
253
|
-
|
254
|
-
def pending_fixed?(example)
|
255
|
-
example.execution_result[:pending_fixed]
|
256
|
-
end
|
257
|
-
|
258
|
-
def dump_failure(example, index)
|
259
|
-
output.puts "#{short_padding}#{index.next}) #{example.full_description}"
|
260
|
-
dump_failure_info(example)
|
261
|
-
end
|
262
|
-
|
263
|
-
def dump_failure_info(example, key = :exception)
|
264
|
-
exception = example.execution_result[key]
|
265
|
-
exception_class_name = exception_class_name_for(exception)
|
266
|
-
output.puts "#{long_padding}#{failure_color("Failure/Error:")} #{failure_color(read_failed_line(exception, example).strip)}"
|
267
|
-
output.puts "#{long_padding}#{failure_color(exception_class_name)}:" unless exception_class_name =~ /RSpec/
|
268
|
-
exception.message.to_s.split("\n").each { |line| output.puts "#{long_padding} #{failure_color(line)}" } if exception.message
|
269
|
-
|
270
|
-
if shared_group = find_shared_group(example)
|
271
|
-
dump_shared_failure_info(shared_group)
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
def exception_class_name_for(exception)
|
276
|
-
name = exception.class.name.to_s
|
277
|
-
name ="(anonymous error class)" if name == ''
|
278
|
-
name
|
279
|
-
end
|
280
|
-
|
281
|
-
def dump_shared_failure_info(group)
|
282
|
-
output.puts "#{long_padding}Shared Example Group: \"#{group.metadata[:shared_group_name]}\" called from " +
|
283
|
-
"#{configuration.backtrace_formatter.backtrace_line(group.metadata[:example_group][:location])}"
|
284
|
-
end
|
285
|
-
|
286
|
-
def find_shared_group(example)
|
287
|
-
group_and_parent_groups(example).find {|group| group.metadata[:shared_group_name]}
|
288
|
-
end
|
289
|
-
|
290
|
-
def group_and_parent_groups(example)
|
291
|
-
example.example_group.parent_groups + [example.example_group]
|
292
|
-
end
|
293
72
|
end
|
294
73
|
end
|
295
74
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Core
|
3
|
+
module Formatters
|
4
|
+
# ConsoleCodes provides helpers for formatting console output
|
5
|
+
# with ANSI codes, e.g. color's and bold.
|
6
|
+
module ConsoleCodes
|
7
|
+
# @private
|
8
|
+
VT100_CODES =
|
9
|
+
{
|
10
|
+
:black => 30,
|
11
|
+
:red => 31,
|
12
|
+
:green => 32,
|
13
|
+
:yellow => 33,
|
14
|
+
:blue => 34,
|
15
|
+
:magenta => 35,
|
16
|
+
:cyan => 36,
|
17
|
+
:white => 37,
|
18
|
+
:bold => 1,
|
19
|
+
}
|
20
|
+
# @private
|
21
|
+
VT100_CODE_VALUES = VT100_CODES.invert
|
22
|
+
|
23
|
+
module_function
|
24
|
+
|
25
|
+
# Fetches the correct code for the supplied symbol, or checks
|
26
|
+
# that a code is valid. Defaults to white (37).
|
27
|
+
#
|
28
|
+
# @param code_or_symbol [Symbol, Fixnum] Symbol or code to check
|
29
|
+
# @return [Fixnum] a console code
|
30
|
+
def console_code_for(code_or_symbol)
|
31
|
+
if RSpec.configuration.respond_to?(:"#{code_or_symbol}_color")
|
32
|
+
console_code_for configuration_color(code_or_symbol)
|
33
|
+
elsif VT100_CODE_VALUES.has_key?(code_or_symbol)
|
34
|
+
code_or_symbol
|
35
|
+
else
|
36
|
+
VT100_CODES.fetch(code_or_symbol) do
|
37
|
+
console_code_for(:white)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Wraps a piece of text in ANSI codes with the supplied code. Will
|
43
|
+
# only apply the control code if `RSpec.configuration.color_enabled?`
|
44
|
+
# returns true.
|
45
|
+
#
|
46
|
+
# @param text [String] the text to wrap
|
47
|
+
# @param code_or_symbol [Symbol, Fixnum] the desired control code
|
48
|
+
# @return [String] the wrapped text
|
49
|
+
def wrap(text, code_or_symbol)
|
50
|
+
if RSpec.configuration.color_enabled?
|
51
|
+
"\e[#{console_code_for(code_or_symbol)}m#{text}\e[0m"
|
52
|
+
else
|
53
|
+
text
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# @private
|
58
|
+
def configuration_color(code)
|
59
|
+
RSpec.configuration.__send__(:"#{code}_color")
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -1,9 +1,10 @@
|
|
1
|
-
|
1
|
+
RSpec::Support.require_rspec_core "formatters/helpers"
|
2
2
|
require 'set'
|
3
3
|
|
4
4
|
module RSpec
|
5
5
|
module Core
|
6
6
|
module Formatters
|
7
|
+
# @private
|
7
8
|
class DeprecationFormatter
|
8
9
|
Formatters.register self, :deprecation, :deprecation_summary
|
9
10
|
|
@@ -56,6 +57,9 @@ module RSpec
|
|
56
57
|
|deprecation warnings into errors, giving you the full backtrace.
|
57
58
|
EOS
|
58
59
|
|
60
|
+
DEPRECATION_STREAM_NOTICE = "Pass `--deprecation-out` or set " +
|
61
|
+
"`config.deprecation_stream` to a file for full output."
|
62
|
+
|
59
63
|
SpecifiedDeprecationMessage = Struct.new(:type) do
|
60
64
|
def initialize(data)
|
61
65
|
@message = data.message
|
@@ -63,17 +67,23 @@ module RSpec
|
|
63
67
|
end
|
64
68
|
|
65
69
|
def to_s
|
66
|
-
@message
|
70
|
+
output_formatted @message
|
67
71
|
end
|
68
72
|
|
69
73
|
def too_many_warnings_message
|
70
|
-
msg = "Too many similar deprecation messages reported, disregarding further reports."
|
71
|
-
msg <<
|
74
|
+
msg = "Too many similar deprecation messages reported, disregarding further reports. "
|
75
|
+
msg << DEPRECATION_STREAM_NOTICE
|
72
76
|
msg
|
73
77
|
end
|
74
78
|
|
75
79
|
private
|
76
80
|
|
81
|
+
def output_formatted(str)
|
82
|
+
return str unless str.lines.count > 1
|
83
|
+
separator = "#{'-' * 80}"
|
84
|
+
"#{separator}\n#{str.chomp}\n#{separator}"
|
85
|
+
end
|
86
|
+
|
77
87
|
def deprecation_type_for(data)
|
78
88
|
data.message.gsub(/(\w+\/)+\w+\.rb:\d+/, '')
|
79
89
|
end
|
@@ -93,12 +103,13 @@ module RSpec
|
|
93
103
|
end
|
94
104
|
|
95
105
|
def too_many_warnings_message
|
96
|
-
msg = "Too many uses of deprecated '#{type}'."
|
97
|
-
msg <<
|
106
|
+
msg = "Too many uses of deprecated '#{type}'. "
|
107
|
+
msg << DEPRECATION_STREAM_NOTICE
|
98
108
|
msg
|
99
109
|
end
|
100
110
|
end
|
101
111
|
|
112
|
+
# @private
|
102
113
|
class ImmediatePrinter
|
103
114
|
attr_reader :deprecation_stream, :summary_stream, :deprecation_formatter
|
104
115
|
|
@@ -120,11 +131,10 @@ module RSpec
|
|
120
131
|
end
|
121
132
|
end
|
122
133
|
|
134
|
+
# @private
|
123
135
|
class DelayedPrinter
|
124
136
|
TOO_MANY_USES_LIMIT = 4
|
125
137
|
|
126
|
-
include ::RSpec::Core::Formatters::Helpers
|
127
|
-
|
128
138
|
attr_reader :deprecation_stream, :summary_stream, :deprecation_formatter
|
129
139
|
|
130
140
|
def initialize(deprecation_stream, summary_stream, deprecation_formatter)
|
@@ -156,7 +166,7 @@ module RSpec
|
|
156
166
|
print_deferred_deprecation_warnings
|
157
167
|
deprecation_stream.puts RAISE_ERROR_CONFIG_NOTICE
|
158
168
|
|
159
|
-
summary_stream.puts "\n#{pluralize(deprecation_formatter.count, 'deprecation warning')} total"
|
169
|
+
summary_stream.puts "\n#{Helpers.pluralize(deprecation_formatter.count, 'deprecation warning')} total"
|
160
170
|
end
|
161
171
|
|
162
172
|
def print_deferred_deprecation_warnings
|
@@ -169,23 +179,21 @@ module RSpec
|
|
169
179
|
end
|
170
180
|
end
|
171
181
|
|
182
|
+
# @private
|
172
183
|
# Not really a stream, but is usable in place of one.
|
173
184
|
class RaiseErrorStream
|
174
|
-
include ::RSpec::Core::Formatters::Helpers
|
175
|
-
|
176
185
|
def puts(message)
|
177
186
|
raise DeprecationError, message
|
178
187
|
end
|
179
188
|
|
180
189
|
def summarize(summary_stream, deprecation_count)
|
181
|
-
summary_stream.puts "\n#{pluralize(deprecation_count, 'deprecation')} found."
|
190
|
+
summary_stream.puts "\n#{Helpers.pluralize(deprecation_count, 'deprecation')} found."
|
182
191
|
end
|
183
192
|
end
|
184
193
|
|
194
|
+
# @private
|
185
195
|
# Wraps a File object and provides file-specific operations.
|
186
196
|
class FileStream
|
187
|
-
include ::RSpec::Core::Formatters::Helpers
|
188
|
-
|
189
197
|
def initialize(file)
|
190
198
|
@file = file
|
191
199
|
|
@@ -201,7 +209,7 @@ module RSpec
|
|
201
209
|
end
|
202
210
|
|
203
211
|
def summarize(summary_stream, deprecation_count)
|
204
|
-
summary_stream.puts "\n#{pluralize(deprecation_count, 'deprecation')} logged to #{@file.path}"
|
212
|
+
summary_stream.puts "\n#{Helpers.pluralize(deprecation_count, 'deprecation')} logged to #{@file.path}"
|
205
213
|
puts RAISE_ERROR_CONFIG_NOTICE
|
206
214
|
end
|
207
215
|
end
|
@@ -209,6 +217,7 @@ module RSpec
|
|
209
217
|
end
|
210
218
|
end
|
211
219
|
|
220
|
+
# Deprecation Error
|
212
221
|
DeprecationError = Class.new(StandardError)
|
213
222
|
end
|
214
223
|
end
|