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

Commit 3535958

Browse files
committed
The syntax highlighter does not work on windows so disable it for now.
1 parent 43b6d69 commit 3535958

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

Changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ Enhancements:
5353
to force the run to abort after the specified number of failures.
5454
(Jack Scotti, #2065)
5555
* Syntax highlight the failure snippets in text formatters when `color`
56-
is enabled and the `coderay` gem is installed. (Myron Marston, #2109)
56+
is enabled and the `coderay` gem is installed on a POSIX system.
57+
(Myron Marston, #2109)
5758

5859
Bug Fixes:
5960

lib/rspec/core/source/syntax_highlighter.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,17 @@ def highlight(lines)
1515

1616
private
1717

18-
def implementation
19-
return color_enabled_implementation if @configuration.color_enabled?
20-
ColorDisabledImplementation
18+
if RSpec::Support::OS.windows?
19+
# :nocov:
20+
def implementation
21+
WindowsImplementation
22+
end
23+
# :nocov:
24+
else
25+
def implementation
26+
return color_enabled_implementation if @configuration.color_enabled?
27+
ColorDisabledImplementation
28+
end
2129
end
2230

2331
def color_enabled_implementation
@@ -58,6 +66,11 @@ def self.highlight_syntax(lines)
5866
lines
5967
end
6068
end
69+
70+
# @private
71+
# Not sure why, but our code above (and/or coderay itself) does not work
72+
# on Windows, so we disable the feature on Windows.
73+
WindowsImplementation = ColorDisabledImplementation
6174
end
6275
end
6376
end

spec/rspec/core/source/syntax_highlighter_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def be_highlighted
99
include("\e[32m")
1010
end
1111

12-
context "when CodeRay is available" do
12+
context "when CodeRay is available", :unless => RSpec::Support::OS.windows? do
1313
before { expect { require 'coderay' }.not_to raise_error }
1414

1515
it 'highlights the syntax of the provided lines' do
@@ -54,7 +54,7 @@ def be_highlighted
5454
expect(unhighlighted.first).not_to be_highlighted
5555
end
5656

57-
it 'adds a comment explaining the user can get syntax highlighting by installing coderay' do
57+
it 'adds a comment explaining the user can get syntax highlighting by installing coderay', :unless => RSpec::Support::OS.windows? do
5858
lines = ["a = 1", "b = 2"]
5959
expect(highlighter.highlight(lines)).to eq([
6060
"a = 1",
@@ -63,7 +63,7 @@ def be_highlighted
6363
])
6464
end
6565

66-
it 'indents the "install coderay" comment to match the snippet' do
66+
it 'indents the "install coderay" comment to match the snippet', :unless => RSpec::Support::OS.windows? do
6767
lines = [" a = 1", " b = 2"]
6868
expect(highlighter.highlight(lines)).to eq([
6969
" a = 1",

0 commit comments

Comments
 (0)