【问题标题】:rspec save_and_open_page does create an html dumprspec save_and_open_page 确实创建了一个 html 转储
【发布时间】:2012-11-15 17:40:26
【问题描述】:

我正在尝试使用 save_and_open_page 查看 rspec 测试失败的详细信息:

相关测试代码

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

测试执行并失败,但现在生成输出

相关 Gemfile sn-p:

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 sn-p(我期待 save_and_open_page 输出到达这里)

Capybara.save_and_open_page_path = 'tmp/test_out'

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

【问题讨论】:

  • 为什么不让capybara使用它的默认路径Rails.root + "tmp/capybara"
  • 我想我喜欢控制自己的目的地:)

标签: ruby-on-rails ruby rspec integration-testing


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 2014-04-27
    • 1970-01-01
    • 1970-01-01
    • 2014-10-14
    相关资源
    最近更新 更多