rspec-core 2.11.1 → 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/.document +1 -1
- data/.yardopts +3 -1
- data/Changelog.md +1814 -29
- data/{License.txt → LICENSE.md} +6 -4
- data/README.md +197 -48
- data/exe/rspec +2 -23
- data/lib/rspec/autorun.rb +1 -0
- data/lib/rspec/core/backtrace_formatter.rb +65 -0
- data/lib/rspec/core/bisect/coordinator.rb +62 -0
- data/lib/rspec/core/bisect/example_minimizer.rb +173 -0
- data/lib/rspec/core/bisect/fork_runner.rb +138 -0
- data/lib/rspec/core/bisect/server.rb +61 -0
- data/lib/rspec/core/bisect/shell_command.rb +126 -0
- data/lib/rspec/core/bisect/shell_runner.rb +73 -0
- data/lib/rspec/core/bisect/utilities.rb +69 -0
- data/lib/rspec/core/configuration.rb +1846 -407
- data/lib/rspec/core/configuration_options.rb +154 -50
- data/lib/rspec/core/did_you_mean.rb +46 -0
- data/lib/rspec/core/drb.rb +120 -0
- data/lib/rspec/core/dsl.rb +90 -18
- data/lib/rspec/core/example.rb +488 -152
- data/lib/rspec/core/example_group.rb +733 -294
- data/lib/rspec/core/example_status_persister.rb +235 -0
- data/lib/rspec/core/filter_manager.rb +175 -147
- data/lib/rspec/core/flat_map.rb +20 -0
- data/lib/rspec/core/formatters/base_bisect_formatter.rb +45 -0
- data/lib/rspec/core/formatters/base_formatter.rb +32 -130
- data/lib/rspec/core/formatters/base_text_formatter.rb +62 -190
- data/lib/rspec/core/formatters/bisect_drb_formatter.rb +29 -0
- data/lib/rspec/core/formatters/bisect_progress_formatter.rb +157 -0
- data/lib/rspec/core/formatters/console_codes.rb +76 -0
- data/lib/rspec/core/formatters/deprecation_formatter.rb +223 -0
- data/lib/rspec/core/formatters/documentation_formatter.rb +62 -27
- data/lib/rspec/core/formatters/exception_presenter.rb +521 -0
- data/lib/rspec/core/formatters/failure_list_formatter.rb +23 -0
- data/lib/rspec/core/formatters/fallback_message_formatter.rb +28 -0
- data/lib/rspec/core/formatters/helpers.rb +93 -14
- data/lib/rspec/core/formatters/html_formatter.rb +104 -415
- data/lib/rspec/core/formatters/html_printer.rb +414 -0
- data/lib/rspec/core/formatters/html_snippet_extractor.rb +120 -0
- data/lib/rspec/core/formatters/json_formatter.rb +102 -0
- data/lib/rspec/core/formatters/profile_formatter.rb +68 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +12 -15
- data/lib/rspec/core/formatters/protocol.rb +182 -0
- data/lib/rspec/core/formatters/snippet_extractor.rb +115 -39
- data/lib/rspec/core/formatters/syntax_highlighter.rb +91 -0
- data/lib/rspec/core/formatters.rb +279 -0
- data/lib/rspec/core/hooks.rb +451 -300
- data/lib/rspec/core/invocations.rb +87 -0
- data/lib/rspec/core/memoized_helpers.rb +580 -0
- data/lib/rspec/core/metadata.rb +395 -173
- data/lib/rspec/core/metadata_filter.rb +255 -0
- data/lib/rspec/core/minitest_assertions_adapter.rb +31 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +31 -0
- data/lib/rspec/core/mocking_adapters/mocha.rb +57 -0
- data/lib/rspec/core/mocking_adapters/null.rb +14 -0
- data/lib/rspec/core/mocking_adapters/rr.rb +31 -0
- data/lib/rspec/core/mocking_adapters/rspec.rb +32 -0
- data/lib/rspec/core/notifications.rb +521 -0
- data/lib/rspec/core/option_parser.rb +208 -64
- data/lib/rspec/core/ordering.rb +169 -0
- data/lib/rspec/core/output_wrapper.rb +29 -0
- data/lib/rspec/core/pending.rb +115 -59
- data/lib/rspec/core/profiler.rb +34 -0
- data/lib/rspec/core/project_initializer/.rspec +1 -0
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +98 -0
- data/lib/rspec/core/project_initializer.rb +26 -65
- data/lib/rspec/core/rake_task.rb +140 -131
- data/lib/rspec/core/reporter.rb +207 -44
- data/lib/rspec/core/ruby_project.rb +15 -6
- data/lib/rspec/core/runner.rb +180 -44
- data/lib/rspec/core/sandbox.rb +37 -0
- data/lib/rspec/core/set.rb +54 -0
- data/lib/rspec/core/shared_context.rb +25 -19
- data/lib/rspec/core/shared_example_group.rb +229 -54
- data/lib/rspec/core/shell_escape.rb +49 -0
- 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 +40 -0
- data/lib/rspec/core/world.rb +208 -49
- data/lib/rspec/core.rb +166 -80
- data.tar.gz.sig +0 -0
- metadata +230 -445
- metadata.gz.sig +0 -0
- data/exe/autospec +0 -13
- data/features/Autotest.md +0 -38
- data/features/README.md +0 -17
- data/features/Upgrade.md +0 -364
- data/features/command_line/README.md +0 -28
- data/features/command_line/example_name_option.feature +0 -101
- data/features/command_line/exit_status.feature +0 -83
- data/features/command_line/format_option.feature +0 -81
- data/features/command_line/init.feature +0 -18
- 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 -29
- data/features/command_line/pattern_option.feature +0 -31
- data/features/command_line/rake_task.feature +0 -68
- data/features/command_line/ruby.feature +0 -22
- data/features/command_line/tag.feature +0 -91
- data/features/configuration/alias_example_to.feature +0 -48
- data/features/configuration/custom_settings.feature +0 -84
- data/features/configuration/default_path.feature +0 -38
- data/features/configuration/fail_fast.feature +0 -77
- data/features/configuration/read_options_from_file.feature +0 -87
- 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 -204
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -102
- data/features/filtering/exclusion_filters.feature +0 -139
- data/features/filtering/if_and_unless.feature +0 -168
- data/features/filtering/inclusion_filters.feature +0 -105
- data/features/filtering/run_all_when_everything_filtered.feature +0 -46
- data/features/formatters/custom_formatter.feature +0 -36
- 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 -149
- data/features/hooks/around_hooks.feature +0 -343
- data/features/hooks/before_and_after_hooks.feature +0 -423
- data/features/hooks/filtering.feature +0 -234
- data/features/metadata/current_example.feature +0 -17
- data/features/metadata/described_class.feature +0 -17
- data/features/metadata/user_defined.feature +0 -113
- data/features/mock_framework_integration/use_any_framework.feature +0 -106
- data/features/mock_framework_integration/use_flexmock.feature +0 -96
- data/features/mock_framework_integration/use_mocha.feature +0 -97
- data/features/mock_framework_integration/use_rr.feature +0 -98
- data/features/mock_framework_integration/use_rspec.feature +0 -97
- data/features/pending/pending_examples.feature +0 -229
- data/features/spec_files/arbitrary_file_suffix.feature +0 -13
- data/features/step_definitions/additional_cli_steps.rb +0 -30
- data/features/subject/attribute_of_subject.feature +0 -124
- data/features/subject/explicit_subject.feature +0 -82
- data/features/subject/implicit_receiver.feature +0 -29
- data/features/subject/implicit_subject.feature +0 -63
- data/features/support/env.rb +0 -12
- data/lib/autotest/discover.rb +0 -1
- data/lib/autotest/rspec2.rb +0 -73
- data/lib/rspec/core/backward_compatibility.rb +0 -65
- data/lib/rspec/core/command_line.rb +0 -36
- data/lib/rspec/core/deprecation.rb +0 -36
- data/lib/rspec/core/drb_command_line.rb +0 -26
- data/lib/rspec/core/drb_options.rb +0 -87
- data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
- data/lib/rspec/core/extensions/kernel.rb +0 -9
- data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
- data/lib/rspec/core/extensions/ordered.rb +0 -21
- data/lib/rspec/core/extensions.rb +0 -4
- data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
- data/lib/rspec/core/let.rb +0 -110
- data/lib/rspec/core/load_path.rb +0 -3
- data/lib/rspec/core/metadata_hash_builder.rb +0 -97
- data/lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
- data/lib/rspec/core/mocking/with_flexmock.rb +0 -27
- data/lib/rspec/core/mocking/with_mocha.rb +0 -29
- data/lib/rspec/core/mocking/with_rr.rb +0 -27
- data/lib/rspec/core/mocking/with_rspec.rb +0 -23
- data/lib/rspec/core/subject.rb +0 -219
- data/spec/autotest/discover_spec.rb +0 -19
- data/spec/autotest/failed_results_re_spec.rb +0 -45
- data/spec/autotest/rspec_spec.rb +0 -123
- data/spec/command_line/order_spec.rb +0 -137
- data/spec/rspec/core/command_line_spec.rb +0 -108
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -377
- data/spec/rspec/core/configuration_spec.rb +0 -1196
- data/spec/rspec/core/deprecations_spec.rb +0 -66
- data/spec/rspec/core/drb_command_line_spec.rb +0 -108
- data/spec/rspec/core/drb_options_spec.rb +0 -180
- data/spec/rspec/core/dsl_spec.rb +0 -17
- data/spec/rspec/core/example_group_spec.rb +0 -1098
- data/spec/rspec/core/example_spec.rb +0 -370
- data/spec/rspec/core/filter_manager_spec.rb +0 -256
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -80
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -363
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -88
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -66
- data/spec/rspec/core/formatters/html_formatted-1.8.7-jruby.html +0 -410
- data/spec/rspec/core/formatters/html_formatted-1.8.7.html +0 -409
- data/spec/rspec/core/formatters/html_formatted-1.9.2.html +0 -416
- data/spec/rspec/core/formatters/html_formatted-1.9.3.html +0 -416
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -82
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -30
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -18
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7-jruby.html +0 -410
- data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +0 -409
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.2.html +0 -416
- data/spec/rspec/core/formatters/text_mate_formatted-1.9.3.html +0 -416
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -83
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -250
- data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
- data/spec/rspec/core/let_spec.rb +0 -55
- data/spec/rspec/core/metadata_spec.rb +0 -447
- data/spec/rspec/core/option_parser_spec.rb +0 -166
- data/spec/rspec/core/pending_example_spec.rb +0 -220
- data/spec/rspec/core/project_initializer_spec.rb +0 -130
- data/spec/rspec/core/rake_task_spec.rb +0 -138
- data/spec/rspec/core/reporter_spec.rb +0 -103
- 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 -60
- 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 -24
- data/spec/rspec/core/runner_spec.rb +0 -81
- data/spec/rspec/core/shared_context_spec.rb +0 -67
- data/spec/rspec/core/shared_example_group_spec.rb +0 -84
- data/spec/rspec/core/subject_spec.rb +0 -244
- data/spec/rspec/core/world_spec.rb +0 -144
- data/spec/rspec/core_spec.rb +0 -35
- data/spec/spec_helper.rb +0 -98
- data/spec/support/config_options_helper.rb +0 -24
- data/spec/support/helper_methods.rb +0 -5
- data/spec/support/matchers.rb +0 -65
- data/spec/support/shared_example_groups.rb +0 -41
- data/spec/support/spec_files.rb +0 -44
@@ -1,462 +1,151 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
RSpec::Support.require_rspec_core "formatters/base_text_formatter"
|
2
|
+
RSpec::Support.require_rspec_core "formatters/html_printer"
|
3
3
|
|
4
4
|
module RSpec
|
5
5
|
module Core
|
6
6
|
module Formatters
|
7
|
-
|
8
|
-
|
7
|
+
# @private
|
8
|
+
class HtmlFormatter < BaseFormatter
|
9
|
+
Formatters.register self, :start, :example_group_started, :start_dump,
|
10
|
+
:example_started, :example_passed, :example_failed,
|
11
|
+
:example_pending, :dump_summary
|
9
12
|
|
10
13
|
def initialize(output)
|
11
14
|
super(output)
|
15
|
+
@failed_examples = []
|
12
16
|
@example_group_number = 0
|
13
17
|
@example_number = 0
|
14
18
|
@header_red = nil
|
19
|
+
@printer = HtmlPrinter.new(output)
|
15
20
|
end
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
def start(notification)
|
23
|
+
super
|
24
|
+
@printer.print_html_start
|
25
|
+
@printer.flush
|
20
26
|
end
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
# The number of the currently running example_group
|
27
|
-
def example_group_number
|
28
|
-
@example_group_number
|
29
|
-
end
|
30
|
-
|
31
|
-
# The number of the currently running example (a global counter)
|
32
|
-
def example_number
|
33
|
-
@example_number
|
34
|
-
end
|
35
|
-
|
36
|
-
def start(example_count)
|
37
|
-
super(example_count)
|
38
|
-
@output.puts html_header
|
39
|
-
@output.puts report_header
|
40
|
-
@output.flush
|
41
|
-
end
|
42
|
-
|
43
|
-
def example_group_started(example_group)
|
44
|
-
super(example_group)
|
28
|
+
def example_group_started(notification)
|
29
|
+
super
|
45
30
|
@example_group_red = false
|
46
31
|
@example_group_number += 1
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
@
|
53
|
-
@output.puts " <dt id=\"example_group_#{example_group_number}\" class=\"passed\">#{h(example_group.description)}</dt>"
|
54
|
-
@output.flush
|
32
|
+
|
33
|
+
@printer.print_example_group_end unless example_group_number == 1
|
34
|
+
@printer.print_example_group_start(example_group_number,
|
35
|
+
notification.group.description,
|
36
|
+
notification.group.parent_groups.size)
|
37
|
+
@printer.flush
|
55
38
|
end
|
56
39
|
|
57
|
-
def start_dump
|
58
|
-
@
|
59
|
-
@
|
60
|
-
@output.flush
|
40
|
+
def start_dump(_notification)
|
41
|
+
@printer.print_example_group_end
|
42
|
+
@printer.flush
|
61
43
|
end
|
62
44
|
|
63
|
-
def example_started(
|
64
|
-
super(example)
|
45
|
+
def example_started(_notification)
|
65
46
|
@example_number += 1
|
66
47
|
end
|
67
48
|
|
68
|
-
def example_passed(
|
69
|
-
move_progress
|
70
|
-
@
|
71
|
-
@
|
49
|
+
def example_passed(passed)
|
50
|
+
@printer.move_progress(percent_done)
|
51
|
+
@printer.print_example_passed(passed.example.description, passed.example.execution_result.run_time)
|
52
|
+
@printer.flush
|
72
53
|
end
|
73
54
|
|
74
|
-
def example_failed(
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
@output.puts " <script type=\"text/javascript\">makeRed('div_group_#{example_group_number}');</script>" unless @example_group_red
|
81
|
-
@output.puts " <script type=\"text/javascript\">makeRed('example_group_#{example_group_number}');</script>" unless @example_group_red
|
82
|
-
@example_group_red = true
|
83
|
-
move_progress
|
84
|
-
@output.puts " <dd class=\"example #{exception.pending_fixed? ? 'pending_fixed' : 'failed'}\">"
|
85
|
-
@output.puts " <span class=\"failed_spec_name\">#{h(example.description)}</span>"
|
86
|
-
@output.puts " <span class=\"duration\">#{sprintf('%.5f', example.execution_result[:run_time])}s</span>"
|
87
|
-
@output.puts " <div class=\"failure\" id=\"failure_#{@failed_examples.size}\">"
|
88
|
-
@output.puts " <div class=\"message\"><pre>#{h(exception.message)}</pre></div>" unless exception.nil?
|
89
|
-
@output.puts " <div class=\"backtrace\"><pre>#{format_backtrace(exception.backtrace, example).join("\n")}</pre></div>" if exception
|
90
|
-
@output.puts extra unless extra == ""
|
91
|
-
@output.puts " </div>"
|
92
|
-
@output.puts " </dd>"
|
93
|
-
@output.flush
|
94
|
-
end
|
55
|
+
def example_failed(failure)
|
56
|
+
@failed_examples << failure.example
|
57
|
+
unless @header_red
|
58
|
+
@header_red = true
|
59
|
+
@printer.make_header_red
|
60
|
+
end
|
95
61
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
@output.puts " <script type=\"text/javascript\">makeYellow('example_group_#{example_group_number}');</script>" unless @example_group_red
|
101
|
-
move_progress
|
102
|
-
@output.puts " <dd class=\"example not_implemented\"><span class=\"not_implemented_spec_name\">#{h(example.description)} (PENDING: #{h(message)})</span></dd>"
|
103
|
-
@output.flush
|
104
|
-
end
|
62
|
+
unless @example_group_red
|
63
|
+
@example_group_red = true
|
64
|
+
@printer.make_example_group_header_red(example_group_number)
|
65
|
+
end
|
105
66
|
|
106
|
-
|
107
|
-
# could output links to images or other files produced during the specs.
|
108
|
-
#
|
109
|
-
def extra_failure_content(exception)
|
110
|
-
require 'rspec/core/formatters/snippet_extractor'
|
111
|
-
backtrace = exception.backtrace.map {|line| backtrace_line(line)}
|
112
|
-
backtrace.compact!
|
113
|
-
@snippet_extractor ||= SnippetExtractor.new
|
114
|
-
" <pre class=\"ruby\"><code>#{@snippet_extractor.snippet(backtrace)}</code></pre>"
|
115
|
-
end
|
67
|
+
@printer.move_progress(percent_done)
|
116
68
|
|
117
|
-
|
118
|
-
@output.puts " <script type=\"text/javascript\">moveProgressBar('#{percent_done}');</script>"
|
119
|
-
@output.flush
|
120
|
-
end
|
69
|
+
example = failure.example
|
121
70
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
71
|
+
exception = failure.exception
|
72
|
+
message_lines = failure.fully_formatted_lines(nil, RSpec::Core::Notifications::NullColorizer)
|
73
|
+
exception_details = if exception
|
74
|
+
{
|
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"),
|
78
|
+
}
|
79
|
+
end
|
80
|
+
extra = extra_failure_content(failure)
|
129
81
|
|
130
|
-
|
82
|
+
@printer.print_example_failed(
|
83
|
+
example.execution_result.pending_fixed,
|
84
|
+
example.description,
|
85
|
+
example.execution_result.run_time,
|
86
|
+
@failed_examples.size,
|
87
|
+
exception_details,
|
88
|
+
(extra == "") ? false : extra
|
89
|
+
)
|
90
|
+
@printer.flush
|
131
91
|
end
|
132
92
|
|
133
|
-
def
|
134
|
-
|
93
|
+
def example_pending(pending)
|
94
|
+
example = pending.example
|
135
95
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
totals = "#{example_count} example#{'s' unless example_count == 1}, "
|
142
|
-
totals << "#{failure_count} failure#{'s' unless failure_count == 1}"
|
143
|
-
totals << ", #{pending_count} pending" if pending_count > 0
|
144
|
-
end
|
145
|
-
@output.puts "<script type=\"text/javascript\">document.getElementById('duration').innerHTML = \"Finished in <strong>#{sprintf("%.5f", duration)} seconds</strong>\";</script>"
|
146
|
-
@output.puts "<script type=\"text/javascript\">document.getElementById('totals').innerHTML = \"#{totals}\";</script>"
|
147
|
-
@output.puts "</div>"
|
148
|
-
@output.puts "</div>"
|
149
|
-
@output.puts "</body>"
|
150
|
-
@output.puts "</html>"
|
151
|
-
@output.flush
|
152
|
-
end
|
153
|
-
|
154
|
-
def current_indentation
|
155
|
-
"style=\"margin-left: #{(example_group.ancestors.size - 1) * 15}px;\""
|
96
|
+
@printer.make_header_yellow unless @header_red
|
97
|
+
@printer.make_example_group_header_yellow(example_group_number) unless @example_group_red
|
98
|
+
@printer.move_progress(percent_done)
|
99
|
+
@printer.print_example_pending(example.description, example.execution_result.pending_message)
|
100
|
+
@printer.flush
|
156
101
|
end
|
157
102
|
|
158
|
-
def
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
<title>RSpec results</title>
|
167
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
168
|
-
<meta http-equiv="Expires" content="-1" />
|
169
|
-
<meta http-equiv="Pragma" content="no-cache" />
|
170
|
-
<style type="text/css">
|
171
|
-
body {
|
172
|
-
margin: 0;
|
173
|
-
padding: 0;
|
174
|
-
background: #fff;
|
175
|
-
font-size: 80%;
|
176
|
-
}
|
177
|
-
</style>
|
178
|
-
<script type="text/javascript">
|
179
|
-
// <![CDATA[
|
180
|
-
#{global_scripts}
|
181
|
-
// ]]>
|
182
|
-
</script>
|
183
|
-
<style type="text/css">
|
184
|
-
#{global_styles}
|
185
|
-
</style>
|
186
|
-
</head>
|
187
|
-
<body>
|
188
|
-
EOF
|
103
|
+
def dump_summary(summary)
|
104
|
+
@printer.print_summary(
|
105
|
+
summary.duration,
|
106
|
+
summary.example_count,
|
107
|
+
summary.failure_count,
|
108
|
+
summary.pending_count
|
109
|
+
)
|
110
|
+
@printer.flush
|
189
111
|
end
|
190
112
|
|
191
|
-
|
192
|
-
<<-EOF
|
193
|
-
<div class="rspec-report">
|
194
|
-
|
195
|
-
<div id="rspec-header">
|
196
|
-
<div id="label">
|
197
|
-
<h1>RSpec Code Examples</h1>
|
198
|
-
</div>
|
199
|
-
|
200
|
-
<div id="display-filters">
|
201
|
-
<input id="passed_checkbox" name="passed_checkbox" type="checkbox" checked onchange="apply_filters()" value="1"> <label for="passed_checkbox">Passed</label>
|
202
|
-
<input id="failed_checkbox" name="failed_checkbox" type="checkbox" checked onchange="apply_filters()" value="2"> <label for="failed_checkbox">Failed</label>
|
203
|
-
<input id="pending_checkbox" name="pending_checkbox" type="checkbox" checked onchange="apply_filters()" value="3"> <label for="pending_checkbox">Pending</label>
|
204
|
-
</div>
|
113
|
+
private
|
205
114
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
</div>
|
210
|
-
</div>
|
115
|
+
# If these methods are declared with attr_reader Ruby will issue a
|
116
|
+
# warning because they are private.
|
117
|
+
# rubocop:disable Style/TrivialAccessors
|
211
118
|
|
212
|
-
|
213
|
-
|
214
|
-
|
119
|
+
# The number of the currently running example_group.
|
120
|
+
def example_group_number
|
121
|
+
@example_group_number
|
215
122
|
end
|
216
123
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
function addClass(element_id, classname) {
|
221
|
-
document.getElementById(element_id).className += (" " + classname);
|
222
|
-
}
|
223
|
-
|
224
|
-
function removeClass(element_id, classname) {
|
225
|
-
var elem = document.getElementById(element_id);
|
226
|
-
var classlist = elem.className.replace(classname,'');
|
227
|
-
elem.className = classlist;
|
228
|
-
}
|
229
|
-
|
230
|
-
function moveProgressBar(percentDone) {
|
231
|
-
document.getElementById("rspec-header").style.width = percentDone +"%";
|
232
|
-
}
|
233
|
-
|
234
|
-
function makeRed(element_id) {
|
235
|
-
removeClass(element_id, 'passed');
|
236
|
-
removeClass(element_id, 'not_implemented');
|
237
|
-
addClass(element_id,'failed');
|
238
|
-
}
|
239
|
-
|
240
|
-
function makeYellow(element_id) {
|
241
|
-
var elem = document.getElementById(element_id);
|
242
|
-
if (elem.className.indexOf("failed") == -1) { // class doesn't includes failed
|
243
|
-
if (elem.className.indexOf("not_implemented") == -1) { // class doesn't include not_implemented
|
244
|
-
removeClass(element_id, 'passed');
|
245
|
-
addClass(element_id,'not_implemented');
|
246
|
-
}
|
247
|
-
}
|
248
|
-
}
|
249
|
-
|
250
|
-
function apply_filters() {
|
251
|
-
var passed_filter = document.getElementById('passed_checkbox').checked;
|
252
|
-
var failed_filter = document.getElementById('failed_checkbox').checked;
|
253
|
-
var pending_filter = document.getElementById('pending_checkbox').checked;
|
254
|
-
|
255
|
-
assign_display_style("example passed", passed_filter);
|
256
|
-
assign_display_style("example failed", failed_filter);
|
257
|
-
assign_display_style("example not_implemented", pending_filter);
|
258
|
-
|
259
|
-
assign_display_style_for_group("example_group passed", passed_filter);
|
260
|
-
assign_display_style_for_group("example_group not_implemented", pending_filter, pending_filter || passed_filter);
|
261
|
-
assign_display_style_for_group("example_group failed", failed_filter, failed_filter || pending_filter || passed_filter);
|
262
|
-
}
|
263
|
-
|
264
|
-
function get_display_style(display_flag) {
|
265
|
-
var style_mode = 'none';
|
266
|
-
if (display_flag == true) {
|
267
|
-
style_mode = 'block';
|
268
|
-
}
|
269
|
-
return style_mode;
|
270
|
-
}
|
271
|
-
|
272
|
-
function assign_display_style(classname, display_flag) {
|
273
|
-
var style_mode = get_display_style(display_flag);
|
274
|
-
var elems = document.getElementsByClassName(classname)
|
275
|
-
for (var i=0; i<elems.length;i++) {
|
276
|
-
elems[i].style.display = style_mode;
|
277
|
-
}
|
278
|
-
}
|
279
|
-
|
280
|
-
function assign_display_style_for_group(classname, display_flag, subgroup_flag) {
|
281
|
-
var display_style_mode = get_display_style(display_flag);
|
282
|
-
var subgroup_style_mode = get_display_style(subgroup_flag);
|
283
|
-
var elems = document.getElementsByClassName(classname)
|
284
|
-
for (var i=0; i<elems.length;i++) {
|
285
|
-
var style_mode = display_style_mode;
|
286
|
-
if ((display_flag != subgroup_flag) && (elems[i].getElementsByTagName('dt')[0].innerHTML.indexOf(", ") != -1)) {
|
287
|
-
elems[i].style.display = subgroup_style_mode;
|
288
|
-
} else {
|
289
|
-
elems[i].style.display = display_style_mode;
|
290
|
-
}
|
291
|
-
}
|
292
|
-
}
|
293
|
-
EOF
|
124
|
+
# The number of the currently running example (a global counter).
|
125
|
+
def example_number
|
126
|
+
@example_number
|
294
127
|
end
|
128
|
+
# rubocop:enable Style/TrivialAccessors
|
295
129
|
|
296
|
-
def
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
margin: 0px 10px 0px 10px;
|
304
|
-
padding: 10px;
|
305
|
-
font-family: "Lucida Grande", Helvetica, sans-serif;
|
306
|
-
font-size: 1.8em;
|
307
|
-
position: absolute;
|
308
|
-
}
|
309
|
-
|
310
|
-
#label {
|
311
|
-
float:left;
|
312
|
-
}
|
313
|
-
|
314
|
-
#display-filters {
|
315
|
-
float:left;
|
316
|
-
padding: 28px 0 0 40%;
|
317
|
-
font-family: "Lucida Grande", Helvetica, sans-serif;
|
318
|
-
}
|
319
|
-
|
320
|
-
#summary {
|
321
|
-
float:right;
|
322
|
-
padding: 5px 10px;
|
323
|
-
font-family: "Lucida Grande", Helvetica, sans-serif;
|
324
|
-
text-align: right;
|
325
|
-
}
|
326
|
-
|
327
|
-
#summary p {
|
328
|
-
margin: 0 0 0 2px;
|
329
|
-
}
|
330
|
-
|
331
|
-
#summary #totals {
|
332
|
-
font-size: 1.2em;
|
333
|
-
}
|
334
|
-
|
335
|
-
.example_group {
|
336
|
-
margin: 0 10px 5px;
|
337
|
-
background: #fff;
|
338
|
-
}
|
339
|
-
|
340
|
-
dl {
|
341
|
-
margin: 0; padding: 0 0 5px;
|
342
|
-
font: normal 11px "Lucida Grande", Helvetica, sans-serif;
|
343
|
-
}
|
344
|
-
|
345
|
-
dt {
|
346
|
-
padding: 3px;
|
347
|
-
background: #65C400;
|
348
|
-
color: #fff;
|
349
|
-
font-weight: bold;
|
350
|
-
}
|
351
|
-
|
352
|
-
dd {
|
353
|
-
margin: 5px 0 5px 5px;
|
354
|
-
padding: 3px 3px 3px 18px;
|
355
|
-
}
|
356
|
-
|
357
|
-
dd .duration {
|
358
|
-
padding-left: 5px;
|
359
|
-
text-align: right;
|
360
|
-
right: 0px;
|
361
|
-
float:right;
|
362
|
-
}
|
363
|
-
|
364
|
-
dd.example.passed {
|
365
|
-
border-left: 5px solid #65C400;
|
366
|
-
border-bottom: 1px solid #65C400;
|
367
|
-
background: #DBFFB4; color: #3D7700;
|
368
|
-
}
|
369
|
-
|
370
|
-
dd.example.not_implemented {
|
371
|
-
border-left: 5px solid #FAF834;
|
372
|
-
border-bottom: 1px solid #FAF834;
|
373
|
-
background: #FCFB98; color: #131313;
|
374
|
-
}
|
375
|
-
|
376
|
-
dd.example.pending_fixed {
|
377
|
-
border-left: 5px solid #0000C2;
|
378
|
-
border-bottom: 1px solid #0000C2;
|
379
|
-
color: #0000C2; background: #D3FBFF;
|
380
|
-
}
|
381
|
-
|
382
|
-
dd.example.failed {
|
383
|
-
border-left: 5px solid #C20000;
|
384
|
-
border-bottom: 1px solid #C20000;
|
385
|
-
color: #C20000; background: #FFFBD3;
|
386
|
-
}
|
387
|
-
|
388
|
-
|
389
|
-
dt.not_implemented {
|
390
|
-
color: #000000; background: #FAF834;
|
391
|
-
}
|
392
|
-
|
393
|
-
dt.pending_fixed {
|
394
|
-
color: #FFFFFF; background: #C40D0D;
|
395
|
-
}
|
396
|
-
|
397
|
-
dt.failed {
|
398
|
-
color: #FFFFFF; background: #C40D0D;
|
399
|
-
}
|
400
|
-
|
401
|
-
|
402
|
-
#rspec-header.not_implemented {
|
403
|
-
color: #000000; background: #FAF834;
|
404
|
-
}
|
405
|
-
|
406
|
-
#rspec-header.pending_fixed {
|
407
|
-
color: #FFFFFF; background: #C40D0D;
|
408
|
-
}
|
409
|
-
|
410
|
-
#rspec-header.failed {
|
411
|
-
color: #FFFFFF; background: #C40D0D;
|
412
|
-
}
|
413
|
-
|
414
|
-
|
415
|
-
.backtrace {
|
416
|
-
color: #000;
|
417
|
-
font-size: 12px;
|
418
|
-
}
|
419
|
-
|
420
|
-
a {
|
421
|
-
color: #BE5C00;
|
422
|
-
}
|
423
|
-
|
424
|
-
/* Ruby code, style similar to vibrant ink */
|
425
|
-
.ruby {
|
426
|
-
font-size: 12px;
|
427
|
-
font-family: monospace;
|
428
|
-
color: white;
|
429
|
-
background-color: black;
|
430
|
-
padding: 0.1em 0 0.2em 0;
|
431
|
-
}
|
432
|
-
|
433
|
-
.ruby .keyword { color: #FF6600; }
|
434
|
-
.ruby .constant { color: #339999; }
|
435
|
-
.ruby .attribute { color: white; }
|
436
|
-
.ruby .global { color: white; }
|
437
|
-
.ruby .module { color: white; }
|
438
|
-
.ruby .class { color: white; }
|
439
|
-
.ruby .string { color: #66FF00; }
|
440
|
-
.ruby .ident { color: white; }
|
441
|
-
.ruby .method { color: #FFCC00; }
|
442
|
-
.ruby .number { color: white; }
|
443
|
-
.ruby .char { color: white; }
|
444
|
-
.ruby .comment { color: #9933CC; }
|
445
|
-
.ruby .symbol { color: white; }
|
446
|
-
.ruby .regex { color: #44B4CC; }
|
447
|
-
.ruby .punct { color: white; }
|
448
|
-
.ruby .escape { color: white; }
|
449
|
-
.ruby .interp { color: white; }
|
450
|
-
.ruby .expr { color: white; }
|
130
|
+
def percent_done
|
131
|
+
result = 100.0
|
132
|
+
if @example_count > 0
|
133
|
+
result = (((example_number).to_f / @example_count.to_f * 1000).to_i / 10.0).to_f
|
134
|
+
end
|
135
|
+
result
|
136
|
+
end
|
451
137
|
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
138
|
+
# Override this method if you wish to output extra HTML for a failed
|
139
|
+
# spec. For example, you could output links to images or other files
|
140
|
+
# produced during the specs.
|
141
|
+
def extra_failure_content(failure)
|
142
|
+
RSpec::Support.require_rspec_core "formatters/html_snippet_extractor"
|
143
|
+
backtrace = (failure.exception.backtrace || []).map do |line|
|
144
|
+
RSpec.configuration.backtrace_formatter.backtrace_line(line)
|
145
|
+
end
|
146
|
+
backtrace.compact!
|
147
|
+
@snippet_extractor ||= HtmlSnippetExtractor.new
|
148
|
+
" <pre class=\"ruby\"><code>#{@snippet_extractor.snippet(backtrace)}</code></pre>"
|
460
149
|
end
|
461
150
|
end
|
462
151
|
end
|