Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 91f3682

Browse files
committed
Raise on legacy formatter usage
1 parent b481bf1 commit 91f3682

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Breaking Changes:
2929
* Remove deprecated `PendingExampleFixedNotification` and
3030
`PendingExampleFailedAsExpectedNotification` classes. (Phil Pirozhkov, #2864)
3131
* Remove deprecated `rerun_argument` example method. (Phil Pirozhkov, #2864)
32+
* Raise on attempt to use a legacy formatter without `rspec-legacy_formatters`.
33+
(Phil Pirozhkov, #2864)
3234

3335
Enhancements:
3436

lib/rspec/core/formatters.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,15 @@ def add(formatter_to_use, *paths)
160160
formatter = RSpec::LegacyFormatters.load_formatter formatter_class, *args
161161
register formatter, formatter.notifications
162162
else
163-
call_site = "Formatter added at: #{::RSpec::CallerFilter.first_non_rspec_line}"
164-
165-
RSpec.warn_deprecation <<-WARNING.gsub(/\s*\|/, ' ')
163+
raise ArgumentError, <<-ERROR.gsub(/\s*\|/, ' ')
166164
|The #{formatter_class} formatter uses the deprecated formatter
167-
|interface not supported directly by RSpec 3.
165+
|interface not supported directly by RSpec 4.
168166
|
169167
|To continue to use this formatter you must install the
170168
|`rspec-legacy_formatters` gem, which provides support
171169
|for legacy formatters or upgrade the formatter to a
172170
|compatible version.
173-
|
174-
|#{call_site}
175-
WARNING
171+
ERROR
176172
end
177173
end
178174

spec/rspec/core/formatters_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ module RSpec::Core::Formatters
8383
end
8484

8585
it "issues a deprecation" do
86-
expect_warn_deprecation(
87-
/The #{formatter_class} formatter uses the deprecated formatter interface.+#{__FILE__}:#{__LINE__ + 1}/)
88-
loader.add formatter_class, output
86+
expect {
87+
loader.add formatter_class, output
88+
}.to raise_error(ArgumentError, /The #{formatter_class} formatter uses the deprecated formatter interface not supported directly by RSpec 4/)
8989
end
9090
end
9191

0 commit comments

Comments
 (0)