我想运行一个测试元素顺序的测试
我希望按日期升序。
这是我的黄瓜特写场景和最后一句话的步骤。
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
我真的有两个问题。第一个问题是如何正确地指定我的测试?我可以指定我的测试以上不同和更正确吗?
我想做的是在两个不同的日期下注册两个不同的事件。该事件稍后将作为列表显示在网页上。然后我想检查事件是否按日期排序。我希望最新日期的活动出现在最上面。
这是我要测试的集合的代码。在某种程度上,我想检查下面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