ruby on rails - How to test content of Devise emails with email_spec gem and cucumber? -


i learning how test email generation , delivery cucumber , th email-spec gem.

i have installed gem , generated email_steps.rb file.

however actionmailer::base.deliveries array appears empty not able test email.

my scenario looks this:

background:     given visit user registration page    scenario: happy path - seccessful sign     , fill in user registration form correctly     , click register     redirected users index page     , can see email confirmation notification     , "john89@example.com" should receive email      when open email subject "confirmation instructions"     , follow "confirm account" in email     , redirected sign in page     , fill in sign in form correctly     , click log in     redirected home page     , can see "signed in successfully" notification 

and failing on

and "john89@example.com" should receive email subject "confirmation instructions" 

i have checked email sent in development environment letter opener gem dont know why isnt being found in test environment the

then /^(?:i|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ |address, amount|   unread_emails_for(address).size.should == parse_email_count(amount) end 

step email-spec gem.

is there configuarion settings missing?

the issue had set

  config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } 

in development environment not in test environment meant there error email being sent in test environment though appeared fine when doing manually in development environment.

this main issue, second minor issue had capital letter in email address downcased when sent. meant when email-spec gem looked email not find match because did not match (the 1 in deliveries array downcased).

a great way debug set step definition debugging pages in cucumber below:

then(/^show me page$/)   save_and_open_page end 

this lets view current page in browser allowed me see error messages , figure out problem.

i hope helps if gets stuck on same thing in future


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -