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("&", "&")
end
visit(url) end
Comments and changes to this ticket
-
Ian White November 22nd, 2009 @ 08:55 AM
- Assigned user set to Ian White
-
Ian White November 24th, 2009 @ 10:54 PM
I like this idea, but short of groking the regexp, is the idea that you specify any text that appears of the line containing the link, and it parses the whole link to follow?
-
johnf December 29th, 2009 @ 03:40 AM
Basically it matches the content of any anchor tag and then follows that link. It's ripped out of Ben Maybey's email-rspec which I was previously using in my projects
-
Ian White February 25th, 2010 @ 10:08 AM
- State changed from new to resolved
(from [ff2e60ad09f67fa551c6781dc69ca62a8ededdf9]) Add notes about new follow links in email steps [#7 state:resolved] http://github.com/ianwhite/pickle/commit/ff2e60ad09f67fa551c6781dc6...
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.
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
- 7 follow link in email (from [ff2e60ad09f67fa551c6781dc69ca62a8ededdf9]) Add not...