黄瓜:未定义的步骤,尽管应该定义步骤

时间:2010-10-26 10:58:09

标签: ruby-on-rails cucumber

我创建了这个步骤:

    Given /^the feed "([^"]*)" has an item "([^"]*)" published at "([^"]*)"$/ do |feed_name, feed_item_title, published_at|
  feed = Feed.find_by_name(feed_name)
  FeedItem.make(:feed => feed, :title => feed_item_title, :published_at => published_at)
end

我用以下方式进行黄瓜测试:

Scenario: feed items should be sorted by date
    Given I am signed into an account called "GT" as a customer
    And there is a social feed called "Twitter" for the account "GT"
    And the feed Twitter has an item Majbrasa published at "2010-05-01"
    --- more follows 

黄瓜说:

7 steps (4 skipped, 1 undefined, 2 passed)
You can implement step definitions for undefined steps with these snippets:

Given /^the feed Twitter has an item Majbrasa published at "([^"]*)"$/ do |arg1|
  pending # express the regexp above with the code you wish you had
end

我只是看不出我的步骤有什么问题。我错过了什么? 在此先感谢Emil

1 个答案:

答案 0 :(得分:2)

在你的步骤中,你需要在Twitter周围使用“”,所以对Majbrasa使用相同的

Scenario: feed items should be sorted by date
    Given I am signed into an account called "GT" as a customer
    And there is a social feed called "Twitter" for the account "GT"
    And the feed "Twitter" has an item "Majbrasa" published at "2010-05-01"