I am testing a mailer in Rspec and have run into a quirk with string concatenation. When I do it as follows:
it 'renders the subject' do
expect(mail.subject).to eq('#{order.firstname} <#{order.email}> has made an order.')
end
I get the following message:
OrderMailer instructions renders the subject
Failure/Error: expect(mail.subject).to eq('#{order.firstname} <#{order.email}> has made an order.')
expected: "\#{order.firstname} <\#{order.email}> has made an order."
got: "Joe <joe@mctester.com> has made an order."
(compared using ==)
However when I do the following it passes:
it 'renders the subject' do
expect(mail.subject).to eq(order.firstname + " <" + order.email + "> has made an order.")
end
What is the correct way to concatenate in rspec? I find the first way far easier on the eye and quicker to work with.