String interpolation with single and double quotes dealing with escape characters

Public, Testing / TDD, Ruby General

harrylevine

Created: Aug 14, 2015     Updated: Aug 14, 2015


This expectation does not recognize/interpolate the @volunteer.phone_number:

expect(response.body).to include('<Message to="#{@volunteer.phone_number}">Anybody home?</Message>')

By using Ruby programming alternate double quotes it works:

expect(response.body).to include(%Q!<Message to="#{@volunteer.phone_number}">Anybody home?</Message>!)

From: https://en.wikibooks.org/wiki/Ruby_Programming/Alternate_quotes