Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@iafonov
Created July 23, 2011 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iafonov/1101460 to your computer and use it in GitHub Desktop.
Save iafonov/1101460 to your computer and use it in GitHub Desktop.
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