Skip to content

Instantly share code, notes, and snippets.

@iafonov
Created Jul 23, 2011
Embed
What would you like to do?
parse the link and put custom host into it
When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
def parse_email_for_anchor_text_link(link_text)
if current_email.body =~ %r{<a[^>]*href=['"]?([^'"]*)['"]?[^>]*?>[^<]*?#{link_text}[^<]*?</a>}
URI.split($1)[5..-1].compact!.join("?").gsub("&amp;", "&")
end
end
url_path = parse_email_for_anchor_text_link(link)
visit "http://test1.localhost:31337#{url_path}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment