Skip to content

Instantly share code, notes, and snippets.

@agibralter
Created December 9, 2008 20:46
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 agibralter/34079 to your computer and use it in GitHub Desktop.
Save agibralter/34079 to your computer and use it in GitHub Desktop.
When %r{^'(.*?)' deletes his welcome email$} do |user_email|
to_remove = nil
ActionMailer::Base.deliveries.each do |email|
email_msg = email.to_s.gsub("=\n", '')
next unless email_msg =~ Regexp.new("To: #{user_email}")
if email_msg =~ /.*http:\/\/.*?(\/reset_password\/[\w]+).*/mi
to_remove = email
break
end
end
ActionMailer::Base.deliveries.delete_if { |email| email == to_remove } if to_remove
end
When %r{^'(.*?)' clicks his email verification link$} do |user_email|
ActionMailer::Base.deliveries.each do |email|
email_msg = email.to_s
email_msg.should =~ Regexp.new("To: #{user_email}")
next unless email_msg =~ /http:\/\/.*?\/verify_email/
link = email_msg.gsub("=\n", '').gsub(/.*http:\/\/.*?(\/verify_email\/[\w]+).*/mi, '\1')
get link
break
end
end
When %r{^'(.*?)' clicks his reset password link$} do |user_email|
ActionMailer::Base.deliveries.each do |email|
email_msg = email.to_s
email_msg.should =~ Regexp.new("To: #{user_email}")
next unless email_msg =~ /http:\/\/.*?\/reset_password/
link = email_msg.gsub("=\n", '').gsub(/.*http:\/\/.*?(\/reset_password\/[\w]+).*/mi, '\1')
get link
break
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment