我正在为我正在上的课程写一个石头剪刀程序。
我的功能测试文件如下......
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不能通过我的测试。第一个错误是它无法在页面上找到我的名字,其余的都无法在各自的页面上找到按钮。但是,当我用硒运行时,它们都很好。我通常不会感到困扰,但我的代码正在拉动请求中使用travis CI进行检查,因此它目前没有通过!
有人可以解释一下吗?