require 'rails_helper' describe WYSIWYGSanitizer do subject { described_class.new } describe '#sanitize' do it 'returns an html_safe string' do expect(subject.sanitize('hello')).to be_html_safe end it 'allows basic html formatting' do html = '
This is a paragraph
' expect(subject.sanitize(html)).to eq(html) end it 'allows links' do html = '' expect(subject.sanitize(html)).to eq(html) end it 'allows headings' do html = 'Fix flaky specs
This is
' expect(subject.sanitize(html)).to eq('This is alert("dangerous");
') end it 'filters images' do html = 'Dangerous
image'
expect(subject.sanitize(html)).to eq('Dangerous image')
end
end
end