Skip to content

Commit 8eab01f

Browse files
committed
Add new tests with syntax highlighting/include:file expectations
1 parent c32f642 commit 8eab01f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

spec/templates/helpers/html_helper_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,30 @@ def options
144144
expect(htmlify("test {include:file:foo.rdoc}", :rdoc).gsub(/[\r?\n]+/, '')).to eq '<p>test HI</p>'
145145
end
146146

147+
it "preserves syntax highlighting in {include:} snippets" do
148+
load_markup_provider(:rdoc)
149+
expect(File).to receive(:file?).with('foo.rdoc').and_return(true)
150+
expect(File).to receive(:read).with('foo.rdoc').and_return(
151+
" !!!ruby\n x = 1\n"
152+
)
153+
expect(htmlify("{include:file:foo.rdoc}", :rdoc).gsub(/[\r?\n]+/, '')).
154+
not_to include("&lt;")
155+
end
156+
157+
it "escapes {include:} html snippets only once" do
158+
expect(self).to receive(:html_syntax_highlight_html) do |source|
159+
%(<strong>#{CGI.escapeHTML(source)}</strong>)
160+
end.at_least(:once)
161+
162+
load_markup_provider(:rdoc)
163+
expect(File).to receive(:file?).with('foo.md').and_return(true)
164+
expect(File).to receive(:read).with('foo.md').and_return(
165+
" !!!html\n <h1>\n"
166+
)
167+
expect(htmlify("{include:file:foo.md}", :markdown).gsub(/[\r?\n]+/, '')).
168+
to include(%(<strong>&lt;h1&gt;</strong>))
169+
end
170+
147171
it "does not autolink URLs inside of {} (markdown specific)" do
148172
log.enter_level(Logger::FATAL) do
149173
pending 'This test depends on markdown' unless markup_class(:markdown)

0 commit comments

Comments
 (0)