ruby-on-rails - 表中元素的 cucumber 测试顺序

标签 ruby-on-rails ruby cucumber bdd

我想运行一个测试元素顺序的测试 我希望订单按日期升序排列。

这是我的 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/

相关文章:

java - Selenium 找不到 css/classname 选择器

spring - 尽管有 `Annotations differs on glue classes found`,如何使用自己的 Spring 上下文配置来定义通用 Cucumber 步骤

ruby-on-rails - Ubuntu 10 ruby 1.9 Rails 3 : No such file or directory

ruby-on-rails - 清理 URL 以防止 Rails 中的 XSS

ruby-on-rails - 我需要什么基本 gem ?

ruby-on-rails - config.cache_classes = true 时缺少方法

java - 是否可以从 JRuby 创建 Java 类并在 Java 中使用它们?

java将字符串与变量名匹配并传递变量的值

css - Rails - CSS 未在 Internet Explorer 中加载

ruby-on-rails - 在 Rails 中预构建 View 缓存