尝试将以下内容添加到您的 gem 文件中
group :test do
gem "capybara"
gem "launchy"
end
如果没有这个我不相信 save_and_open_page 将无法工作。
- 更新 -
我已经为你测试过这个,当我使用保存和打开方法时,我得到了同样的错误。在我的设置中,这是因为我的页面正在引用:
<link href="/assets/application.css" media="screen" rel="stylesheet" type="text/css" />
这种情况发生在 Firefox、Chrome 和 Safari 中。据检查员称,没有找到任何文件。
我没有对此进行过详细研究,也没有答案为什么它不起作用。然而,也有很多人为此苦苦挣扎:
https://github.com/jnicklas/capybara/issues/485 https://github.com/jnicklas/capybara/issues/485
并且,有关水豚和资产预编译的更多信息:
https://github.com/jnicklas/capybara/pull/609 https://github.com/jnicklas/capybara/pull/609
这里可能有什么解决办法:
https://groups.google.com/forum/#!msg/ruby-capybara/SBCor8UUj7w/hv97EgUQ1P4J https://groups.google.com/forum/#!msg/ruby-capybara/SBCor8UUj7w/hv97EgUQ1P4J
但是,如果您只想查看页面,您可以尝试以下操作:删除 scrap save_and_open_page 并将测试更改为使用 javascript。这样,我的页面就可以正常打开了。
require 'spec_helper'
describe "Foo" do
it "should fail if Bar is lactose intolerant", :js => true do
# .....
end
end
尝试一下,让我知道是否有帮助。
回应(来自泰勒网站):
我看到该页面几秒钟,然后就消失了。有没有办法让浏览器窗口不关闭?