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

Commit f6c4430

Browse files
committed
Rename SnippetExtractor to HtmlSnippetExtractor
1 parent 7477810 commit f6c4430

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

lib/rspec/core/formatters/html_formatter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ def percent_done
137137
# spec. For example, you could output links to images or other files
138138
# produced during the specs.
139139
def extra_failure_content(failure)
140-
RSpec::Support.require_rspec_core "formatters/snippet_extractor"
140+
RSpec::Support.require_rspec_core "formatters/html_snippet_extractor"
141141
backtrace = (failure.exception.backtrace || []).map do |line|
142142
RSpec.configuration.backtrace_formatter.backtrace_line(line)
143143
end
144144
backtrace.compact!
145-
@snippet_extractor ||= SnippetExtractor.new
145+
@snippet_extractor ||= HtmlSnippetExtractor.new
146146
" <pre class=\"ruby\"><code>#{@snippet_extractor.snippet(backtrace)}</code></pre>"
147147
end
148148
end

lib/rspec/core/formatters/snippet_extractor.rb renamed to lib/rspec/core/formatters/html_snippet_extractor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Formatters
55
#
66
# Extracts code snippets by looking at the backtrace of the passed error
77
# and applies synax highlighting and line numbers using html.
8-
class SnippetExtractor
8+
class HtmlSnippetExtractor
99
# @private
1010
module NullConverter
1111
def self.convert(code)

spec/rspec/core/formatters/snippet_extractor_spec.rb renamed to spec/rspec/core/formatters/html_snippet_extractor_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
require 'rspec/core/formatters/snippet_extractor'
1+
require 'rspec/core/formatters/html_snippet_extractor'
22

33
module RSpec
44
module Core
55
module Formatters
6-
RSpec.describe SnippetExtractor do
6+
RSpec.describe HtmlSnippetExtractor do
77
it "falls back on a default message when it doesn't understand a line" do
8-
expect(RSpec::Core::Formatters::SnippetExtractor.new.snippet_for("blech")).to eq(["# Couldn't get snippet for blech", 1])
8+
expect(RSpec::Core::Formatters::HtmlSnippetExtractor.new.snippet_for("blech")).to eq(["# Couldn't get snippet for blech", 1])
99
end
1010

1111
it "falls back on a default message when it doesn't find the file" do
12-
expect(RSpec::Core::Formatters::SnippetExtractor.new.lines_around("blech", 8)).to eq("# Couldn't get snippet for blech")
12+
expect(RSpec::Core::Formatters::HtmlSnippetExtractor.new.lines_around("blech", 8)).to eq("# Couldn't get snippet for blech")
1313
end
1414

1515
it "falls back on a default message when it gets a security error" do
1616
message = nil
1717
with_safe_set_to_level_that_triggers_security_errors do
18-
message = RSpec::Core::Formatters::SnippetExtractor.new.lines_around("blech", 8)
18+
message = RSpec::Core::Formatters::HtmlSnippetExtractor.new.lines_around("blech", 8)
1919
end
2020
expect(message).to eq("# Couldn't get snippet for blech")
2121
end
2222

2323
describe "snippet extraction" do
2424
let(:snippet) do
25-
SnippetExtractor.new.snippet(["#{__FILE__}:#{__LINE__}"])
25+
HtmlSnippetExtractor.new.snippet(["#{__FILE__}:#{__LINE__}"])
2626
end
2727

2828
before do
2929
# `send` is required for 1.8.7...
30-
@orig_converter = SnippetExtractor.send(:class_variable_get, :@@converter)
30+
@orig_converter = HtmlSnippetExtractor.send(:class_variable_get, :@@converter)
3131
end
3232

3333
after do
34-
SnippetExtractor.send(:class_variable_set, :@@converter, @orig_converter)
34+
HtmlSnippetExtractor.send(:class_variable_set, :@@converter, @orig_converter)
3535
end
3636

3737
it 'suggests you install coderay when it cannot be loaded' do
38-
SnippetExtractor.send(:class_variable_set, :@@converter, SnippetExtractor::NullConverter)
38+
HtmlSnippetExtractor.send(:class_variable_set, :@@converter, HtmlSnippetExtractor::NullConverter)
3939

4040
expect(snippet).to include("Install the coderay gem")
4141
end

0 commit comments

Comments
 (0)