When(/^I click the "(.*?)" link$/) do |subscribe|
click_on subscribe
end
订阅链接转到外部网站:
https://www.somesite.com/path/to/something?this=that
然而,当我运行该功能时,我收到此错误:
No route matches [GET] "/path/to/something" (ActionController::RoutingError)
如何让capybara关注此外部链接而不是忽略该查询?
答案 0 :(得分:1)
Cucumber和Capybara很遗憾没有使用外部链接。我建议使用Capybara-Mechanize:https://github.com/jeroenvandijk/capybara-mechanize
试试这个(虽然只适用于一个链接):
When(/^I click the "(.*?)" link$/) do
Capybara.current_driver = :mechanize
visit 'https://www.somesite.com/path/to/something?this=that'
end
以下是一些使用示例: http://turriate.com/articles/2011/feb/testing-twitter-oauth-with-real-data/