【发布时间】:2017-05-19 10:37:18
【问题描述】:
我有一个用 rspec 编写的测试,在单击链接后检查路径:
click_link("Dew, Muntain A")
expect(current_path).to eq(demographic_information_patient_path(1))
现在,我明白了:
current_path = "/"
demographic_information_patient_path(1) = "/patients/1/demographics"
因此,测试失败。我可以看到,点击链接后,下一页确实是人口统计页面,网址为“/patients/1/demographics”,但不知何故水豚找不到。
注意:当我手动尝试测试并在 rails 控制器中打印 request.url 时,我得到 "/patients/1/demographics"
我能解决的一个原因是,被点击的页面是一个 Angular2 页面,是不是因为水豚找不到正确的 URL?
我对水豚的尝试:
URI.parse(current_url).request_uri #gives "/"
page.current_url #gives "/"
u = page.execute_script("window.location.url"); #gives nil as expected
【问题讨论】:
标签: ruby-on-rails rspec capybara