2

我正在尝试使用 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'

任何想法为什么输出不显示?

4

1 回答 1

7

save_and_open_page尝试在失败的测试之前放置:

it { save_and_open_page; should have_selector('div.alert') }

否则,一旦运行should have_selector('div.alert'),它将不会继续运行,save_and_open_page因为测试已经失败。

于 2012-11-15T18:14:01.223 回答