3

我正在使用rspec功能和capybara来测试我的rails 3.1应用程序。有时保存我们正在访问的页面的静态 html 并浏览一下会很有用。这就是save_and_open_page方法的用途。

但是 capybara 在名为tmp/capybara的目录中生成一个 html 文件,所以如果我的样式表和 javascripts 的路径如下所示:

<script src="/javascripts/application.js?1362462583" type="text/javascript"></script>

它们不会被找到,因为这个绝对路径假定我们在/public目录中。

保存页面并正确打开它的最佳解决方案是什么?

4

1 回答 1

4

Asset pipeline support for save_and_open_page will be available in Capybara v2.1, see https://github.com/jnicklas/capybara/pull/958

In the meantime you have to use the selenium driver and halt the test execution using methods sleep gets or binding.pry so that you can interact with the selenium browser

于 2013-03-05T12:14:30.273 回答