capybara-email
capybara-email copied to clipboard
Failed to open email which contain non-ascii symbols in "to" field
If I send in my application email to address which contain utf-8 symbols ("antoinette.cormier@oconnell.рф"), then open_email("antoinette.cormier@oconnell.рф") returns nil. It's because email.to in email/dsl.rb:23 returns this address encoded as "=?UTF-8?B?YW50b2luZXR0ZS5jb3JtaWVyQG9jb25uZWxsLtGA0YQ=?=" referenced to RFC 6539
Not sure who should decode this value "capybara-email" or "mail" gem.
But here is one of quick fix. Create file spec/support/capybara_email.rb with content:
module Capybara::Email::DSL
def emails_sent_to(recipient)
self.current_emails = all_emails.select { |email| [email.to, email.cc, email.bcc].flatten.compact.map{ |a| Mail::Encodings.value_decode(a) }.include?(recipient) }.map do |email|
driver = Capybara::Email::Driver.new(email)
Capybara::Node::Email.new(Capybara.current_session, driver)
end
end
end
Make sure that support files are included in spec_helper.rb/rails_helper.rb
@shir is this a failing test or a fix?
@bcardarella it's a quick fix in last comment.
@shir after digging around some I believe this is an issue with the mail gem