# frozen_string_literal: true RSpec.describe :highlight do link :highlight, from: :ree_text context "general" do it { expect(highlight("")).to eq("") expect(highlight("This is a beautiful morning", "beautiful")).to eq("This is a beautiful morning") expect(highlight("This is a beautiful morning, but also a beautiful day", "beautiful")).to eq("This is a beautiful morning, but also a beautiful day") expect(highlight("This is a beautiful morning, but also a beautiful day", "beautiful", highlighter: '\1')).to eq("This is a beautiful morning, but also a beautiful day") expect(highlight("This text is not changed because we supplied an empty phrase")).to eq("This text is not changed because we supplied an empty phrase") expect(highlight(" ", "blank text is returned verbatim")).to eq(" ") expect(highlight("This is a beautiful morning", "beautiful")).to eq("This is a beautiful morningcode!") expect(highlight("This is a beautiful morning", "beautiful", sanitize: false)).to eq("This is a beautiful morning") expect(highlight("This is a beautiful! morning", "beautiful!")).to eq("This is a beautiful! morning") expect(highlight("This is a beautiful! morning", "beautiful! morning")).to eq("This is a beautiful! morning") expect(highlight("This is a beautiful? morning", "beautiful? morning")).to eq("This is a beautiful? morning") expect(highlight("This day was challenging for judge Allen and his colleagues.", /\ballen\b/i)).to eq("This day was challenging for judge Allen and his colleagues.") expect(highlight("wow em", %w(wow em), highlighter: '\1')).to eq(%(wow em)) expect(highlight("one two three", ["one", "two", "three"]) { |word| "#{word}" }).to eq("one two three") } end context "highlight with html" do it { expect(highlight("
This is a beautiful morning, but also a beautiful day
", "beautiful")) .to eq("This is a beautiful morning, but also a beautiful day
") expect(highlight("This is a beautiful morning, but also a beautiful day
", "beautiful")) .to eq("This is a beautiful morning, but also a beautiful day
") expect(highlight("This is a beautiful morning, but also a beautiful day
", "beautiful")) .to eq("This is a beautiful morning, but also a beautiful day
") expect(highlight("This is a beautiful morning, but also a beautiful day
", "beautiful")) .to eq("This is a beautiful morning, but also a beautiful day
") expect(highlight("This is a beautiful morning, but also a beautiful day
", "beautiful")) .to eq("This is a beautiful morning, but also a beautiful day
") expect(highlight("