-1

When I write:

When I fill in "To" with "example1@example.com, example2@example.com"
And I press "Send testimonials request"
Then I should see "Testimonial requests have been successfully sent"
And "example1@example.com" should receive an email with subject "Add a testimonial..."
And "example2@example.com" should receive an email with subject "Add a testimonial..."

everything works fine.

But if I write:

When I fill in "To" with "example1@example.com, example2@example.com"
And I press "Send testimonials request"
Then "example1@example.com" should receive an email with subject "Add a testimonial..."
And "example2@example.com" should receive an email with subject "Add a testimonial..."
And I should see "Testimonial requests have been successfully sent"

Nothing works... Just one line was moved to the end and... boom..

May the reason be in some delay before checking email? or something like that.

ValeriiVasin
  • 8,628
  • 11
  • 58
  • 78
  • and... boom.. is not a good description. You should add some details. – lucapette Mar 13 '12 at 09:12
  • Boom.. means nothing. I've seen the error message: "expected: 1, got: 0". Something like that. – ValeriiVasin Mar 13 '12 at 09:54
  • I think you'd get a better answer if you included the exact error message you're seeing, and also the step definition code (or are these the built-in web_steps?) – Jon M Mar 14 '12 at 03:45

2 Answers2

2

This is asynchronous behavior of cucumber. In the first case you're waiting until action completed by waiting for a flash message. Internally cucumber driver "waits" until element would become visible by polling this element with interval and guard delay (capybara wait time).

And in second case you're immediately checking for an email. Cucumber knows nothing about your controllers/actions and isn't synchronized with them.

You can either left the first case or introduce some kind of polling in email checking step.

iafonov
  • 5,152
  • 1
  • 25
  • 21
1

This could well be a timing issue, depending on the browser driver you're using. We've seen this a lot using Capybara with Selenium. The step 'I should see...' actually makes the test stop and wait for that message to be displayed on the page (which is when the email sending happens). If you move that to the end, there's a chance that the 'should receive an email' step is just happening too quickly, making the assertion before the app has actually had a chance to send the email.

Jon M
  • 11,669
  • 3
  • 41
  • 47