我正在尝试习惯使用Cucumber进行BDD并且我已经写了一些功能但是这个特别让我感到困惑,这里是错误:
Scenario: # features/viewing_posts.feature:6
Given there is a post with the title "Just another day at the beach" # features/step_definitions/post_steps.rb:1
And I am on the homepage # features/step_definitions/web_steps.rb:44
When I follow "Just another day at the beach" # features/step_definitions/web_steps.rb:56
Then I should be on the post page for "Just another day at the beach" # features/step_definitions/web_steps.rb:230
Can't find mapping from "the post page for "Just another day at the beach"" to a path.
Now, go and add a mapping in /Users/jeff/rails_projects/jeffc/features/support/paths.rb (RuntimeError)
./features/support/paths.rb:29:in `rescue in path_to'
./features/support/paths.rb:23:in `path_to'
./features/step_definitions/web_steps.rb:233:in `/^(?:|I )should be on (.+)$/'
features/viewing_posts.feature:10:in `Then I should be on the post page for "Just another day at the beach"'
Failing Scenarios:
cucumber features/viewing_posts.feature:6 # Scenario:
我在那个错误中检查了我的web_steps.rb,我有一个应该匹配的步骤。
Then /^(?:|I )should be on (.+)$/ do |page_name|
current_path = URI.parse(current_url).path
if current_path.respond_to? :should
current_path.should == path_to(page_name)
else
assert_equal path_to(page_name), current_path
end
end
直到“然后我应该在帖子页面上......”
有人能说出这是怎么回事吗?
由于
Ĵ
答案 0 :(得分:4)
期望在paths.rb
Now, go and add a mapping in /Users/jeff/rails_projects/jeffc/features/support/paths.rb (RuntimeError)
您可能需要移动它。您的其他测试是否偶然会出现同样的问题,或者它们是否与您已经获得的相同?