我正在尝试使用 save_and_open_page 查看 rspec 测试失败原因的详细信息:
相关测试代码
it { should have_selector('div.alert'); save_and_open_page}
测试执行失败但现在生成输出
相关 Gemfile 片段:
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '4.1.0'
gem 'launchy'
end
Launchy 安装成功:
$ bundle show launchy
//.rvm/gems/ruby-1.9.3-p286/gems/launchy-2.1.2
相关的 config/test.rb 片段(我期待 save_and_open_page 输出到达这里)
Capybara.save_and_open_page_path = 'tmp/test_out'
输出不显示的任何想法?
最佳答案
尝试将 save_and_open_page
放在失败的测试之前:
it { save_and_open_page; should have_selector('div.alert') }
否则,一旦它运行 should have_selector('div.alert')
,它就不会继续到 save_and_open_page
,因为测试已经失败。
关于ruby-on-rails - rspec save_and_open_page 确实创建了一个 html 转储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13403148/