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

Commit f21bb65

Browse files
committed
remove coreray warning
1 parent b1b5bf4 commit f21bb65

File tree

5 files changed

+8
-76
lines changed

5 files changed

+8
-76
lines changed

lib/rspec/core/notifications.rb

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,8 @@ def fully_formatted
281281
# @attr pending_examples [Array<RSpec::Core::Example>] the pending examples
282282
# @attr load_time [Float] the number of seconds taken to boot RSpec
283283
# and load the spec files
284-
# @attr syntax_highlighting_unavailable [Boolean] indicates if syntax highlighting
285-
# was attempted to be used but was unavailable.
286-
SummaryNotification = Struct.new(:duration, :examples, :failed_examples, :pending_examples,
287-
:load_time, :syntax_highlighting_unavailable)
284+
SummaryNotification = Struct.new(:duration, :examples, :failed_examples,
285+
:pending_examples, :load_time)
288286
class SummaryNotification
289287
# @api
290288
# @return [Fixnum] the number of examples run
@@ -362,11 +360,7 @@ def formatted_load_time
362360
# @return [String] The summary information fully formatted in the way that
363361
# RSpec's built-in formatters emit.
364362
def fully_formatted(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
365-
formatted = ""
366-
if syntax_highlighting_unavailable
367-
formatted << "\nSyntax highlighting of failure snippets unavailable -- install the coderay gem to enable it.\n"
368-
end
369-
formatted << "\nFinished in #{formatted_duration} " \
363+
formatted = "\nFinished in #{formatted_duration} " \
370364
"(files took #{formatted_load_time} to load)\n" \
371365
"#{colorized_totals_line(colorizer)}\n"
372366

lib/rspec/core/reporter.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ def initialize(configuration)
2222

2323
# @private
2424
attr_reader :examples, :failed_examples, :pending_examples
25-
# @private
26-
attr_accessor :syntax_highlighting_unavailable
2725

2826
# @private
2927
def reset
@@ -167,8 +165,7 @@ def finish
167165
@profiler.example_groups)
168166
end
169167
notify :dump_summary, Notifications::SummaryNotification.new(@duration, @examples, @failed_examples,
170-
@pending_examples, @load_time,
171-
syntax_highlighting_unavailable)
168+
@pending_examples, @load_time)
172169
notify :seed, Notifications::SeedNotification.new(@configuration.seed, seed_used?)
173170
end
174171
end

lib/rspec/core/source/syntax_highlighter.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ def implementation
3131
def color_enabled_implementation
3232
@color_enabled_implementation ||= begin
3333
::Kernel.require 'coderay'
34-
@configuration.reporter.syntax_highlighting_unavailable = false
3534
CodeRayImplementation
3635
rescue LoadError
37-
@configuration.reporter.syntax_highlighting_unavailable = true
3836
NoSyntaxHighlightingImplementation
3937
end
4038
end

spec/rspec/core/reporter_spec.rb

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,6 @@ module RSpec::Core
3535
reporter.finish
3636
end
3737

38-
let(:install_coderay_snippet) { "install the coderay gem" }
39-
40-
def formatter_notified_of_dump_summary(syntax_highlighting_unavailable)
41-
formatter = spy("formatter")
42-
reporter.syntax_highlighting_unavailable = syntax_highlighting_unavailable
43-
reporter.register_listener formatter, :dump_summary
44-
45-
reporter.start(0)
46-
reporter.finish
47-
formatter
48-
end
49-
50-
it "includes a note about install coderay if syntax highlighting is unavailable" do
51-
formatter = formatter_notified_of_dump_summary(true)
52-
53-
expect(formatter).to have_received(:dump_summary).with(an_object_having_attributes(
54-
:fully_formatted => a_string_including(install_coderay_snippet)
55-
))
56-
end
57-
58-
it "does not include a note about installing coderay if syntax highlighting is available" do
59-
formatter = formatter_notified_of_dump_summary(false)
60-
61-
expect(formatter).to have_received(:dump_summary).with(an_object_having_attributes(
62-
:fully_formatted => a_string_excluding(install_coderay_snippet)
63-
))
64-
end
6538
end
6639

6740
describe 'start' do

spec/rspec/core/source/syntax_highlighter_spec.rb

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ class RSpec::Core::Source
55
let(:config) { RSpec::Core::Configuration.new.tap { |c| c.color = true } }
66
let(:highlighter) { SyntaxHighlighter.new(config) }
77

8-
def be_highlighted
9-
include("\e[32m")
10-
end
11-
128
context "when CodeRay is available", :unless => RSpec::Support::OS.windows? do
139
before { expect { require 'coderay' }.not_to raise_error }
1410

@@ -42,22 +38,6 @@ def be_highlighted
4238
expect(highlighter.highlight(['[:ok, "ok"]']).first).not_to be_highlighted
4339
end
4440

45-
it 'notifies the reporter' do
46-
config.reporter.syntax_highlighting_unavailable = true
47-
48-
expect {
49-
highlighter.highlight([""])
50-
}.to change { config.reporter.syntax_highlighting_unavailable }.to(false)
51-
end
52-
53-
it 'does not notify the reporter if highlighting is never attempted' do
54-
config.reporter.syntax_highlighting_unavailable = true
55-
56-
expect {
57-
SyntaxHighlighter.new(config)
58-
}.not_to change { config.reporter.syntax_highlighting_unavailable }
59-
end
60-
6141
it "rescues coderay failures since we do not want a coderay error to be displayed instead of the user's error" do
6242
allow(CodeRay).to receive(:encode).and_raise(Exception.new "boom")
6343
lines = [":ok"]
@@ -95,21 +75,11 @@ def be_highlighted
9575
expect(highlighter.highlight(lines)).to eq(lines)
9676
end
9777

98-
it 'notifies the reporter', :unless => RSpec::Support::OS.windows? do
99-
config.reporter.syntax_highlighting_unavailable = false
100-
101-
expect {
102-
highlighter.highlight([""])
103-
}.to change { config.reporter.syntax_highlighting_unavailable }.to(true)
104-
end
105-
106-
it 'does not notify the reporter if highlighting is never attempted' do
107-
config.reporter.syntax_highlighting_unavailable = false
78+
end
10879

109-
expect {
110-
SyntaxHighlighter.new(config)
111-
}.not_to change { config.reporter.syntax_highlighting_unavailable }
112-
end
80+
def be_highlighted
81+
include("\e[32m")
11382
end
83+
11484
end
11585
end

0 commit comments

Comments
 (0)