79 lines
2.3 KiB
Ruby
79 lines
2.3 KiB
Ruby
# Feature: Table show
|
|
# As a visitor
|
|
# I want to view a table
|
|
# So I can sit and play a game
|
|
feature 'Table show', :devise do
|
|
context "As a visitor" do
|
|
before(:each) do
|
|
@table = FactoryGirl.create :table
|
|
visit tables_path
|
|
click_link @table.title
|
|
end
|
|
|
|
scenario 'visitor can sit at the table', js: true do
|
|
click_button 'Sit', match: :first
|
|
expect(page).to have_content "Guest"
|
|
end
|
|
|
|
scenario 'visitor can join the current game', js: true do
|
|
click_button 'Sit', match: :first
|
|
#TODO: Fix race condition. Trigger game react component reload when player joins a table
|
|
sleep 4
|
|
expect(page).to have_content "Guest"
|
|
expect(page.text.scan('Guest').count).to eq 2
|
|
end
|
|
|
|
scenario 'visitor can leave the current game', js: true do
|
|
click_button 'Sit', match: :first
|
|
#TODO: Fix race condition
|
|
sleep 4
|
|
expect(page.text.scan('Guest').count).to eq 2
|
|
click_button 'Stand', match: :first
|
|
expect(page).to have_content "Sit"
|
|
#TODO: Fix race condition
|
|
sleep 4
|
|
expect(page.text.scan('Guest').count).to eq 0
|
|
end
|
|
|
|
end
|
|
|
|
context "As a user" do
|
|
before(:each) do
|
|
@table = FactoryGirl.create :table
|
|
@user = FactoryGirl.create :user
|
|
signin(@user.email, @user.password)
|
|
visit table_path @table
|
|
end
|
|
|
|
scenario 'user can sit at the table', js: true 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
|
|
expect(page).to have_content "Sit"
|
|
click_button 'Sit', match: :first
|
|
#TODO: Fix race condition. Trigger game react component reload when player joins a table
|
|
sleep 4
|
|
expect(page).to have_content @user.email
|
|
expect(page.text.scan(@user.email).count).to eq 2
|
|
end
|
|
|
|
scenario 'user can leave the current game', js: true do
|
|
expect(page).to have_content "Sit"
|
|
click_button 'Sit', match: :first
|
|
#TODO: Fix race condition
|
|
sleep 4
|
|
expect(page.text.scan(@user.email).count).to eq 2
|
|
click_button 'Stand', match: :first
|
|
expect(page).to have_content "Sit"
|
|
#TODO: Fix race condition
|
|
sleep 4
|
|
expect(page.text.scan(@user.email).count).to eq 0
|
|
end
|
|
|
|
end
|
|
end
|