Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

follow link in email

#7

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

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

State: resolved
Milestone: none
Assigned to: Ian White Ian White

Activity

  1. Ian White
    Ian White
    • Assigned user set to Ian White

    November 22nd, 2009 @ 08:55 AM

  2. Ian White
    Ian White

    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?

    November 24th, 2009 @ 10:54 PM

  3. johnf
    johnf

    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

    December 29th, 2009 @ 03:40 AM

  4. Ian White

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.