Then /^I should be on the free signup page$/ do
*current_path.should == free_signup_path*
end
Then /^I should be on the free signup page$/ do
*visit free_signup_path*
end
这两个有什么区别?
最佳答案
#visit
告诉浏览器转到一个新的 url 并将向正在测试的应用程序发起获取请求。 #current_path
可让您读取浏览器所在的当前位置。
注意:在验证当前路径时,您应该停止使用 current_path.should == some_path
,而是使用 page.should have_current_path(some_path)
。 have_current_path 匹配器包括等待行为,将有助于减少使用支持 JS 的驱动程序的测试
关于ruby-on-rails - visit 和 current_path 与 .should 在 rails 中的使用有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35667106/