gpt4 book ai didi

ruby-on-rails - 使用 Cucumber 和 Capybara 测试您是否在页面上

转载 作者:行者123 更新时间:2023-12-03 18:16:07 26 4
gpt4 key购买 nike

The training wheels came off Aslak Hellesoy 发表的帖子说,他已经从更新的 cucumber 版本中删除了 web_steps.rb 和 paths.rb。

我可以理解使用 Capybara api 而不是 web_steps.rb,但是您现在如何测试您是否在特定页面上?

这就是我过去使用 path.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

作为次要问题,我们应该这样做吗?

最佳答案

我只是喜欢这个,看看它是否适合你:

assert page.current_path == admin_root_path

关于ruby-on-rails - 使用 Cucumber 和 Capybara 测试您是否在页面上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15294376/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com