2011-09-12 85 views
0

我有以下簡單的黃瓜步:這個黃瓜爲什麼不解析?

Given I submit "Father father father help us" in reply to "Where is the love?"  

我也已經有黃​​瓜步:

Given /^I submit "([^"]*)" in reply to "([^"]*)"$/ do |reply, question| 
    ... 
end 

我每次運行它雖然在最後的問號發送解析器不穩定和我回來了以下內容:

You can implement step definitions for undefined steps with these snippets: 

Given /^I submit "([^"]*)" in reply to Where is the love\?$/ do |arg1| 
    pending # express the regexp above with the code you wish you had 
end 

爲什麼不是這個解析正確,我能做些什麼來糾正它?

回答

0

上面建議的步驟定義與該Cucumber步驟不對應。我懷疑你在功能文件的其他地方有一個幾近完全相同的步驟,但沒有引用「愛在哪裏?」。

+0

我沒有仔細檢查以確定(同時做出其他更改),但我懷疑這幾乎肯定是問題所在。 –

2

我把一個快速測試一起,這裏就是我有。它工作正常,通過了所有測試:

Feature: test 

    Scenario: 
    Given I submit "Father father father help us" in reply to "Where is the love?" 
    When I do this 
    Then I receive that 


Given /^I submit "([^"]*)" in reply to "([^"]*)"$/ do |arg1, arg2| 
    true 
end 

When /^I do this$/ do 
    true 
end 

Then /^I receive that$/ do 
    true 
end 

您正在使用什麼版本的黃瓜?這是我在Gemfile.lock中的內容

cucumber (1.0.2) 
    builder (>= 2.1.2) 
    diff-lcs (>= 1.1.2) 
    gherkin (~> 2.4.5) 
    json (>= 1.4.6) 
    term-ansicolor (>= 1.0.5) 
cucumber-rails (1.0.2) 
    capybara (>= 1.0.0) 
    cucumber (~> 1.0.0) 
    nokogiri (>= 1.4.6) 
+0

感謝您的運行。我不能完全弄清楚發生了什麼,但奇怪的是,當我運行所有其他規格(不只是帶有此標籤的規格)時,所有事情都開始正常工作。正如你所指出的那樣,整個事情似乎都能正常工作,但由於某種原因偶爾之前有些事情正在窒息。 –

+0

是的,我創建了這個功能,並在現有的鐵路項目中進行了大約30或40個定義的黃瓜步驟和六個特徵。我只運行這一個功能文件,並且它運行正常。我知道我有某些嵌套步驟的問題,如果我只運行一個文件。 – agmcleod