我正在构建一个Rails应用程序,它具有一种彩票功能,其中n票在一段时间结束时被选为获胜者。该网站有一个javascript倒计时,当它达到零时将触发一个事件。如果用户是赢家,此事件将触发浏览器检查服务器。我有一个Cucumber功能,内容如下:
Feature: Notify Winners
So that I can tell if I've won
As an authenticated user
I want to be notified if I've won when the countdown completes
Scenario: I have a winning ticket
Given I'm logged in
And I have a winning ticket for today
When I'm on the home page
And the countdown completes
Then I should see "congratulations"
此时,我怀疑这个功能是否以合理的方式编写。据我所知,在Cucumber中,我无法验证倒计时实际完成的时间(例如,通过侦听JS事件)。
保持原样,“倒数完成时”步骤定义是我不确定如何定义的。有关如何更好地测试此功能的任何指示?