电子邮件规范有什么问题?

时间:2012-03-13 09:01:28

标签: ruby-on-rails cucumber email-spec

当我写:

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..."

一切正常。

但如果我写:

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"

没有任何作用......只有一条线被移到了最后......繁荣......

在检查电子邮件之前可能会有一些延迟吗?或类似的东西。

2 个答案:

答案 0 :(得分:2)

这是黄瓜的异步行为。在第一种情况下,您将等待直到通过等待闪存消息完成操作。内部黄瓜驱动程序“等待”,直到元素通过间隔和保护延迟(水豚等待时间)轮询该元素而变得可见。

在第二种情况下,您会立即检查电子邮件。黄瓜对你的控制器/动作一无所知,也不与它们同步。

您可以离开第一个案例,也可以在电子邮件检查步骤中引入某种轮询。

答案 1 :(得分:1)

这可能是一个时间问题,具体取决于您使用的浏览器驱动程序。我们用Capybara和Selenium看了很多。 “我应该看到......”这一步实际上使测试停止并等待以使该消息显示在页面上(即发送电子邮件时)。如果你把它移到最后,那么“应该收到一封电子邮件”的步骤可能发生得太快,在应用实际上有机会发送电子邮件之前做出断言。