2011-09-12 57 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

相关问题