I have a link like this:
< a href= "mailto:<%= @email %>?subject=Answer to complaint&body=<%= @salutation %>,">Answer< /a>
How can I test it using Cucumber/Capybara? I mean something more than just
And I should see "Answer"
I have a link like this:
< a href= "mailto:<%= @email %>?subject=Answer to complaint&body=<%= @salutation %>,">Answer< /a>
How can I test it using Cucumber/Capybara? I mean something more than just
And I should see "Answer"
An addition to Piotr Brudny with URL encode and contains so order of parameters won't matter (I removed the body from there, but you can probably figure it out if you need it.
Then(/^I should have a mailto link with:$/) do |table|
mailto_link = ("//a[contains(@href, \"mailto:#{table.rows_hash['recipient']}\")"\
" and contains(@href, \""+ {
subject: table.rows_hash['subject']
}.to_query + '")]').gsub('+', '%20')
page.should(have_xpath(mailto_link))
end
Similar to the accepted answer, but slightly updated example. You can put it like this:
expect(page).to have_xpath("//a[contains(@href,'mailto:[email protected]')]")