#7 ✓resolved
johnf

follow link in email

Reported by johnf | November 13th, 2009 @ 11:58 AM

This is using some code borrowed from ben Mabey's email-spec so that you can follow a link in an email

Would be nice to include something similar in pickle's email steps

Most of the code should probably go in a library somewhere

Then(/^I follow "([^"]+)" in #{capture_email}$/) do |link_regex, email_ref|
urls = URI.extract(email(email_ref).body, ['http', 'https'])

link_regex = /#{Regexp.escape(link_regex)}/ unless link_regex.is_a?(Regexp) url = urls.detect { |link| link =~ link_regex } url = URI::parse(url).request_uri if url

unless url

email(email_ref).body =~ %r{<a[^>]*href=['"]?([^'"]*)['"]?[^>]*?>[^<]*?#{link_regex}[^<]*?</a>}
url = URI.split($~[1])[5..-1].compact!.join("?").gsub("&amp;", "&")

end

visit(url) end

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Assign tickets to <b>Ian White</b>, so I get notified

People watching this ticket

Tags

Referenced by

Pages