在The training wheels came off由Aslak Hellesoy发表,他说他已经从更新版本的黄瓜中删除了web_steps.rb和paths.rb。测试你在黄瓜和水豚的页面
我可以理解使用水豚api而不是web_steps.rb,但你现在怎么测试你是在一个特定的页面?
这是我如何使用paths.rb做到这一点:
#admin_authentication.feature
Then I should be on the admin home page
# paths.rb
when /the admin home page/
admin_root_path
# 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
作为第二个问题,我们应该在所有这样做呢?
我认为这个答案更符合黄瓜精神和培训轮的文章 – 2013-03-09 20:53:41