require 'spec_helper' describe Banzai::Filter::SyntaxHighlightFilter, lib: true do include FilterSpecHelper context "when no language is specified" do it "highlights as plaintext" do result = filter('
def fun end
')
expect(result.to_html).to eq('def fun end
')
end
end
context "when a valid language is specified" do
it "highlights as that language" do
result = filter('def fun end
')
expect(result.to_html).to eq('def fun end
')
end
end
context "when an invalid language is specified" do
it "highlights as plaintext" do
result = filter('This is a test
')
expect(result.to_html).to eq('This is a test
')
end
end
context "when Rouge formatting fails" do
before do
allow_any_instance_of(Rouge::Formatter).to receive(:format).and_raise(StandardError)
end
it "highlights as plaintext" do
result = filter('This is a test
')
expect(result.to_html).to eq('This is a test
')
end
end
end