This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionMailer::Base.default_url_options[:host] |
This is most likely set to localhost:5000 or something like that. Saucelabs on the other hand seems to use a random host. The end result is that when we click the first link within our email, the test fails with a DNS error as the saucelabs selenium server tries to hit localhost:5000 which does not exist at saucelabs. Emailed the folks at saucelabs and they recommended converting links within the email from absolute to relative. Got it done by monkey patching pickle:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Pickle | |
module Email | |
def click_first_link_in_email(email) | |
link = absolute_link_to_relative(links_in_email(email).first) | |
visit link | |
end | |
def absolute_link_to_relative(link) | |
link.slice(/#{ActionMailer::Base.default_url_options[:host]}(.*)/, 1) | |
end | |
end | |
end |
The absolute_link_to_relative method just slices off the hostname in the url using the String#slice method. The first argument is a regular expression built with the ActionMailer host configuration and the second is the capture number.
No comments:
Post a Comment