Avoid js driver
This commit is contained in:
parent
fe136d1764
commit
13730bf979
@ -1,9 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.feature "EndOfGames", type: :feature, js: true do
|
||||
RSpec.feature "EndOfGames", type: :feature do
|
||||
# Given I am in a started game
|
||||
before(:each) do
|
||||
page.driver.browser.manage.window.resize_to(1640, 1090)
|
||||
# If test is unable to click correct card, use wider window
|
||||
# page.driver.browser.manage.window.resize_to(1640, 1090)
|
||||
@game = setup_game
|
||||
@game.reload
|
||||
@player = @game.controlling_player
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
# As a visitor
|
||||
# I want to quickly join a game
|
||||
# So I can play
|
||||
feature 'Play now', :devise, js: true do
|
||||
feature 'Play now', :devise do
|
||||
# Scenario: Visitor can play now
|
||||
# Given I am not signed in
|
||||
# When I click Play Now
|
||||
|
||||
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||
include Warden::Test::Helpers
|
||||
Warden.test_mode!
|
||||
|
||||
feature 'Play a hand', type: :feature, js: true do
|
||||
feature 'Play a hand', type: :feature do
|
||||
before(:each) do
|
||||
@game = setup_game
|
||||
@game.reload
|
||||
@ -37,7 +37,7 @@ feature 'Play a hand', type: :feature, js: true do
|
||||
# No play to beat, because play was invalid
|
||||
expect(@game.play_to_beat).to eq(nil)
|
||||
# TODO: This scenario is causing other scenarios to fail unless we slow down here
|
||||
sleep 1
|
||||
# sleep 1
|
||||
# TODO: Flash messages
|
||||
#expect(page).to have_content "First hand must contain the lowest card: #{@game.lowest_card.to_s}"
|
||||
end
|
||||
@ -48,7 +48,9 @@ feature 'Play a hand', type: :feature, js: true do
|
||||
# Then I see the hand to beat is this play
|
||||
scenario 'first play contains lowest card' do
|
||||
@card_to_play = @game.lowest_card
|
||||
find_card(@card_to_play).click(x: 0, y: 0)
|
||||
# If test can't click card enable js and click coordinates
|
||||
# find_card(@card_to_play).click(x: 0, y: 0)
|
||||
find_card(@card_to_play).click
|
||||
click_button 'Play Hand'
|
||||
expect(cards_to_beat).to eq @game.lowest_card.to_s
|
||||
end
|
||||
@ -166,11 +168,11 @@ feature 'Play a hand', type: :feature, js: true do
|
||||
# Given I am the active player
|
||||
# When I pass
|
||||
# Then I see an successful pass message
|
||||
scenario 'active player can pass' do
|
||||
scenario 'active player can pass', js: true do
|
||||
@current_user = @game.controlling_player
|
||||
accept_confirm do
|
||||
click_button 'Pass'
|
||||
# binding.pry
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
end
|
||||
# click_button "pass_hand_button_#{@player.id}"
|
||||
## TODO: Flash messages
|
||||
expect(page).to have_content 'Successfully passed.'
|
||||
@ -213,7 +215,6 @@ feature 'Play a hand', type: :feature, js: true do
|
||||
|
||||
expect(page).to have_button 'Play Hand'
|
||||
expect(@game.player_to_beat).to eq(@game.controlling_player)
|
||||
debug
|
||||
expect(page).to have_content "Hand to beat:\nNone"
|
||||
end
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
# As a visitor
|
||||
# I want to sit in a seat
|
||||
# So I can be at a table and play a game
|
||||
feature 'Seats', :devise, js: true do
|
||||
feature 'Seats', :devise do
|
||||
context "As a visitor" do
|
||||
before(:each) do
|
||||
@table = FactoryGirl.create :table
|
||||
@ -62,7 +62,7 @@ feature 'Seats', :devise, js: true do
|
||||
find_all(:button, "Sit")
|
||||
end
|
||||
|
||||
scenario 'visitor can leave the current game' do
|
||||
scenario 'visitor can leave the current game', js: true do
|
||||
click_button 'Sit', match: :first
|
||||
expect(page).to have_content 'Guest'
|
||||
expect(page.text.scan('Guest').count).to eq 1
|
||||
@ -95,7 +95,7 @@ feature 'Seats', :devise, js: true do
|
||||
expect(page.text.scan(@user.email).count).to eq 1
|
||||
end
|
||||
|
||||
scenario 'user can leave the current game' do
|
||||
scenario 'user can leave the current game', js: true do
|
||||
click_button 'Sit', match: :first
|
||||
expect(page).to have_content @user.email
|
||||
expect(page.text.scan(@user.email).count).to eq 1
|
||||
|
||||
@ -8,7 +8,7 @@ feature 'Table index', :devise do
|
||||
# Given I am not signed in
|
||||
# When I click browse tables
|
||||
# Then I see an index of tables
|
||||
scenario 'I can see all the tables', js: true do
|
||||
scenario 'I can see all the tables' do
|
||||
5.times { FactoryGirl.create :table }
|
||||
visit root_path
|
||||
click_link 'Browse Tables'
|
||||
@ -24,7 +24,7 @@ feature 'Table index', :devise do
|
||||
# Given I am signed in
|
||||
# When I click browse tables
|
||||
# Then I see an index of tables
|
||||
scenario 'I can see all the tables', js: true do
|
||||
scenario 'I can see all the tables' do
|
||||
@user = FactoryGirl.create :user
|
||||
signin(@user.email,'password')
|
||||
|
||||
|
||||
@ -10,12 +10,12 @@ feature 'Table show', :devise do
|
||||
click_link @table.title
|
||||
end
|
||||
|
||||
scenario 'visitor can sit at the table', js: true do
|
||||
scenario 'visitor can sit at the table' do
|
||||
click_button 'Sit', match: :first
|
||||
expect(page).to have_content "Guest"
|
||||
end
|
||||
|
||||
scenario 'visitor can join the current game', js: true do
|
||||
scenario 'visitor can join the current game' do
|
||||
click_button 'Sit', match: :first
|
||||
expect(page).to have_content "Guest"
|
||||
expect(page.text.scan('Guest').count).to eq 1
|
||||
@ -42,14 +42,14 @@ feature 'Table show', :devise do
|
||||
visit table_path @table
|
||||
end
|
||||
|
||||
scenario 'user can sit at the table', js: true do
|
||||
scenario 'user can sit at the table' do
|
||||
#TODO: Fix race condition
|
||||
expect(page).to have_content "Sit"
|
||||
click_button 'Sit', match: :first
|
||||
expect(page).to have_content @user.email
|
||||
end
|
||||
|
||||
scenario 'user can join the current game', js: true do
|
||||
scenario 'user can join the current game' do
|
||||
expect(page).to have_content "Sit"
|
||||
click_button 'Sit', match: :first
|
||||
expect(page).to have_content @user.email
|
||||
|
||||
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||
include Warden::Test::Helpers
|
||||
Warden.test_mode!
|
||||
|
||||
feature 'Join a game', type: :feature, js: true do
|
||||
feature 'Join a game', type: :feature do
|
||||
# before(:each) do
|
||||
# @game = setup_game
|
||||
# @game.reload
|
||||
|
||||
@ -2,7 +2,7 @@ require 'rails_helper'
|
||||
include Warden::Test::Helpers
|
||||
Warden.test_mode!
|
||||
|
||||
feature 'Play a hand', type: :feature, js: true do
|
||||
feature 'Play a hand', type: :feature do
|
||||
before(:each) do
|
||||
@game = setup_visitor_game
|
||||
visit table_path @game.table
|
||||
|
||||
@ -7,7 +7,7 @@ feature 'Join game', :devise do
|
||||
# Given I am not signed in
|
||||
# When I visit a joinable game
|
||||
# Then I see a join button
|
||||
scenario 'visitor can join a game', js: true do
|
||||
scenario 'visitor can join a game' do
|
||||
visit new_table_path
|
||||
fill_in 'table_title', with: 'Test Game'
|
||||
click_button 'Create Table'
|
||||
@ -16,7 +16,6 @@ feature 'Join game', :devise do
|
||||
click_button 'Sit', match: :first
|
||||
#TODO: Fix this asynchronous race condition
|
||||
visit current_path
|
||||
page.save_screenshot
|
||||
@table = Table.find(current_path.split('/').last)
|
||||
@player = @table.current_game.players.last
|
||||
@playerComponent = page.find_all(".seat").first
|
||||
|
||||
@ -7,9 +7,8 @@ feature 'Home page' do
|
||||
# Given I am a visitor
|
||||
# When I visit the home page
|
||||
# Then I see the main menu
|
||||
scenario 'visit the home page', js: true do
|
||||
scenario 'visit the home page' do
|
||||
visit root_path
|
||||
page.save_screenshot('screenshot-' + Time.now.strftime("%Y-%m-%d %H%M") + '.png')
|
||||
expect(page).to have_link 'Play Now'
|
||||
expect(page).to have_link 'Browse Tables'
|
||||
expect(page).to have_link 'Tutorial'
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
RSpec.describe Table, type: :model do
|
||||
before :all do
|
||||
@table = FactoryGirl.create(:table)
|
||||
end
|
||||
|
||||
subject { @table }
|
||||
let(:table) { FactoryGirl.create(:table) }
|
||||
|
||||
it { should respond_to :title }
|
||||
it { should respond_to :seats }
|
||||
@ -12,27 +8,27 @@ RSpec.describe Table, type: :model do
|
||||
it { should respond_to :current_game }
|
||||
|
||||
it '#title returns a string' do
|
||||
expect(@table.title).to match 'Test Table'
|
||||
expect(table.title).to match 'Test Table'
|
||||
end
|
||||
|
||||
it '#seats returns Seats collection' do
|
||||
expect(@table.seats.class.to_s).to match "Seat::ActiveRecord_Associations_CollectionProxy"
|
||||
expect(table.seats.class.to_s).to match "Seat::ActiveRecord_Associations_CollectionProxy"
|
||||
end
|
||||
|
||||
it '#users returns Users collection' do
|
||||
expect(@table.users.class.to_s).to match "User::ActiveRecord_Associations_CollectionProxy"
|
||||
expect(table.users.class.to_s).to match "User::ActiveRecord_Associations_CollectionProxy"
|
||||
end
|
||||
|
||||
it '#games returns Games collection' do
|
||||
expect(@table.games.class.to_s).to match "Game::ActiveRecord_Associations_CollectionProxy"
|
||||
expect(table.games.class.to_s).to match "Game::ActiveRecord_Associations_CollectionProxy"
|
||||
end
|
||||
|
||||
it '#current_game returns a Game' do
|
||||
expect(@table.current_game.class).to match Game
|
||||
expect(table.current_game.class).to match Game
|
||||
end
|
||||
|
||||
it "#seats returns 4 seats by default" do
|
||||
expect(@table.seats.count).to eq 4
|
||||
expect(table.seats.count).to eq 4
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -7,7 +7,7 @@ RSpec.configure do |config|
|
||||
DatabaseCleaner.strategy = :transaction
|
||||
end
|
||||
|
||||
config.before(:each, js: true) do
|
||||
config.before(:each) do
|
||||
DatabaseCleaner.strategy = :truncation
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user