Skip to content

Commit 8abb266

Browse files
committed
Implement explanation_with_linebreaks. [zipmark#275]
1 parent f4b7578 commit 8abb266

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/rspec_api_documentation/views/slate_example.rb

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ def curl_with_linebreaks
1111
line.rstrip.gsub("\t", ' ').gsub(' ', ' ').gsub('\\', '\')
1212
end.join "<br>"
1313
end
14+
15+
def explanation_with_linebreaks
16+
explanation.gsub "\n", "<br>\n"
17+
end
1418
end
1519
end
1620
end

spec/views/slate_example_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,12 @@
5353
end
5454
end
5555
end
56+
57+
describe '#explanation_with_linebreaks' do
58+
it 'returns the explanation with HTML linebreaks' do
59+
explanation = "Line 1\nLine 2\nLine 3\Line 4"
60+
allow(slate_example).to receive(:explanation).and_return explanation
61+
expect(slate_example.explanation_with_linebreaks).to be == explanation.gsub("\n", "<br>\n")
62+
end
63+
end
5664
end

0 commit comments

Comments
 (0)