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

Commit e0f638d

Browse files
authored
Merge pull request #2864 from rspec/remove-deprecations-2
Remove deprecations
2 parents d50c083 + 91f3682 commit e0f638d

28 files changed

+101
-390
lines changed

Changelog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ Breaking Changes:
1919
execution result. (Phil Pirozhkov, #2862)
2020
* Skip setting the default pattern from Rake task. (Phil Pirozhkov, #2868)
2121
* Remove special `:if`/`:unless` filtering metadata. (Phil Pirozhkov, #2870)
22+
* Remove deprecated `color` configuration option and `--color` command line
23+
option. (Phil Pirozhkov, #2864)
24+
* Remove `it_should_behave_like` nested shared group method and
25+
`alias_it_should_behave_like_to` configuration option. (Phil Pirozhkov, #2864)
26+
* Remove deprecated `treat_symbols_as_metadata_keys_with_true_values` configuration
27+
option. (Phil Pirozhkov, #2864)
28+
* Remove support for Mocha version < 1.0. (Phil Pirozhkov, #2864)
29+
* Remove deprecated `PendingExampleFixedNotification` and
30+
`PendingExampleFailedAsExpectedNotification` classes. (Phil Pirozhkov, #2864)
31+
* 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)
2234

2335
Enhancements:
2436

features/example_groups/shared_examples.feature

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Feature: shared examples
1010
```ruby
1111
include_examples "name" # include the examples in the current context
1212
it_behaves_like "name" # include the examples in a nested context
13-
it_should_behave_like "name" # include the examples in a nested context
1413
matching metadata # include the examples in the current context
1514
```
1615

@@ -206,34 +205,34 @@ Feature: shared examples
206205
207206
RSpec.describe Array, "with 3 items" do
208207
subject { [1, 2, 3] }
209-
it_should_behave_like "a measurable object", 3, [:size, :length]
208+
it_behaves_like "a measurable object", 3, [:size, :length]
210209
end
211210
212211
RSpec.describe String, "of 6 characters" do
213212
subject { "FooBar" }
214-
it_should_behave_like "a measurable object", 6, [:size, :length]
213+
it_behaves_like "a measurable object", 6, [:size, :length]
215214
end
216215
"""
217216
When I run `rspec shared_example_group_params_spec.rb --format documentation`
218217
Then the examples should all pass
219218
And the output should contain:
220219
"""
221220
Array with 3 items
222-
it should behave like a measurable object
221+
behaves like a measurable object
223222
should return 3 from #size
224223
should return 3 from #length
225224
226225
String of 6 characters
227-
it should behave like a measurable object
226+
behaves like a measurable object
228227
should return 6 from #size
229228
should return 6 from #length
230229
"""
231230

232-
Scenario: Aliasing `it_should_behave_like` to `it_has_behavior`
231+
Scenario: Aliasing `it_behaves_like` to `it_has_behavior`
233232
Given a file named "shared_example_group_spec.rb" with:
234233
"""ruby
235234
RSpec.configure do |c|
236-
c.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:'
235+
c.alias_it_behaves_like_to :it_has_behavior, 'has behavior:'
237236
end
238237
239238
RSpec.shared_examples 'sortability' do

features/formatters/custom_formatter.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Feature: custom formatters
1313
"""ruby
1414
class CustomFormatter
1515
# This registers the notifications this formatter supports, and tells
16-
# us that this was written against the RSpec 3.x formatter API.
16+
# us that this was written against the RSpec >= 3.x formatter API.
1717
RSpec::Core::Formatters.register self, :example_started
1818
1919
def initialize(output)

lib/rspec/core.rb

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,7 @@ def self.configure
100100
# The example being executed.
101101
#
102102
# The primary audience for this method is library authors who need access
103-
# to the example currently being executed and also want to support RSpec 2.
104-
#
105-
# @example support for RSpec version 2
106-
#
107-
# RSpec.configure do |c|
108-
# # context.example is deprecated, but RSpec.current_example is not
109-
# # available until RSpec 3.0.
110-
# fetch_current_example = RSpec.respond_to?(:current_example) ?
111-
# proc { RSpec.current_example } : proc { |context| context.example }
112-
#
113-
# c.before(:example) do
114-
# example = fetch_current_example.call(self)
115-
#
116-
# # ...
117-
# end
118-
# end
119-
#
103+
# to the example currently being executed.
120104
def self.current_example
121105
RSpec::Support.thread_local_data[:current_example]
122106
end

lib/rspec/core/configuration.rb

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -348,18 +348,6 @@ def exclude_pattern=(value)
348348
# return [Boolean]
349349
add_setting :silence_filter_announcements
350350

351-
# @deprecated This config option was added in RSpec 2 to pave the way
352-
# for this being the default behavior in RSpec 3. Now this option is
353-
# a no-op.
354-
def treat_symbols_as_metadata_keys_with_true_values=(_value)
355-
RSpec.deprecate(
356-
"RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values=",
357-
:message => "RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values= " \
358-
"is deprecated, it is now set to true as default and " \
359-
"setting it to false has no effect."
360-
)
361-
end
362-
363351
# Record the start time of the spec suite to measure load time.
364352
# return [Time]
365353
add_setting :start_time
@@ -408,9 +396,6 @@ def bisect_runner=(value)
408396
@bisect_runner = value
409397
end
410398

411-
# @private
412-
# @deprecated Use {#color_mode} = :on, instead of {#color} with {#tty}
413-
add_setting :tty
414399
# @private
415400
attr_writer :files_to_run
416401
# @private
@@ -441,7 +426,6 @@ def initialize
441426
@mock_framework = nil
442427
@files_or_directories_to_run = []
443428
@loaded_spec_files = Set.new
444-
@color = false
445429
@color_mode = :automatic
446430
@pattern = '**{,/*/**}/*_spec.rb'
447431
@exclude_pattern = ''
@@ -803,20 +787,6 @@ def full_backtrace=(true_or_false)
803787
@backtrace_formatter.full_backtrace = true_or_false
804788
end
805789

806-
# Enables color output if the output is a TTY. As of RSpec 3.6, this is
807-
# the default behavior and this option is retained only for backwards
808-
# compatibility.
809-
#
810-
# @deprecated No longer recommended because of complex behavior. Instead,
811-
# rely on the fact that TTYs will display color by default, or set
812-
# {#color_mode} to :on to display color on a non-TTY output.
813-
# @see color_mode
814-
# @see color_enabled?
815-
# @return [Boolean]
816-
def color
817-
value_for(:color) { @color }
818-
end
819-
820790
# The mode for determining whether to display output in color. One of:
821791
#
822792
# - :automatic - the output will be in color if the output is a TTY (the
@@ -839,20 +809,13 @@ def color_enabled?(output=output_stream)
839809
when :on then true
840810
when :off then false
841811
else # automatic
842-
output_to_tty?(output) || (color && tty?)
812+
output_to_tty?(output)
843813
end
844814
end
845815

846816
# Set the color mode.
847817
attr_writer :color_mode
848818

849-
# Toggle output color.
850-
#
851-
# @deprecated No longer recommended because of complex behavior. Instead,
852-
# rely on the fact that TTYs will display color by default, or set
853-
# {:color_mode} to :on to display color on a non-TTY output.
854-
attr_writer :color
855-
856819
# @private
857820
def libs=(libs)
858821
libs.map do |lib|
@@ -1101,8 +1064,8 @@ def alias_example_group_to(new_name, *args)
11011064
RSpec::Core::ExampleGroup.define_example_group_method(new_name, extra_options)
11021065
end
11031066

1104-
# Define an alias for it_should_behave_like that allows different
1105-
# language (like "it_has_behavior" or "it_behaves_like") to be
1067+
# Define an alias for it_behaves_like that allows different
1068+
# language (like "it_has_behavior" or "it_is_able_to") to be
11061069
# employed when including shared examples.
11071070
#
11081071
# @example
@@ -1124,13 +1087,10 @@ def alias_example_group_to(new_name, *args)
11241087
# # ...sortability examples here
11251088
#
11261089
# @note Use with caution. This extends the language used in your
1127-
# specs, but does not add any additional documentation. We use this
1128-
# in RSpec to define `it_should_behave_like` (for backward
1129-
# compatibility), but we also add docs for that method.
1090+
# specs, but does not add any additional documentation.
11301091
def alias_it_behaves_like_to(new_name, report_label='')
11311092
RSpec::Core::ExampleGroup.define_nested_shared_group_method(new_name, report_label)
11321093
end
1133-
alias_method :alias_it_should_behave_like_to, :alias_it_behaves_like_to
11341094

11351095
# Adds key/value pairs to the `inclusion_filter`. If `args`
11361096
# includes any symbols that are not part of the hash, each symbol

lib/rspec/core/configuration_options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def organize_options
5858

5959
UNFORCED_OPTIONS = Set.new([
6060
:requires, :profile, :drb, :libs, :files_or_directories_to_run,
61-
:full_description, :full_backtrace, :tty
61+
:full_description, :full_backtrace
6262
])
6363

6464
UNPROCESSABLE_OPTIONS = Set.new([:formatters])

lib/rspec/core/drb.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ def initialize(submitted_options, filter_manager)
4040

4141
def options
4242
argv = []
43-
argv << "--color" if @submitted_options[:color]
4443
argv << "--force-color" if @submitted_options[:color_mode] == :on
4544
argv << "--no-color" if @submitted_options[:color_mode] == :off
4645
argv << "--profile" if @submitted_options[:profile_examples]
4746
argv << "--backtrace" if @submitted_options[:full_backtrace]
48-
argv << "--tty" if @submitted_options[:tty]
4947
argv << "--fail-fast" if @submitted_options[:fail_fast]
5048
argv << "--options" << @submitted_options[:custom_options_file] if @submitted_options[:custom_options_file]
5149
argv << "--order" << @submitted_options[:order] if @submitted_options[:order]

lib/rspec/core/example.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,6 @@ def location_rerun_argument
105105
end
106106
end
107107

108-
# Returns the location-based argument that can be passed to the `rspec` command to rerun this example.
109-
#
110-
# @deprecated Use {#location_rerun_argument} instead.
111-
# @note If there are multiple examples identified by this location, they will use {#id}
112-
# to rerun instead, but this method will still return the location (that's why it is deprecated!).
113-
def rerun_argument
114-
location_rerun_argument
115-
end
116-
117108
# @return [String] the unique id of this example. Pass
118109
# this at the command line to re-run this exact example.
119110
def id

lib/rspec/core/example_group.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def self.define_example_group_method(name, metadata={})
314314
# @!scope class
315315
#
316316
# @see SharedExampleGroup
317-
def self.define_nested_shared_group_method(new_name, report_label="it should behave like")
317+
def self.define_nested_shared_group_method(new_name, report_label="behaves like")
318318
idempotently_define_singleton_method(new_name) do |name, *args, &customization_block|
319319
# Pass :caller so the :location metadata is set properly.
320320
# Otherwise, it'll be set to the next line because that's
@@ -329,10 +329,7 @@ def self.define_nested_shared_group_method(new_name, report_label="it should beh
329329

330330
# Generates a nested example group and includes the shared content
331331
# mapped to `name` in the nested group.
332-
define_nested_shared_group_method :it_behaves_like, "behaves like"
333-
# Generates a nested example group and includes the shared content
334-
# mapped to `name` in the nested group.
335-
define_nested_shared_group_method :it_should_behave_like
332+
define_nested_shared_group_method :it_behaves_like
336333

337334
# Includes shared content mapped to `name` directly in the group in which
338335
# it is declared, as opposed to `it_behaves_like`, which creates a nested

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

lib/rspec/core/mocking_adapters/mocha.rb

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,4 @@
1-
# In order to support all versions of mocha, we have to jump through some
2-
# hoops here.
3-
#
4-
# mocha >= '0.13.0':
5-
# require 'mocha/api' is required.
6-
# require 'mocha/object' raises a LoadError b/c the file no longer exists.
7-
# mocha < '0.13.0', >= '0.9.7'
8-
# require 'mocha/api' is required.
9-
# require 'mocha/object' is required.
10-
# mocha < '0.9.7':
11-
# require 'mocha/api' raises a LoadError b/c the file does not yet exist.
12-
# require 'mocha/standalone' is required.
13-
# require 'mocha/object' is required.
14-
begin
15-
require 'mocha/api'
16-
17-
begin
18-
require 'mocha/object'
19-
rescue LoadError
20-
# Mocha >= 0.13.0 no longer contains this file nor needs it to be loaded.
21-
end
22-
rescue LoadError
23-
require 'mocha/standalone'
24-
require 'mocha/object'
25-
end
1+
require 'mocha/api'
262

273
module RSpec
284
module Core
@@ -33,12 +9,7 @@ def self.framework_name
339
:mocha
3410
end
3511

36-
# Mocha::Standalone was deprecated as of Mocha 0.9.7.
37-
begin
38-
include ::Mocha::API
39-
rescue NameError
40-
include ::Mocha::Standalone
41-
end
12+
include ::Mocha::API
4213

4314
def setup_mocks_for_rspec
4415
mocha_setup

lib/rspec/core/notifications.rb

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,9 @@ def self.for(example)
4242
execution_result = example.execution_result
4343

4444
return SkippedExampleNotification.new(example) if execution_result.example_skipped?
45-
return new(example) unless execution_result.status == :pending || execution_result.status == :failed
45+
return FailedExampleNotification.new(example) if execution_result.status == :pending || execution_result.status == :failed
4646

47-
klass = if execution_result.pending_fixed?
48-
PendingExampleFixedNotification
49-
elsif execution_result.status == :pending
50-
PendingExampleFailedAsExpectedNotification
51-
else
52-
FailedExampleNotification
53-
end
54-
55-
klass.new(example)
47+
new(example)
5648
end
5749

5850
private_class_method :new
@@ -214,12 +206,6 @@ def initialize(example, exception_presenter=Formatters::ExceptionPresenter::Fact
214206
end
215207
end
216208

217-
# @deprecated Use {FailedExampleNotification} instead.
218-
class PendingExampleFixedNotification < FailedExampleNotification; end
219-
220-
# @deprecated Use {FailedExampleNotification} instead.
221-
class PendingExampleFailedAsExpectedNotification < FailedExampleNotification; end
222-
223209
# The `SkippedExampleNotification` extends `ExampleNotification` with
224210
# things useful for specs that are skipped.
225211
#

lib/rspec/core/option_parser.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def parse(source=nil)
1818
return { :files_or_directories_to_run => [] } if original_args.empty?
1919
args = original_args.dup
2020

21-
options = args.delete('--tty') ? { :tty => true } : {}
21+
options = {}
2222
begin
2323
parser(options).parse!(args)
2424
rescue OptionParser::InvalidOption => e
@@ -140,12 +140,6 @@ def parser(options)
140140
options[:full_backtrace] = true
141141
end
142142

143-
parser.on('-c', '--color', '--colour', '') do |_o|
144-
# flag will be excluded from `--help` output because it is deprecated
145-
options[:color] = true
146-
options[:color_mode] = :automatic
147-
end
148-
149143
parser.on('--force-color', '--force-colour', 'Force the output to be in color, even if the output is not a TTY') do |_o|
150144
if options[:color_mode] == :off
151145
abort "Please only use one of `--force-color` and `--no-color`"

0 commit comments

Comments
 (0)