我想运行一个测试元素顺序的测试 我希望订单按日期升序排列。
这是我的 cucumber 功能场景和最后一句话的步骤。
Scenario: Order of the events should be Ascending
Given I am signed into an account called "Gorilla Tech" as a customer
When I follow "Register"
And I follow "Events"
And I follow "Register new event"
Then I should see the header "Use the form below to register a new event"
And I fill in "Title" with "Apefest 2010"
And I fill in "Event at" with "2010-01-07"
And I fill in "Add a note" with "This was truly awesome"
Then I press "Create"
Then I follow "Register new event"
And I fill in "Title" with "Monkeyfest 2010"
And I fill in "Event at" with "2010-01-08"
And I fill in "Add a note" with "Yeah"
Then "Apefest 2010" should appear before "Monkeyfest 2010"
Then /"(.*)" should appear before "(.*)"/ do |first_example, second_example|
response.body.should =~ /#{first_example}.*#{second_example}/
end
我这里确实有两个问题。第一个是如何正确指定我的测试?我可以在上面指定我的测试不同且更正确吗?
我想做的是在 2 个不同的日期下注册 2 个不同的事件。该事件稍后将在网页上显示为列表。然后我想检查事件是否按日期排序。我希望具有最新日期的事件出现在顶部。
这是我要测试的集合的代码。在某种程度上,我想检查下面的 div 中的集合是否按日期升序排列。
<div id="feeds">
<table>
<caption><%= t('events.all') %></caption>
<thead>
<tr>
<th><%= Event.t(:title) %></th>
<th><%= Event.t(:event_at) %></th>
<th></th>
</tr>
</thead>
<tbody>
<%= render :partial => 'event', :collection => @events %>
</tbody>
</table>
</div>
<%= will_paginate(@events) %>
最佳答案
您编写步骤定义的方式很好,您只需将多行 (m) 开关添加到您的模式。 :)
response.body.should =~ /#{first_item}.*#{second_item}/m
关于ruby-on-rails - 表中元素的 cucumber 测试顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4132758/