Ruby on rails Rails黄瓜场景
我对rails还是比较陌生的。当前卡在以下步骤:Ruby on rails Rails黄瓜场景,ruby-on-rails,ruby,ruby-on-rails-3,cucumber,Ruby On Rails,Ruby,Ruby On Rails 3,Cucumber,我对rails还是比较陌生的。当前卡在以下步骤: And I should see "THX-1138" 上一次意外地过去了。然而,我被困在幸福道路的最后一步。以下是我的错误描述: Then I should be on the Similar Movies page for "Star Wars" # features/step_definitions/web_steps.rb:230 And I should see "THX-1138" # features/Search_movie_b
And I should see "THX-1138"
上一次意外地过去了。然而,我被困在幸福道路的最后一步。以下是我的错误描述:
Then I should be on the Similar Movies page for "Star Wars" # features/step_definitions/web_steps.rb:230
And I should see "THX-1138" # features/Search_movie_by_director.feature:25
Ambiguous match of "I should see "THX-1138"":
features/step_definitions/movie_steps.rb:12:in `/^(?:|I )should see "([^"]*)"$/'
features/step_definitions/web_steps.rb:105:in `/^(?:|I )should see "([^"]*)"$/'
You can run again with --guess to make Cucumber be more smart about it
(Cucumber::Ambiguous)
features/Search_movie_by_director.feature:25:in `And I should see "THX-1138"'
在我的路径.rb中,我输入了:
When /the Similar Movies page for "(.*)"/
"/movies/the_same_director/xxx%20XXX"
Then /^(?:|I )should see "([^"]*)"$/ do |title|
if page.respond_to? :should
page.should have_content(title)
else
assert page.has_content?(title)
end
end
在我的电影步骤(怀疑是否相关)中,我输入了:
When /the Similar Movies page for "(.*)"/
"/movies/the_same_director/xxx%20XXX"
Then /^(?:|I )should see "([^"]*)"$/ do |title|
if page.respond_to? :should
page.should have_content(title)
else
assert page.has_content?(title)
end
end
最后在我的电影\u controller.rb中:
def the_same_director
#left it empty for I think its relevant to the happy scenerio
end
有人能给我指一下正确的方向吗?您的步骤名称不明确。将给定的
,
时的,和
以及步骤开始时的视为常规占位符。因此:
And I should see " "
及
实际上是相同的步骤(cumber
将看到步骤功能文件夹中的所有文件,而不管调用它们的是哪个功能文件)
如果它们应该做完全相同的事情,请编写步骤,使它们在要素文件中完全相同(将两者切换为:
Then I should see " "
然后将步骤定义分解出来(将其放入general_steps.rb文件中)
如果它们的行为不同,请更改步骤的名称,使它们不会模棱两可。例如:
Then I should see the movie title " "
及
否则,当您启动cucumber时,您可以使用--guess
标记调用它。这应该可以工作,但您仍然应该修复歧义。感谢Kyle及时提供反馈!