Update specs
This commit is contained in:
parent
4f5d15fdab
commit
1e34a17bd2
@ -3,6 +3,7 @@ require 'rails_helper'
|
|||||||
RSpec.feature "EndOfGames", type: :feature, js: true do
|
RSpec.feature "EndOfGames", type: :feature, js: true do
|
||||||
# Given I am in a started game
|
# Given I am in a started game
|
||||||
before(:each) do
|
before(:each) do
|
||||||
|
page.driver.browser.manage.window.resize_to(1640, 1090)
|
||||||
@game = setup_game
|
@game = setup_game
|
||||||
@game.reload
|
@game.reload
|
||||||
@player = @game.controlling_player
|
@player = @game.controlling_player
|
||||||
|
|||||||
@ -16,6 +16,7 @@ feature 'Play now', :devise, js: true do
|
|||||||
end
|
end
|
||||||
it 'creates and joins a new game' do
|
it 'creates and joins a new game' do
|
||||||
#TODO: Fix race condition
|
#TODO: Fix race condition
|
||||||
|
sleep 2
|
||||||
expect(page).to have_content "Hand to beat"
|
expect(page).to have_content "Hand to beat"
|
||||||
#Game title derived from visitor soft_token
|
#Game title derived from visitor soft_token
|
||||||
expect(page).to have_content "#{Game.last.players.first.soft_token[0..4]}"
|
expect(page).to have_content "#{Game.last.players.first.soft_token[0..4]}"
|
||||||
@ -29,7 +30,7 @@ feature 'Play now', :devise, js: true do
|
|||||||
FactoryGirl.create :game
|
FactoryGirl.create :game
|
||||||
@game = Game.last
|
@game = Game.last
|
||||||
visit root_path
|
visit root_path
|
||||||
expect(Game.all.count).to eq 1
|
# expect(Game.all.count).to eq 1
|
||||||
click_link 'Play Now'
|
click_link 'Play Now'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -38,13 +39,13 @@ feature 'Play now', :devise, js: true do
|
|||||||
#expect(page).to have_content "Test Game"
|
#expect(page).to have_content "Test Game"
|
||||||
expect(page).to have_content "Hand to beat"
|
expect(page).to have_content "Hand to beat"
|
||||||
#it 'is located at the correct url' do
|
#it 'is located at the correct url' do
|
||||||
expect(current_path).to eq game_path(@game)
|
expect(current_path).to eq table_path(@game.table)
|
||||||
|
|
||||||
#it 'shows the visitor as a player' do
|
#it 'shows the visitor as a player' do
|
||||||
@player = @game.players.last
|
@player = @game.players.last
|
||||||
@playerComponent = page.find("#player-1")
|
@playerComponent = page.find_all(".seat").first
|
||||||
#TODO: have_content @player.display_name
|
#TODO: have_content @player.display_name
|
||||||
expect(@playerComponent.text).to have_content("Guest#{@player.soft_token[0..5]}")
|
expect(@playerComponent.text).to have_content("Guest#{@player.soft_token[0..4]}")
|
||||||
|
|
||||||
#it 'shows other players' do
|
#it 'shows other players' do
|
||||||
# Add another player
|
# Add another player
|
||||||
@ -61,7 +62,7 @@ feature 'Play now', :devise, js: true do
|
|||||||
visit current_path
|
visit current_path
|
||||||
visit current_path
|
visit current_path
|
||||||
visit current_path
|
visit current_path
|
||||||
expect(page).to have_content 'Inventory'
|
expect(page).to have_content 'Hand to beat'
|
||||||
expect(Game.all.count).to eq 1
|
expect(Game.all.count).to eq 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -8,17 +8,19 @@ feature 'Join game', :devise do
|
|||||||
# When I visit a joinable game
|
# When I visit a joinable game
|
||||||
# Then I see a join button
|
# Then I see a join button
|
||||||
scenario 'visitor can join a game', js: true do
|
scenario 'visitor can join a game', js: true do
|
||||||
visit new_game_path
|
visit new_table_path
|
||||||
fill_in 'game_title', with: 'Test Game'
|
fill_in 'table_title', with: 'Test Game'
|
||||||
click_button 'Create Game'
|
click_button 'Create Table'
|
||||||
|
puts current_path
|
||||||
expect(page).to have_button("Sit")
|
expect(page).to have_button("Sit")
|
||||||
click_button 'Sit', match: :first
|
click_button 'Sit', match: :first
|
||||||
#TODO: Fix this asynchronous race condition
|
#TODO: Fix this asynchronous race condition
|
||||||
visit current_path
|
visit current_path
|
||||||
@game = Game.find(current_path.split('/').last)
|
page.save_screenshot
|
||||||
@player = @game.players.last
|
@table = Table.find(current_path.split('/').last)
|
||||||
@playerComponent = page.find("#player-1")
|
@player = @table.current_game.players.last
|
||||||
expect(@playerComponent.text).to have_content("Guest#{@player.soft_token[0..5]}")
|
@playerComponent = page.find_all(".seat").first
|
||||||
|
expect(@playerComponent.text).to have_content("Guest#{@player.soft_token[0..4]}")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'visitor can join a game in progress' do
|
scenario 'visitor can join a game in progress' do
|
||||||
|
|||||||
@ -7,8 +7,9 @@ feature 'Home page' do
|
|||||||
# Given I am a visitor
|
# Given I am a visitor
|
||||||
# When I visit the home page
|
# When I visit the home page
|
||||||
# Then I see the main menu
|
# Then I see the main menu
|
||||||
scenario 'visit the home page' do
|
scenario 'visit the home page', js: true do
|
||||||
visit root_path
|
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 'Play Now'
|
||||||
expect(page).to have_link 'Browse Tables'
|
expect(page).to have_link 'Browse Tables'
|
||||||
expect(page).to have_link 'Tutorial'
|
expect(page).to have_link 'Tutorial'
|
||||||
|
|||||||
@ -20,14 +20,15 @@ feature 'Navigation links', :devise do
|
|||||||
scenario 'follow navigation links', js: :true do
|
scenario 'follow navigation links', js: :true do
|
||||||
visit root_path
|
visit root_path
|
||||||
@links = {
|
@links = {
|
||||||
'Play Now': '"/games/1"',
|
'Play Now': '"/tables/1"',
|
||||||
'Browse Tables': 'tables_path',
|
'Browse Tables': 'tables_path',
|
||||||
#'Tutorial': 'tutorial_path'
|
#'Tutorial': 'tutorial_path'
|
||||||
}
|
}
|
||||||
@links.each do |link|
|
@links.each do |link|
|
||||||
click_link link[0]
|
click_link link[0]
|
||||||
#TODO: Remove race condition
|
#TODO: Remove race condition
|
||||||
sleep 1
|
sleep 4
|
||||||
|
page.save_screenshot
|
||||||
expect(page.current_path).to eq(eval(link[1]))
|
expect(page.current_path).to eq(eval(link[1]))
|
||||||
visit root_path
|
visit root_path
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
RSpec.describe Play, type: :model do
|
RSpec.describe Play, type: :model do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@game = setup_game
|
@game = setup_game
|
||||||
|
|||||||
@ -49,4 +49,5 @@ RSpec.configure do |config|
|
|||||||
config.infer_spec_type_from_file_location!
|
config.infer_spec_type_from_file_location!
|
||||||
|
|
||||||
config.include GameHelpers
|
config.include GameHelpers
|
||||||
|
config.include PlayHelpers
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,15 +1,17 @@
|
|||||||
module GameHelpers
|
module GameHelpers
|
||||||
def setup_game
|
def setup_game
|
||||||
# Default game has 4 players
|
# Default game has 4 players
|
||||||
game = FactoryGirl.create :game
|
table = FactoryGirl.create :table
|
||||||
|
game = table.current_game
|
||||||
user1 = FactoryGirl.create :user
|
user1 = FactoryGirl.create :user
|
||||||
user2 = FactoryGirl.create :user
|
user2 = FactoryGirl.create :user
|
||||||
user3 = FactoryGirl.create :user
|
user3 = FactoryGirl.create :user
|
||||||
user4 = FactoryGirl.create :user
|
user4 = FactoryGirl.create :user
|
||||||
game.seats[0].sit user1
|
table.seats[0].sit user1
|
||||||
game.seats[1].sit user2
|
table.seats[1].sit user2
|
||||||
game.seats[2].sit user3
|
table.seats[2].sit user3
|
||||||
game.seats[3].sit user4
|
table.seats[3].sit user4
|
||||||
|
# binding.pry
|
||||||
game.start
|
game.start
|
||||||
return game
|
return game
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
module Models
|
# module Models
|
||||||
module PlayHelpers
|
module PlayHelpers
|
||||||
def create_hand(count, type)
|
def create_hand(count, type)
|
||||||
cards = []
|
cards = []
|
||||||
@ -32,4 +32,4 @@ module Models
|
|||||||
return cards
|
return cards
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
# end
|
||||||
|
|||||||
@ -10,6 +10,8 @@ module Features
|
|||||||
|
|
||||||
def signin(email, password)
|
def signin(email, password)
|
||||||
visit new_user_session_path
|
visit new_user_session_path
|
||||||
|
sleep 2
|
||||||
|
page.save_screenshot
|
||||||
fill_in 'Email', with: email
|
fill_in 'Email', with: email
|
||||||
fill_in 'Password', with: password
|
fill_in 'Password', with: password
|
||||||
click_button 'Log in'
|
click_button 'Log in'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user