capybara-email: open_email does not appear to work
background do
recipient_user = double()
recipient_user.stub(:name) {'Ash Williams'}
recipient_user.stub(:email) {'theKing@email.com'}
message = mock_model( Message,
recipient: recipient_user
)
Mailer.sponsored_challenge_promotion(message).deliver!
open_email('theKing@email.com')
end
scenario 'should say hello to the user' do
current_email.should have_content "Hello, Ash"
end
in this scenario, both open_email and current_email return nil
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 2
- Comments: 21 (1 by maintainers)
From @ghost’s comment back in 2015, you may get an “undefined” error if you are trying to use the library in an email spec test. The DSL is not included by default in these tests. To include them, add
to the top of the email spec.
I was able to access the email by passing the action that sends the email to
perform_enqueued_jobs. My test looks likeHope this helps.
@joethrive Make sure you follow the setup guide for capybara-email: https://github.com/DavyJonesLocker/capybara-email#setting-your-test-host
Also, you might need to set your job queue adapter to inline for testing. config/environments/test.rb: config.active_job.queue_adapter = :inline