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.
Files changed (216) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.sig +0 -0
  3. data/.yardopts +1 -0
  4. data/Changelog.md +339 -1
  5. data/License.txt +1 -0
  6. data/README.md +19 -37
  7. data/exe/rspec +2 -23
  8. data/lib/rspec/core/backport_random.rb +336 -0
  9. data/lib/rspec/core/backtrace_formatter.rb +70 -0
  10. data/lib/rspec/core/configuration.rb +479 -577
  11. data/lib/rspec/core/configuration_options.rb +71 -54
  12. data/lib/rspec/core/drb.rb +111 -0
  13. data/lib/rspec/core/dsl.rb +86 -18
  14. data/lib/rspec/core/example.rb +267 -119
  15. data/lib/rspec/core/example_group.rb +381 -393
  16. data/lib/rspec/core/filter_manager.rb +133 -114
  17. data/lib/rspec/core/flat_map.rb +18 -0
  18. data/lib/rspec/core/formatters/base_formatter.rb +51 -125
  19. data/lib/rspec/core/formatters/base_text_formatter.rb +34 -286
  20. data/lib/rspec/core/formatters/console_codes.rb +24 -1
  21. data/lib/rspec/core/formatters/deprecation_formatter.rb +25 -26
  22. data/lib/rspec/core/formatters/documentation_formatter.rb +27 -25
  23. data/lib/rspec/core/formatters/helpers.rb +14 -36
  24. data/lib/rspec/core/formatters/html_formatter.rb +58 -65
  25. data/lib/rspec/core/formatters/html_printer.rb +12 -18
  26. data/lib/rspec/core/formatters/json_formatter.rb +54 -31
  27. data/lib/rspec/core/formatters/profile_formatter.rb +67 -0
  28. data/lib/rspec/core/formatters/progress_formatter.rb +11 -15
  29. data/lib/rspec/core/formatters/snippet_extractor.rb +22 -11
  30. data/lib/rspec/core/formatters.rb +90 -43
  31. data/lib/rspec/core/hooks.rb +325 -270
  32. data/lib/rspec/core/memoized_helpers.rb +45 -156
  33. data/lib/rspec/core/metadata.rb +284 -236
  34. data/lib/rspec/core/metadata_filter.rb +86 -0
  35. data/lib/rspec/core/mocking_adapters/flexmock.rb +29 -0
  36. data/lib/rspec/core/{mocking/with_mocha.rb → mocking_adapters/mocha.rb} +19 -16
  37. data/lib/rspec/core/mocking_adapters/null.rb +12 -0
  38. data/lib/rspec/core/mocking_adapters/rr.rb +29 -0
  39. data/lib/rspec/core/mocking_adapters/rspec.rb +30 -0
  40. data/lib/rspec/core/notifications.rb +511 -0
  41. data/lib/rspec/core/option_parser.rb +49 -74
  42. data/lib/rspec/core/ordering.rb +156 -0
  43. data/lib/rspec/core/pending.rb +94 -96
  44. data/lib/rspec/core/project_initializer/.rspec +3 -0
  45. data/lib/rspec/core/project_initializer/spec/spec_helper.rb +78 -0
  46. data/lib/rspec/core/project_initializer.rb +24 -64
  47. data/lib/rspec/core/rake_task.rb +44 -130
  48. data/lib/rspec/core/reporter.rb +76 -59
  49. data/lib/rspec/core/ruby_project.rb +2 -1
  50. data/lib/rspec/core/runner.rb +117 -52
  51. data/lib/rspec/core/shared_context.rb +10 -10
  52. data/lib/rspec/core/shared_example_group.rb +108 -121
  53. data/lib/rspec/core/version.rb +3 -1
  54. data/lib/rspec/core/warnings.rb +40 -0
  55. data/lib/rspec/core/world.rb +66 -10
  56. data/lib/rspec/core.rb +64 -104
  57. data.tar.gz.sig +3 -0
  58. metadata +75 -322
  59. metadata.gz.sig +1 -0
  60. data/exe/autospec +0 -13
  61. data/features/Autotest.md +0 -38
  62. data/features/README.md +0 -17
  63. data/features/Upgrade.md +0 -364
  64. data/features/command_line/README.md +0 -28
  65. data/features/command_line/example_name_option.feature +0 -97
  66. data/features/command_line/exit_status.feature +0 -82
  67. data/features/command_line/format_option.feature +0 -75
  68. data/features/command_line/init.feature +0 -18
  69. data/features/command_line/line_number_appended_to_path.feature +0 -140
  70. data/features/command_line/line_number_option.feature +0 -53
  71. data/features/command_line/order.feature +0 -26
  72. data/features/command_line/pattern_option.feature +0 -49
  73. data/features/command_line/rake_task.feature +0 -122
  74. data/features/command_line/require_option.feature +0 -43
  75. data/features/command_line/ruby.feature +0 -22
  76. data/features/command_line/tag.feature +0 -98
  77. data/features/command_line/warnings_option.feature +0 -29
  78. data/features/configuration/alias_example_to.feature +0 -48
  79. data/features/configuration/backtrace_clean_patterns.feature +0 -102
  80. data/features/configuration/custom_settings.feature +0 -84
  81. data/features/configuration/default_path.feature +0 -38
  82. data/features/configuration/deprecation_stream.feature +0 -58
  83. data/features/configuration/fail_fast.feature +0 -77
  84. data/features/configuration/failure_exit_code.feature +0 -36
  85. data/features/configuration/order_and_seed.feature +0 -3
  86. data/features/configuration/output_stream.feature +0 -24
  87. data/features/configuration/pattern.feature +0 -38
  88. data/features/configuration/profile.feature +0 -220
  89. data/features/configuration/read_options_from_file.feature +0 -90
  90. data/features/configuration/run_all_when_everything_filtered.feature +0 -76
  91. data/features/configuration/show_failures_in_pending_blocks.feature +0 -61
  92. data/features/configuration/treat_symbols_as_metadata_keys_with_true_values.feature +0 -52
  93. data/features/example_groups/basic_structure.feature +0 -55
  94. data/features/example_groups/shared_context.feature +0 -74
  95. data/features/example_groups/shared_examples.feature +0 -294
  96. data/features/expectation_framework_integration/configure_expectation_framework.feature +0 -197
  97. data/features/filtering/exclusion_filters.feature +0 -138
  98. data/features/filtering/if_and_unless.feature +0 -168
  99. data/features/filtering/inclusion_filters.feature +0 -105
  100. data/features/formatters/configurable_colors.feature +0 -31
  101. data/features/formatters/custom_formatter.feature +0 -36
  102. data/features/formatters/json_formatter.feature +0 -30
  103. data/features/formatters/text_formatter.feature +0 -46
  104. data/features/helper_methods/arbitrary_methods.feature +0 -40
  105. data/features/helper_methods/let.feature +0 -50
  106. data/features/helper_methods/modules.feature +0 -149
  107. data/features/hooks/around_hooks.feature +0 -343
  108. data/features/hooks/before_and_after_hooks.feature +0 -427
  109. data/features/hooks/filtering.feature +0 -234
  110. data/features/metadata/current_example.feature +0 -56
  111. data/features/metadata/described_class.feature +0 -17
  112. data/features/metadata/user_defined.feature +0 -113
  113. data/features/mock_framework_integration/use_any_framework.feature +0 -106
  114. data/features/mock_framework_integration/use_flexmock.feature +0 -96
  115. data/features/mock_framework_integration/use_mocha.feature +0 -97
  116. data/features/mock_framework_integration/use_rr.feature +0 -98
  117. data/features/mock_framework_integration/use_rspec.feature +0 -97
  118. data/features/pending/pending_examples.feature +0 -229
  119. data/features/spec_files/arbitrary_file_suffix.feature +0 -13
  120. data/features/step_definitions/additional_cli_steps.rb +0 -49
  121. data/features/subject/attribute_of_subject.feature +0 -124
  122. data/features/subject/explicit_subject.feature +0 -101
  123. data/features/subject/implicit_subject.feature +0 -63
  124. data/features/subject/one_liner_syntax.feature +0 -71
  125. data/features/support/env.rb +0 -14
  126. data/features/support/rubinius.rb +0 -6
  127. data/lib/autotest/discover.rb +0 -10
  128. data/lib/autotest/rspec2.rb +0 -77
  129. data/lib/rspec/core/backtrace_cleaner.rb +0 -46
  130. data/lib/rspec/core/backward_compatibility.rb +0 -55
  131. data/lib/rspec/core/caller_filter.rb +0 -60
  132. data/lib/rspec/core/command_line.rb +0 -47
  133. data/lib/rspec/core/deprecated_mutable_array_proxy.rb +0 -32
  134. data/lib/rspec/core/deprecation.rb +0 -26
  135. data/lib/rspec/core/drb_command_line.rb +0 -26
  136. data/lib/rspec/core/drb_options.rb +0 -87
  137. data/lib/rspec/core/extensions/instance_eval_with_args.rb +0 -44
  138. data/lib/rspec/core/extensions/kernel.rb +0 -9
  139. data/lib/rspec/core/extensions/module_eval_with_args.rb +0 -38
  140. data/lib/rspec/core/extensions/ordered.rb +0 -27
  141. data/lib/rspec/core/formatters/text_mate_formatter.rb +0 -34
  142. data/lib/rspec/core/metadata_hash_builder.rb +0 -97
  143. data/lib/rspec/core/mocking/with_absolutely_nothing.rb +0 -11
  144. data/lib/rspec/core/mocking/with_flexmock.rb +0 -27
  145. data/lib/rspec/core/mocking/with_rr.rb +0 -27
  146. data/lib/rspec/core/mocking/with_rspec.rb +0 -27
  147. data/lib/rspec/core/shared_example_group/collection.rb +0 -45
  148. data/spec/autotest/discover_spec.rb +0 -49
  149. data/spec/autotest/failed_results_re_spec.rb +0 -45
  150. data/spec/autotest/rspec_spec.rb +0 -133
  151. data/spec/command_line/order_spec.rb +0 -204
  152. data/spec/rspec/core/backtrace_cleaner_spec.rb +0 -68
  153. data/spec/rspec/core/caller_filter_spec.rb +0 -58
  154. data/spec/rspec/core/command_line_spec.rb +0 -127
  155. data/spec/rspec/core/command_line_spec_output.txt +0 -0
  156. data/spec/rspec/core/configuration_options_spec.rb +0 -417
  157. data/spec/rspec/core/configuration_spec.rb +0 -2072
  158. data/spec/rspec/core/deprecation_spec.rb +0 -27
  159. data/spec/rspec/core/deprecations_spec.rb +0 -59
  160. data/spec/rspec/core/drb_command_line_spec.rb +0 -102
  161. data/spec/rspec/core/drb_options_spec.rb +0 -193
  162. data/spec/rspec/core/dsl_spec.rb +0 -25
  163. data/spec/rspec/core/example_group_spec.rb +0 -1337
  164. data/spec/rspec/core/example_spec.rb +0 -502
  165. data/spec/rspec/core/filter_manager_spec.rb +0 -246
  166. data/spec/rspec/core/formatters/base_formatter_spec.rb +0 -108
  167. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +0 -524
  168. data/spec/rspec/core/formatters/console_codes_spec.rb +0 -50
  169. data/spec/rspec/core/formatters/deprecation_formatter_spec.rb +0 -263
  170. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +0 -89
  171. data/spec/rspec/core/formatters/helpers_spec.rb +0 -104
  172. data/spec/rspec/core/formatters/html_formatted.html +0 -397
  173. data/spec/rspec/core/formatters/html_formatter_spec.rb +0 -131
  174. data/spec/rspec/core/formatters/json_formatter_spec.rb +0 -115
  175. data/spec/rspec/core/formatters/progress_formatter_spec.rb +0 -30
  176. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +0 -26
  177. data/spec/rspec/core/formatters/text_mate_formatted.html +0 -397
  178. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +0 -107
  179. data/spec/rspec/core/hooks_filtering_spec.rb +0 -227
  180. data/spec/rspec/core/hooks_spec.rb +0 -269
  181. data/spec/rspec/core/kernel_extensions_spec.rb +0 -9
  182. data/spec/rspec/core/memoized_helpers_spec.rb +0 -776
  183. data/spec/rspec/core/metadata_spec.rb +0 -514
  184. data/spec/rspec/core/option_parser_spec.rb +0 -297
  185. data/spec/rspec/core/pending_example_spec.rb +0 -260
  186. data/spec/rspec/core/pending_spec.rb +0 -27
  187. data/spec/rspec/core/project_initializer_spec.rb +0 -130
  188. data/spec/rspec/core/rake_task_spec.rb +0 -202
  189. data/spec/rspec/core/reporter_spec.rb +0 -167
  190. data/spec/rspec/core/resources/a_bar.rb +0 -0
  191. data/spec/rspec/core/resources/a_foo.rb +0 -0
  192. data/spec/rspec/core/resources/a_spec.rb +0 -1
  193. data/spec/rspec/core/resources/custom_example_group_runner.rb +0 -14
  194. data/spec/rspec/core/resources/formatter_specs.rb +0 -60
  195. data/spec/rspec/core/resources/utf8_encoded.rb +0 -8
  196. data/spec/rspec/core/rspec_matchers_spec.rb +0 -45
  197. data/spec/rspec/core/ruby_project_spec.rb +0 -26
  198. data/spec/rspec/core/runner_spec.rb +0 -82
  199. data/spec/rspec/core/shared_context_spec.rb +0 -114
  200. data/spec/rspec/core/shared_example_group/collection_spec.rb +0 -70
  201. data/spec/rspec/core/shared_example_group_spec.rb +0 -138
  202. data/spec/rspec/core/world_spec.rb +0 -142
  203. data/spec/rspec/core_spec.rb +0 -108
  204. data/spec/spec_helper.rb +0 -135
  205. data/spec/support/config_options_helper.rb +0 -15
  206. data/spec/support/helper_methods.rb +0 -55
  207. data/spec/support/in_sub_process.rb +0 -37
  208. data/spec/support/isolate_load_path_mutation.rb +0 -6
  209. data/spec/support/isolated_directory.rb +0 -10
  210. data/spec/support/isolated_home_directory.rb +0 -16
  211. data/spec/support/matchers.rb +0 -65
  212. data/spec/support/mathn_integration_support.rb +0 -12
  213. data/spec/support/sandboxed_mock_space.rb +0 -116
  214. data/spec/support/shared_example_groups.rb +0 -42
  215. data/spec/support/silence_dsl_deprecations.rb +0 -32
  216. 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
- class NullConverter; def convert(code, pre); code; end; end
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 'syntax/convertors/html'
12
- @@converter = Syntax::Convertors::HTML.for_syntax "ruby"
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] backtrace the backtrace from a test failure
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, false)
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] error_line file name with line number (i.e. 'foo_spec.rb:12')
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] file filename
55
- # @param [Fixnum] line line number
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] highlighted syntax-highlighted snippet surrounding the offending line of code
77
- # @param [Fixnum] offending_line line where failure occured
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
- # * `start(expected_example_count)`
33
- # * zero or more of the following
34
- # * `example_group_started(group)`
35
- # * `example_started(example)`
36
- # * `example_passed(example)`
37
- # * `example_failed(example)`
38
- # * `example_pending(example)`
39
- # * `message(string)`
40
- # * `stop`
41
- # * `start_dump`
42
- # * `dump_pending`
43
- # * `dump_failures`
44
- # * `dump_summary(duration, example_count, failure_count, pending_count)`
45
- # * `seed(value)`
46
- # * `close`
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
- # You can either implement all of those methods or subclass
49
- # `RSpec::Core::Formatters::BaseTextFormatter` and override the methods you want
50
- # to enhance.
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
- autoload :TextMateFormatter, 'rspec/core/formatters/text_mate_formatter'
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
- @setup = false
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 @default_formatter, output_stream
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
- @formatters.each do |formatter|
92
- @reporter.register_listener formatter, *RSpec::Core::Reporter::NOTIFICATIONS
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
- formatter = formatter_class.new(*args)
104
- if @setup
105
- @reporter.register_listener formatter, *RSpec::Core::Reporter::NOTIFICATIONS
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
- when 't', 'textmate'
141
- if defined?(::RSpec::Mate::Formatters::TextMateFormatter)
142
- RSpec.deprecate "Using the text`#{key.to_s}` as a shortcut for the TextMateFormatter",
143
- :replacement => "`::RSpec::Mate::Formatters::TextMateFormatter`"
144
- else
145
- RSpec.deprecate "Using rspec-core's `::RSpec::Core::TextMateFormatter`",
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