require 'rails_helper'
require 'email_cook'
describe EmailCook do
it 'adds linebreaks to short lines' do
expect(EmailCook.new("hello\nworld\n").cook).to eq("hello\n
world\n
")
end
it "doesn't add linebreaks to long lines" do
long = <
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc convallis volutpat
risus. Nulla ac faucibus quam, quis cursus lorem. Sed rutrum eget nunc sed accumsan.
Vestibulum feugiat mi vitae turpis tempor dignissim.
LONG_COOKED
expect(EmailCook.new(long).cook).to eq(long_cooked.strip)
end
it 'autolinks' do
stub_request(:get, "https://www.eviltrout.com").to_return(body: "")
stub_request(:head, "https://www.eviltrout.com").to_return(body: "")
expect(EmailCook.new("https://www.eviltrout.com").cook).to eq("https://www.eviltrout.com
")
end
it 'autolinks without the beginning of a line' do
expect(EmailCook.new("my site: https://www.eviltrout.com").cook).to eq("my site: https://www.eviltrout.com
")
end
it 'links even within a quote' do
expect(EmailCook.new("> https://www.eviltrout.com").cook).to eq("https://www.eviltrout.com
")
end
end