当js:true时页面空白

时间:2017-01-13 17:17:43

标签: ruby-on-rails-4 rspec capybara poltergeist

我正在写一篇由Capybara和Poltergeist支持的Rspec测试。为测试启用js: true时,生成的页面为空白。 HTML内容只是

<html><head><base href='http://www.hostname.local' /></head><body></body></html>

如果我删除js: true内容,则会显示

  • Rails:4.2
  • Phantom JS:2.1.1
  • Capybara gem:2.11.0
  • Poltergeist gem:1.12.0

在rails_helper.rb中 Capybara.javascript_driver = :poltergeist

测试:

context 'as company_manager' do
    before(:each) do
      @company_manager = create(:user, :company_manager, company: company)
      login_as @company_manager, scope: :user
    end

    context 'show page' do
      it 'should be able to view tenants grid and sort', js: true do
        visit company_lot_path(company_id: company.id, id: lot.id)
        save_and_open_page
        # test cases are here
      end
    end
end

屏幕截图也是空白的。我无法弄清楚为什么在启用javascript时内容为空。

0 个答案:

没有答案