Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to open email which contain non-ascii symbols in "to" field #47

Open
shir opened this issue Jul 30, 2014 · 4 comments
Open

Failed to open email which contain non-ascii symbols in "to" field #47

shir opened this issue Jul 30, 2014 · 4 comments

Comments

@shir
Copy link

shir commented Jul 30, 2014

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

@shir
Copy link
Author

shir commented Jul 30, 2014

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

@bcardarella
Copy link
Contributor

@shir is this a failing test or a fix?

@shir
Copy link
Author

shir commented Jul 30, 2014

@bcardarella it's a quick fix in last comment.

@bcardarella
Copy link
Contributor

@shir after digging around some I believe this is an issue with the mail gem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants