blob: 5b7b729841132a6c1a9d7fce9299bf4d091945cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Banzai::Filter::OutputSafety do
subject do
Class.new do
include Banzai::Filter::OutputSafety
end.new
end
let(:content) { '<pre><code>foo</code></pre>' }
context 'when given HTML is safe' do
let(:html) { content.html_safe }
it 'returns safe HTML' do
expect(subject.escape_once(html)).to eq(html)
end
end
context 'when given HTML is not safe' do
let(:html) { content }
it 'returns escaped HTML' do
expect(subject.escape_once(html)).to eq(ERB::Util.html_escape_once(html))
end
end
end
|