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 = '

Home

' expect(subject.sanitize(html)).to eq(html) end it "allows headings" do html = "

Objectives

Fix flaky specs

Explain why the test is flaky

" expect(subject.sanitize(html)).to eq(html) end it "filters out dangerous tags" do html = "

This is

" expect(subject.sanitize(html)).to eq("

This is alert('dangerous');

") end it "filters images" do html = "DangerousSmile image" expect(subject.sanitize(html)).to eq("Dangerous image") end end end