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

Commit 0f05884

Browse files
committed
Merge pull request #2038 from weedySeaDragon/issue-2020--remove-ANSICON-warning
Issue 2020 remove ansicon warning
2 parents b2b5af2 + 19c255c commit 0f05884

File tree

4 files changed

+24
-65
lines changed

4 files changed

+24
-65
lines changed

features/.nav

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
- run_all_when_everything_filtered.feature
4141
- configuration:
4242
- read_options_from_file.feature
43+
- color.feature
4344
- fail_fast.feature
4445
- custom_settings.feature
4546
- alias_example_to.feature

features/configuration/color.feature

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Feature: Windows may require additional solutions to display color
2+
3+
The output uses [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) to show text in color. Windows
4+
systems (shells) often don't interpret those codes at all.
5+
6+
If you're on Windows and you see ANSI escape codes in the output
7+
(something like `[1m [31m` ) and your text isn't in different colors,
8+
you may need to install a utility so that your Windows shell will
9+
interpret those codes correctly and show the colors. Here are some
10+
popular solutions:
11+
12+
* [ANSICON](https://github.com/adoxa/ansicon): ANSICON runs 'on top of' cmd or powershell. This is a very
13+
popular solution. You can set it up so that it's always used whenever
14+
you use cmd or powershell, or use it only at specific times.
15+
16+
* Alternatives to cmd.exe or powershell: [ConEmu](http://conemu.github.io/), [Console2](http://sourceforge.net/projects/console/),
17+
[ConsoleZ](https://github.com/cbucher/console)
18+
19+
* Unix-like shells and utilities: [cygwin](https://www.cygwin.com/), [babun](http://babun.github.io/index.html),
20+
[MinGW](http://www.mingw.org/) (Minimalist GNU for Windows)
21+
22+
To find out more, search for information about those solutions.

lib/rspec/core/configuration.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -708,19 +708,7 @@ def color_enabled?(output=output_stream)
708708
end
709709

710710
# Toggle output color.
711-
# @attr true_or_false [Boolean] toggle color enabled
712-
def color=(true_or_false)
713-
return unless true_or_false
714-
715-
if RSpec::Support::OS.windows? && !ENV['ANSICON']
716-
RSpec.warning "You must use ANSICON 1.31 or later " \
717-
"(http://adoxa.3eeweb.com/ansicon/) to use colour " \
718-
"on Windows"
719-
@color = false
720-
else
721-
@color = true
722-
end
723-
end
711+
attr_writer :color
724712

725713
# @private
726714
def libs=(libs)

spec/rspec/core/configuration_spec.rb

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,58 +1156,6 @@ def metadata_hash(*args)
11561156
end
11571157
end
11581158

1159-
context "on windows" do
1160-
before do
1161-
@original_host = RbConfig::CONFIG['host_os']
1162-
RbConfig::CONFIG['host_os'] = 'mingw'
1163-
allow(config).to receive(:require)
1164-
end
1165-
1166-
after do
1167-
RbConfig::CONFIG['host_os'] = @original_host
1168-
end
1169-
1170-
context "with ANSICON available" do
1171-
around(:each) { |e| with_env_vars('ANSICON' => 'ANSICON', &e) }
1172-
1173-
it "enables colors" do
1174-
config.output_stream = StringIO.new
1175-
allow(config.output_stream).to receive_messages :tty? => true
1176-
config.color = true
1177-
expect(config.color).to be_truthy
1178-
end
1179-
1180-
it "leaves output stream intact" do
1181-
config.output_stream = $stdout
1182-
allow(config).to receive(:require) do |what|
1183-
config.output_stream = 'foo' if what =~ /Win32/
1184-
end
1185-
config.color = true
1186-
expect(config.output_stream).to eq($stdout)
1187-
end
1188-
end
1189-
1190-
context "with ANSICON NOT available" do
1191-
around { |e| without_env_vars('ANSICON', &e) }
1192-
1193-
before do
1194-
allow_warning
1195-
end
1196-
1197-
it "warns to install ANSICON" do
1198-
allow(config).to receive(:require) { raise LoadError }
1199-
expect_warning_with_call_site(__FILE__, __LINE__ + 1, /You must use ANSICON/)
1200-
config.color = true
1201-
end
1202-
1203-
it "sets color to false" do
1204-
allow(config).to receive(:require) { raise LoadError }
1205-
config.color = true
1206-
expect(config.color).to be_falsey
1207-
end
1208-
end
1209-
end
1210-
12111159
it "prefers incoming cli_args" do
12121160
config.output_stream = StringIO.new
12131161
allow(config.output_stream).to receive_messages :tty? => true

0 commit comments

Comments
 (0)