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

Commit eed4fca

Browse files
committed
fixup! Remove --color and --tty CLI options
1 parent baaa7c1 commit eed4fca

File tree

6 files changed

+17
-27
lines changed

6 files changed

+17
-27
lines changed

Changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Breaking Changes:
1717
(Phil Pirozhkov, #2851)
1818
* Remove deprecated Hash-like behavior from example
1919
execution result. (Phil Pirozhkov, #2862)
20-
* Remove deprecated `color` configuration option. (Phil Pirozhkov, #2864)
20+
* Remove deprecated `color` configuration option and `--color` command line
21+
option. (Phil Pirozhkov, #2864)
2122
* Remove `it_should_behave_like` nested shared group method and
2223
`alias_it_should_behave_like_to` configuration option. (Phil Pirozhkov, #2864)
2324
* Remove deprecated `treat_symbols_as_metadata_keys_with_true_values` configuration

lib/rspec/core/configuration.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,6 @@ def bisect_runner=(value)
396396
@bisect_runner = value
397397
end
398398

399-
# @private
400-
# @deprecated Use {#color_mode} = :on, instead of {#color} with {#tty}
401-
add_setting :tty
402399
# @private
403400
attr_writer :files_to_run
404401
# @private
@@ -812,7 +809,7 @@ def color_enabled?(output=output_stream)
812809
when :on then true
813810
when :off then false
814811
else # automatic
815-
output_to_tty?(output) || tty?
812+
output_to_tty?(output)
816813
end
817814
end
818815

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/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`"

spec/rspec/core/drb_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ def drb_filter_manager_for(args)
125125

126126
it "preserves extra arguments" do
127127
allow(File).to receive(:exist?) { false }
128-
expect(drb_argv_for(%w[ a --drb b --color c ])).to match_array %w[ --color a b c ]
128+
expect(drb_argv_for(%w[ a --drb b --no-color c ])).to match_array %w[ --no-color a b c ]
129129
end
130130

131-
%w(--color --force-color --no-color --fail-fast --profile --backtrace --tty).each do |option|
131+
%w(--force-color --no-color --fail-fast --profile --backtrace).each do |option|
132132
it "includes #{option}" do
133133
expect(drb_argv_for([option])).to include(option)
134134
end
@@ -243,41 +243,41 @@ def drb_filter_manager_for(args)
243243

244244
context "--drb specified in ARGV" do
245245
it "renders all the original arguments except --drb" do
246-
argv = drb_argv_for(%w[ --drb --color --format s --example pattern
246+
argv = drb_argv_for(%w[ --drb --no-color --format s --example pattern
247247
--profile --backtrace -I
248248
path/a -I path/b --require path/c --require
249249
path/d])
250-
expect(argv).to eq(%w[ --color --profile --backtrace --example pattern --format s -I path/a -I path/b --require path/c --require path/d])
250+
expect(argv).to eq(%w[ --no-color --profile --backtrace --example pattern --format s -I path/a -I path/b --require path/c --require path/d])
251251
end
252252
end
253253

254254
context "--drb specified in the options file" do
255255
it "renders all the original arguments except --drb" do
256-
File.open("./.rspec", "w") {|f| f << "--drb --color"}
257-
drb_argv = drb_argv_for(%w[ --tty --format s --example pattern --profile --backtrace ])
258-
expect(drb_argv).to eq(%w[ --color --profile --backtrace --tty --example pattern --format s])
256+
File.open("./.rspec", "w") {|f| f << "--drb --no-color"}
257+
drb_argv = drb_argv_for(%w[ --format s --example pattern --profile --backtrace ])
258+
expect(drb_argv).to eq(%w[ --no-color --profile --backtrace --example pattern --format s])
259259
end
260260
end
261261

262262
context "--drb specified in ARGV and the options file" do
263263
it "renders all the original arguments except --drb" do
264-
File.open("./.rspec", "w") {|f| f << "--drb --color"}
264+
File.open("./.rspec", "w") {|f| f << "--drb --no-color"}
265265
argv = drb_argv_for(%w[ --drb --format s --example pattern --profile --backtrace])
266-
expect(argv).to eq(%w[ --color --profile --backtrace --example pattern --format s])
266+
expect(argv).to eq(%w[ --no-color --profile --backtrace --example pattern --format s])
267267
end
268268
end
269269

270270
context "--drb specified in ARGV and in as ARGV-specified --options file" do
271271
it "renders all the original arguments except --drb and --options" do
272-
File.open("./.rspec", "w") {|f| f << "--drb --color"}
272+
File.open("./.rspec", "w") {|f| f << "--drb --no-color"}
273273
argv = drb_argv_for(%w[ --drb --format s --example pattern --profile --backtrace])
274-
expect(argv).to eq(%w[ --color --profile --backtrace --example pattern --format s ])
274+
expect(argv).to eq(%w[ --no-color --profile --backtrace --example pattern --format s ])
275275
end
276276
end
277277

278278
describe "--drb, -X" do
279279
it "does not send --drb back to the parser after parsing options" do
280-
expect(drb_argv_for(%w[--drb --color])).not_to include("--drb")
280+
expect(drb_argv_for(%w[--drb --no-color])).not_to include("--drb")
281281
end
282282
end
283283
end

0 commit comments

Comments
 (0)