Ruby 除非我使用selenium webdriver,否则Capybara Rspec测试将失败

Ruby 除非我使用selenium webdriver,否则Capybara Rspec测试将失败,ruby,selenium,rspec,sinatra,capybara,Ruby,Selenium,Rspec,Sinatra,Capybara,我目前正在为我正在学习的一门课程编写一个石头剪刀计划 我的特性测试文件如下所示 require 'spec_helper' require 'capybara/dsl' require 'selenium-webdriver' require 'tilt/erb' require './lib/computer.rb' feature 'user can play rock, paper, scissors..' do let(:computer){double :comput

我目前正在为我正在学习的一门课程编写一个石头剪刀计划

我的特性测试文件如下所示

require 'spec_helper'
require 'capybara/dsl'
require 'selenium-webdriver'
require 'tilt/erb'
require './lib/computer.rb'


  feature 'user can play rock, paper, scissors..' do

    let(:computer){double :computer}

    # before do
    #   include Capybara::DSL
    #   Capybara.default_driver = :selenium
    # end

    scenario 'user can enter their name' do
      sign_in
      expect(page).to have_content "Player Name = Reiss"
    end

    scenario 'page has buttons that allows the user to select a move' do
      sign_in
      click_button('Rock')
    end

    scenario 'see what move the computer played' do
      sign_in
      click_button("Rock")
      expect(page).to have_content "The Computer Played"
    end

    scenario 'see what move the computer played' do
      sign_in
      click_button("Paper")
      expect(page).to have_content "You Played Paper"
    end

    scenario 'player plays Rock & either wins or looses' do
      sign_in
      click_button('Rock')
      expect(page).to have_content "Game Result:"
    end

    scenario 'player plays Paper & either wins or looses' do
      sign_in
      click_button('Paper')
      expect(page).to have_content "Game Result:"
    end

    scenario 'player plays Scissors & either wins or looses' do
      sign_in
      click_button('Scissors')
      expect(page).to have_content "Game Result:"
    end

    scenario 'user can play another round if they want to' do
      sign_in
      click_button('Scissors')
      click_button('Play Again')
      expect(page).to have_content "Player Name = Reiss"
    end
  end
我的问题是,当我没有包括Capybara DSL和默认驱动程序循环时,我的测试失败。当循环未被注释掉时。它在firefox中打开并运行测试,然后全部通过。当它不这样做时,rspec将无法通过我的测试。第一个错误是它在页面上找不到我的名字,其余的似乎都在各自的页面上找不到按钮。但再一次,当我使用selenium运行它时,它们都很好。我通常不会被打扰,但我的代码正在与travis CI检查拉请求,因此它目前没有通过


有人能解释一下吗?

你的应用程序依赖于JS吗?如果是(依赖于JS),你可能想看看其中一个无头驱动程序(webkit或poltergeist)——它使CI更容易,你可以摆脱恼人的firefox弹出窗口。