rspec-core 2.99.0 → 3.0.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 +8 -8
- checksums.yaml.gz.sig +0 -0
- data/.yardopts +1 -0
- data/Changelog.md +339 -1
- data/License.txt +1 -0
- data/README.md +19 -37
- data/exe/rspec +2 -23
- data/lib/rspec/core/backport_random.rb +336 -0
- data/lib/rspec/core/backtrace_formatter.rb +70 -0
- data/lib/rspec/core/configuration.rb +479 -577
- data/lib/rspec/core/configuration_options.rb +71 -54
- data/lib/rspec/core/drb.rb +111 -0
- data/lib/rspec/core/dsl.rb +86 -18
- data/lib/rspec/core/example.rb +267 -119
- data/lib/rspec/core/example_group.rb +381 -393
- data/lib/rspec/core/filter_manager.rb +133 -114
- data/lib/rspec/core/flat_map.rb +18 -0
- data/lib/rspec/core/formatters/base_formatter.rb +51 -125
- data/lib/rspec/core/formatters/base_text_formatter.rb +34 -286
- data/lib/rspec/core/formatters/console_codes.rb +24 -1
- data/lib/rspec/core/formatters/deprecation_formatter.rb +25 -26
- data/lib/rspec/core/formatters/documentation_formatter.rb +27 -25
- data/lib/rspec/core/formatters/helpers.rb +14 -36
- data/lib/rspec/core/formatters/html_formatter.rb +58 -65
- data/lib/rspec/core/formatters/html_printer.rb +12 -18
- data/lib/rspec/core/formatters/json_formatter.rb +54 -31
- data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
- data/lib/rspec/core/formatters/progress_formatter.rb +11 -15
- data/lib/rspec/core/formatters/snippet_extractor.rb +22 -11
- data/lib/rspec/core/formatters.rb +90 -43
- data/lib/rspec/core/hooks.rb +325 -270
- data/lib/rspec/core/memoized_helpers.rb +45 -156
- data/lib/rspec/core/metadata.rb +284 -236
- data/lib/rspec/core/metadata_filter.rb +86 -0
- data/lib/rspec/core/mocking_adapters/flexmock.rb +29 -0
- data/lib/rspec/core/{mocking/with_mocha.rb → mocking_adapters/mocha.rb} +19 -16
- data/lib/rspec/core/mocking_adapters/null.rb +12 -0
- data/lib/rspec/core/mocking_adapters/rr.rb +29 -0
- data/lib/rspec/core/mocking_adapters/rspec.rb +30 -0
- data/lib/rspec/core/notifications.rb +511 -0
- data/lib/rspec/core/option_parser.rb +49 -74
- data/lib/rspec/core/ordering.rb +156 -0
- data/lib/rspec/core/pending.rb +94 -96
- data/lib/rspec/core/project_initializer/.rspec +3 -0
- data/lib/rspec/core/project_initializer/spec/spec_helper.rb +78 -0
- data/lib/rspec/core/project_initializer.rb +24 -64
- data/lib/rspec/core/rake_task.rb +44 -130
- data/lib/rspec/core/reporter.rb +76 -59
- data/lib/rspec/core/ruby_project.rb +2 -1
- data/lib/rspec/core/runner.rb +117 -52
- data/lib/rspec/core/shared_context.rb +10 -10
- data/lib/rspec/core/shared_example_group.rb +108 -121
- data/lib/rspec/core/version.rb +3 -1
- data/lib/rspec/core/warnings.rb +40 -0
- data/lib/rspec/core/world.rb +66 -10
- data/lib/rspec/core.rb +64 -104
- data.tar.gz.sig +3 -0
- metadata +75 -322
- metadata.gz.sig +1 -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 -97
- data/features/command_line/exit_status.feature +0 -82
- data/features/command_line/format_option.feature +0 -75
- 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 -53
- data/features/command_line/order.feature +0 -26
- data/features/command_line/pattern_option.feature +0 -49
- data/features/command_line/rake_task.feature +0 -122
- data/features/command_line/require_option.feature +0 -43
- data/features/command_line/ruby.feature +0 -22
- 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 -48
- data/features/configuration/backtrace_clean_patterns.feature +0 -102
- 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/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/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/configuration/show_failures_in_pending_blocks.feature +0 -61
- data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
- 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 -294
- data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -197
- data/features/filtering/exclusion_filters.feature +0 -138
- data/features/filtering/if_and_unless.feature +0 -168
- data/features/filtering/inclusion_filters.feature +0 -105
- data/features/formatters/configurable_colors.feature +0 -31
- data/features/formatters/custom_formatter.feature +0 -36
- data/features/formatters/json_formatter.feature +0 -30
- 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 -427
- data/features/hooks/filtering.feature +0 -234
- data/features/metadata/current_example.feature +0 -56
- 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 -49
- data/features/subject/attribute_of_subject.feature +0 -124
- 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 -14
- data/features/support/rubinius.rb +0 -6
- data/lib/autotest/discover.rb +0 -10
- data/lib/autotest/rspec2.rb +0 -77
- data/lib/rspec/core/backtrace_cleaner.rb +0 -46
- data/lib/rspec/core/backward_compatibility.rb +0 -55
- data/lib/rspec/core/caller_filter.rb +0 -60
- data/lib/rspec/core/command_line.rb +0 -47
- data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
- data/lib/rspec/core/deprecation.rb +0 -26
- 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 -27
- data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
- 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_rr.rb +0 -27
- data/lib/rspec/core/mocking/with_rspec.rb +0 -27
- data/lib/rspec/core/shared_example_group/collection.rb +0 -45
- data/spec/autotest/discover_spec.rb +0 -49
- data/spec/autotest/failed_results_re_spec.rb +0 -45
- data/spec/autotest/rspec_spec.rb +0 -133
- data/spec/command_line/order_spec.rb +0 -204
- data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
- data/spec/rspec/core/caller_filter_spec.rb +0 -58
- data/spec/rspec/core/command_line_spec.rb +0 -127
- data/spec/rspec/core/command_line_spec_output.txt +0 -0
- data/spec/rspec/core/configuration_options_spec.rb +0 -417
- data/spec/rspec/core/configuration_spec.rb +0 -2072
- data/spec/rspec/core/deprecation_spec.rb +0 -27
- data/spec/rspec/core/deprecations_spec.rb +0 -59
- 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 -25
- data/spec/rspec/core/example_group_spec.rb +0 -1337
- data/spec/rspec/core/example_spec.rb +0 -502
- data/spec/rspec/core/filter_manager_spec.rb +0 -246
- data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -108
- data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -524
- data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
- data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -263
- data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -89
- data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
- data/spec/rspec/core/formatters/html_formatted.html +0 -397
- data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -131
- data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -115
- data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -30
- data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
- data/spec/rspec/core/formatters/text_mate_formatted.html +0 -397
- data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
- data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
- data/spec/rspec/core/hooks_spec.rb +0 -269
- data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
- data/spec/rspec/core/memoized_helpers_spec.rb +0 -776
- data/spec/rspec/core/metadata_spec.rb +0 -514
- data/spec/rspec/core/option_parser_spec.rb +0 -297
- data/spec/rspec/core/pending_example_spec.rb +0 -260
- data/spec/rspec/core/pending_spec.rb +0 -27
- data/spec/rspec/core/project_initializer_spec.rb +0 -130
- data/spec/rspec/core/rake_task_spec.rb +0 -202
- data/spec/rspec/core/reporter_spec.rb +0 -167
- 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 -26
- data/spec/rspec/core/runner_spec.rb +0 -82
- data/spec/rspec/core/shared_context_spec.rb +0 -114
- data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -70
- data/spec/rspec/core/shared_example_group_spec.rb +0 -138
- data/spec/rspec/core/world_spec.rb +0 -142
- data/spec/rspec/core_spec.rb +0 -108
- data/spec/spec_helper.rb +0 -135
- data/spec/support/config_options_helper.rb +0 -15
- data/spec/support/helper_methods.rb +0 -55
- data/spec/support/in_sub_process.rb +0 -37
- data/spec/support/isolate_load_path_mutation.rb +0 -6
- data/spec/support/isolated_directory.rb +0 -10
- data/spec/support/isolated_home_directory.rb +0 -16
- data/spec/support/matchers.rb +0 -65
- data/spec/support/mathn_integration_support.rb +0 -12
- data/spec/support/sandboxed_mock_space.rb +0 -116
- data/spec/support/shared_example_groups.rb +0 -42
- data/spec/support/silence_dsl_deprecations.rb +0 -32
- data/spec/support/spec_files.rb +0 -44
|
@@ -5,11 +5,23 @@ module RSpec
|
|
|
5
5
|
#
|
|
6
6
|
# Extracts code snippets by looking at the backtrace of the passed error and applies synax highlighting and line numbers using html.
|
|
7
7
|
class SnippetExtractor
|
|
8
|
-
|
|
8
|
+
# @private
|
|
9
|
+
class NullConverter
|
|
10
|
+
def convert(code)
|
|
11
|
+
%Q(#{code}\n<span class="comment"># Install the coderay gem to get syntax highlighting</span>)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @private
|
|
16
|
+
class CoderayConverter
|
|
17
|
+
def convert(code)
|
|
18
|
+
CodeRay.scan(code, :ruby).html(:line_numbers => false)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
9
21
|
|
|
10
22
|
begin
|
|
11
|
-
require '
|
|
12
|
-
@@converter =
|
|
23
|
+
require 'coderay'
|
|
24
|
+
@@converter = CoderayConverter.new
|
|
13
25
|
rescue LoadError
|
|
14
26
|
@@converter = NullConverter.new
|
|
15
27
|
end
|
|
@@ -18,14 +30,13 @@ module RSpec
|
|
|
18
30
|
#
|
|
19
31
|
# Extract lines of code corresponding to a backtrace.
|
|
20
32
|
#
|
|
21
|
-
# @param [String]
|
|
33
|
+
# @param backtrace [String] the backtrace from a test failure
|
|
22
34
|
# @return [String] highlighted code snippet indicating where the test failure occured
|
|
23
35
|
#
|
|
24
36
|
# @see #post_process
|
|
25
37
|
def snippet(backtrace)
|
|
26
38
|
raw_code, line = snippet_for(backtrace[0])
|
|
27
|
-
highlighted = @@converter.convert(raw_code
|
|
28
|
-
highlighted << "\n<span class=\"comment\"># gem install syntax to get syntax highlighting</span>" if @@converter.is_a?(NullConverter)
|
|
39
|
+
highlighted = @@converter.convert(raw_code)
|
|
29
40
|
post_process(highlighted, line)
|
|
30
41
|
end
|
|
31
42
|
|
|
@@ -33,7 +44,7 @@ module RSpec
|
|
|
33
44
|
#
|
|
34
45
|
# Create a snippet from a line of code.
|
|
35
46
|
#
|
|
36
|
-
# @param [String]
|
|
47
|
+
# @param error_line [String] file name with line number (i.e. 'foo_spec.rb:12')
|
|
37
48
|
# @return [String] lines around the target line within the file
|
|
38
49
|
#
|
|
39
50
|
# @see #lines_around
|
|
@@ -51,8 +62,8 @@ module RSpec
|
|
|
51
62
|
#
|
|
52
63
|
# Extract lines of code centered around a particular line within a source file.
|
|
53
64
|
#
|
|
54
|
-
# @param [String]
|
|
55
|
-
# @param [Fixnum] line
|
|
65
|
+
# @param file [String] filename
|
|
66
|
+
# @param line [Fixnum] line number
|
|
56
67
|
# @return [String] lines around the target line within the file (2 above and 1 below).
|
|
57
68
|
def lines_around(file, line)
|
|
58
69
|
if File.file?(file)
|
|
@@ -73,8 +84,8 @@ module RSpec
|
|
|
73
84
|
#
|
|
74
85
|
# Adds line numbers to all lines and highlights the line where the failure occurred using html `span` tags.
|
|
75
86
|
#
|
|
76
|
-
# @param [String]
|
|
77
|
-
# @param [Fixnum]
|
|
87
|
+
# @param highlighted [String] syntax-highlighted snippet surrounding the offending line of code
|
|
88
|
+
# @param offending_line [Fixnum] line where failure occured
|
|
78
89
|
# @return [String] completed snippet
|
|
79
90
|
def post_process(highlighted, offending_line)
|
|
80
91
|
new_lines = []
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
# * progress (default) - prints dots for passing examples, `F` for failures, `*` for pending
|
|
4
4
|
# * documentation - prints the docstrings passed to `describe` and `it` methods (and their aliases)
|
|
5
5
|
# * html
|
|
6
|
-
# * textmate - html plus links to editor
|
|
7
6
|
# * json - useful for archiving data for subsequent analysis
|
|
8
7
|
#
|
|
9
8
|
# The progress formatter is the default, but you can choose any one or more of
|
|
@@ -29,25 +28,37 @@
|
|
|
29
28
|
#
|
|
30
29
|
# The reporter calls every formatter with this protocol:
|
|
31
30
|
#
|
|
32
|
-
# *
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
# * `
|
|
36
|
-
#
|
|
37
|
-
# * `
|
|
38
|
-
#
|
|
39
|
-
# * `
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
# *
|
|
43
|
-
#
|
|
44
|
-
# *
|
|
45
|
-
#
|
|
46
|
-
#
|
|
31
|
+
# * To start
|
|
32
|
+
# * `start(StartNotification)`
|
|
33
|
+
# * Once per example group
|
|
34
|
+
# * `example_group_started(GroupNotification)`
|
|
35
|
+
# * Once per example
|
|
36
|
+
# * `example_started(ExampleNotification)`
|
|
37
|
+
# * One of these per example, depending on outcome
|
|
38
|
+
# * `example_passed(ExampleNotification)`
|
|
39
|
+
# * `example_failed(FailedExampleNotification)`
|
|
40
|
+
# * `example_pending(ExampleNotification)`
|
|
41
|
+
# * Optionally at any time
|
|
42
|
+
# * `message(MessageNotification)`
|
|
43
|
+
# * At the end of the suite
|
|
44
|
+
# * `stop(ExamplesNotification)`
|
|
45
|
+
# * `start_dump(NullNotification)`
|
|
46
|
+
# * `dump_pending(ExamplesNotification)`
|
|
47
|
+
# * `dump_failures(ExamplesNotification)`
|
|
48
|
+
# * `dump_summary(SummaryNotification)`
|
|
49
|
+
# * `seed(SeedNotification)`
|
|
50
|
+
# * `close(NullNotification)`
|
|
47
51
|
#
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
#
|
|
52
|
+
# Only the notifications to which you subscribe your formatter will be called
|
|
53
|
+
# on your formatter. To subscribe your formatter use:
|
|
54
|
+
# `RSpec::Core::Formatters#register` e.g.
|
|
55
|
+
#
|
|
56
|
+
# `RSpec::Core::Formatters.register FormatterClassName, :example_passed, :example_failed`
|
|
57
|
+
#
|
|
58
|
+
# We recommend you implement the methods yourself; for simplicity we provide the
|
|
59
|
+
# default formatter output via our notification objects but if you prefer you
|
|
60
|
+
# can subclass `RSpec::Core::Formatters::BaseTextFormatter` and override the
|
|
61
|
+
# methods you wish to enhance.
|
|
51
62
|
#
|
|
52
63
|
# @see RSpec::Core::Formatters::BaseTextFormatter
|
|
53
64
|
# @see RSpec::Core::Reporter
|
|
@@ -55,8 +66,17 @@ module RSpec::Core::Formatters
|
|
|
55
66
|
autoload :DocumentationFormatter, 'rspec/core/formatters/documentation_formatter'
|
|
56
67
|
autoload :HtmlFormatter, 'rspec/core/formatters/html_formatter'
|
|
57
68
|
autoload :ProgressFormatter, 'rspec/core/formatters/progress_formatter'
|
|
69
|
+
autoload :ProfileFormatter, 'rspec/core/formatters/profile_formatter'
|
|
58
70
|
autoload :JsonFormatter, 'rspec/core/formatters/json_formatter'
|
|
59
|
-
|
|
71
|
+
|
|
72
|
+
# Register the formatter class
|
|
73
|
+
# @param formatter_class [Class] formatter class to register
|
|
74
|
+
# @param notifications [Symbol, ...] one or more notifications to be registered to the specified formatter
|
|
75
|
+
#
|
|
76
|
+
# @see RSpec::Core::Formatters::BaseFormatter
|
|
77
|
+
def self.register(formatter_class, *notifications)
|
|
78
|
+
Loader.formatters[formatter_class] = notifications
|
|
79
|
+
end
|
|
60
80
|
|
|
61
81
|
# @api private
|
|
62
82
|
#
|
|
@@ -65,13 +85,18 @@ module RSpec::Core::Formatters
|
|
|
65
85
|
# not expected to be used directly, but only through the configuration
|
|
66
86
|
# interface.
|
|
67
87
|
class Loader
|
|
88
|
+
# @api private
|
|
89
|
+
#
|
|
90
|
+
# Internal formatters are stored here when loaded
|
|
91
|
+
def self.formatters
|
|
92
|
+
@formatters ||= {}
|
|
93
|
+
end
|
|
68
94
|
|
|
69
95
|
# @api private
|
|
70
96
|
def initialize(reporter)
|
|
71
97
|
@formatters = []
|
|
72
98
|
@reporter = reporter
|
|
73
|
-
|
|
74
|
-
@default_formatter = 'progress'
|
|
99
|
+
self.default_formatter = 'progress'
|
|
75
100
|
end
|
|
76
101
|
|
|
77
102
|
# @return [Array] the loaded formatters
|
|
@@ -80,18 +105,20 @@ module RSpec::Core::Formatters
|
|
|
80
105
|
# @return [Reporter] the reporter
|
|
81
106
|
attr_reader :reporter
|
|
82
107
|
|
|
108
|
+
# @return [String] the default formatter to setup, defaults to `progress`
|
|
109
|
+
attr_accessor :default_formatter
|
|
110
|
+
|
|
83
111
|
# @private
|
|
84
112
|
def setup_default(output_stream, deprecation_stream)
|
|
85
113
|
if @formatters.empty?
|
|
86
|
-
add
|
|
114
|
+
add default_formatter, output_stream
|
|
87
115
|
end
|
|
88
116
|
unless @formatters.any? { |formatter| DeprecationFormatter === formatter }
|
|
89
117
|
add DeprecationFormatter, deprecation_stream, output_stream
|
|
90
118
|
end
|
|
91
|
-
|
|
92
|
-
|
|
119
|
+
if RSpec.configuration.profile_examples? && !existing_formatter_implements?(:dump_profile)
|
|
120
|
+
add RSpec::Core::Formatters::ProfileFormatter, output_stream
|
|
93
121
|
end
|
|
94
|
-
@setup = true
|
|
95
122
|
end
|
|
96
123
|
|
|
97
124
|
# @private
|
|
@@ -100,12 +127,35 @@ module RSpec::Core::Formatters
|
|
|
100
127
|
|
|
101
128
|
args = paths.map { |p| p.respond_to?(:puts) ? p : file_at(p) }
|
|
102
129
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
@reporter.register_listener formatter, *
|
|
130
|
+
if !Loader.formatters[formatter_class].nil?
|
|
131
|
+
formatter = formatter_class.new(*args)
|
|
132
|
+
@reporter.register_listener formatter, *notifications_for(formatter_class)
|
|
133
|
+
elsif defined?(RSpec::LegacyFormatters)
|
|
134
|
+
formatter = RSpec::LegacyFormatters.load_formatter formatter_class, *args
|
|
135
|
+
@reporter.register_listener formatter, *formatter.notifications
|
|
136
|
+
else
|
|
137
|
+
line = ::RSpec::CallerFilter.first_non_rspec_line
|
|
138
|
+
if line
|
|
139
|
+
call_site = "Formatter added at: #{line}"
|
|
140
|
+
else
|
|
141
|
+
call_site = "The formatter was added via command line flag or your "+
|
|
142
|
+
"`.rspec` file."
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
RSpec.warn_deprecation <<-WARNING.gsub(/\s*\|/,' ')
|
|
146
|
+
|The #{formatter_class} formatter uses the deprecated formatter
|
|
147
|
+
|interface not supported directly by RSpec 3.
|
|
148
|
+
|
|
|
149
|
+
|To continue to use this formatter you must install the
|
|
150
|
+
|`rspec-legacy_formatters` gem, which provides support
|
|
151
|
+
|for legacy formatters or upgrade the formatter to a
|
|
152
|
+
|compatible version.
|
|
153
|
+
|
|
|
154
|
+
|#{call_site}
|
|
155
|
+
WARNING
|
|
156
|
+
return
|
|
106
157
|
end
|
|
107
158
|
@formatters << formatter unless duplicate_formatter_exists?(formatter)
|
|
108
|
-
|
|
109
159
|
formatter
|
|
110
160
|
end
|
|
111
161
|
|
|
@@ -123,29 +173,26 @@ module RSpec::Core::Formatters
|
|
|
123
173
|
end
|
|
124
174
|
end
|
|
125
175
|
|
|
176
|
+
def existing_formatter_implements?(notification)
|
|
177
|
+
@reporter.registered_listeners(notification).any?
|
|
178
|
+
end
|
|
179
|
+
|
|
126
180
|
def built_in_formatter(key)
|
|
127
181
|
case key.to_s
|
|
128
182
|
when 'd', 'doc', 'documentation'
|
|
129
183
|
DocumentationFormatter
|
|
130
|
-
when 's', 'n', 'spec', 'nested'
|
|
131
|
-
RSpec.deprecate "Using `#{key.to_s}` as a shortcut for the DocumentationFormatter",
|
|
132
|
-
:replacement => "`d`, `doc`, or `documentation`"
|
|
133
|
-
DocumentationFormatter
|
|
134
184
|
when 'h', 'html'
|
|
135
185
|
HtmlFormatter
|
|
136
186
|
when 'p', 'progress'
|
|
137
187
|
ProgressFormatter
|
|
138
188
|
when 'j', 'json'
|
|
139
189
|
JsonFormatter
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
:replacement => "the `rspec-tmbundle` gem and it's `::RSpec::Mate::Formatters::TextMateFormatter`"
|
|
147
|
-
end
|
|
148
|
-
TextMateFormatter
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def notifications_for(formatter_class)
|
|
194
|
+
formatter_class.ancestors.inject(Set.new) do |notifications, klass|
|
|
195
|
+
notifications + Loader.formatters.fetch(klass) { Set.new }
|
|
149
196
|
end
|
|
150
197
|
end
|
|
151
198
|
|