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.

Private method `scan' when using click_first_link_in_email

#26

Hi,

Having an issue on pickle with the 'click first link in email',

Ruby : 1.8.7 (or 1.9.1 tested via both)
Pickle : 0.3.3
gem 'email_spec', :git => "git://github.com/bmabey/email-spec.git", :branch => "rails3" (generated email spec file commented out, only using pickle email_steps.rb)

And 1 email should be delivered

And I click the first link in the email                                                           # features/step_definitions/email_steps.rb:25
  private method `scan' called for #<Mail::Body:0x106238668> (NoMethodError)
  /opt/local/lib/ruby/1.8/uri/common.rb:557:in `extract'
  ./features/step_definitions/email_steps.rb:26:in `/^(?:I|they) click the first link in ((?:(?:(?:a|an|another|the|that) )?(?:(?:first|last|(?:\d+(?:st|nd|rd|th))) )?email))$/'
  features/public/forgotten_password.feature:19:in `And I click the first link in the email'

email_steps.rb

When(/^(?:I|they) click the first link in #{capture_email}$/) do |email_ref|
click_first_link_in_email(email(email_ref)) end

(Show me the email - works perfectly just before) its failing when it goes through email(email_ref) in parser.rb:

given a string like 'foo: "bar", bar: "baz"' returns {"foo" => "bar", "bar" => "baz"}

def parse_fields(fields)
  if fields.blank?
    {}
  elsif fields =~ /^#{match_fields}$/
    fields.scan(/(#{match_field})(?:,|$)/).inject({}) do |m, match|
      m.merge(parse_field(match[0]))
    end
  else
    raise ArgumentError, "The fields string is not in the correct format.\n\n'#{fields}' did not match: #{match_fields}" 
  end
end

Have you seen this before? The email is seeming to fail when scan is run on the passed fields?

I've tested on 1.9.1 and same result too, I'll keep hunting around, but not sure if its come up before?

Cheers,
Tom

Reported by Tom Meier · August 5th, 2010 @ 10:38 PM

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

Activity

  1. Ian White
    Ian White

    This must be a result of the changes in 0.3.2

    Thanks for the bug report, will look into this tomorrow morning.

    Cheers,
    Ian

    August 5th, 2010 @ 11:25 PM

  2. Tom Meier
    Tom Meier

    Found it, i'll work on a spec and commit to a fork... Let you know when its done :)

    August 6th, 2010 @ 07:13 AM

  3. Tom Meier
    Tom Meier

    run out of time, can't duplicate in specs without bringing in some ugly gems that i'd rather not pollute pickle with,

    but in email.rb:

    def links_in_email(email, protos=['http', 'https'])

      URI.extract(email.body.to_s, protos)
    

    end

    (Having a to_s on email.body ensures no private method error is raised when it is scanned via 'extract')

    Cheers,

    Tom

    August 6th, 2010 @ 07:59 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.