44 lines
1023 B
Ruby
44 lines
1023 B
Ruby
require 'rails_helper'
|
|
|
|
RSpec.feature "EndOfGames", type: :feature, js: true do
|
|
# Given I am in a started game
|
|
before do
|
|
@game = setup_game
|
|
@game.reload
|
|
@player = @game.controlling_player
|
|
signin(@player.user.email,'password')
|
|
visit table_path @game.table
|
|
end
|
|
# And it is my turn
|
|
# And I play my last cards
|
|
# Then I win the game
|
|
scenario 'I win the game' do
|
|
|
|
# Play lowest card
|
|
# Other players always pass
|
|
# Play next lowest card
|
|
# Repeat until out of cards
|
|
@player.inventory.each do |card|
|
|
find_card(card).click
|
|
click_button "Play Hand"
|
|
sleep 1
|
|
visit current_url
|
|
@game.reload
|
|
@game.controlling_player_id = @player.id
|
|
@game.save
|
|
@game.reload
|
|
sleep 1
|
|
visit current_url
|
|
end
|
|
|
|
# Play my last card(s)
|
|
# Expect that I am the winner
|
|
expect(@game.winner).to eq @player
|
|
end
|
|
|
|
describe 'I lose the game' do
|
|
# Another player plays their last card(s)
|
|
# Expect that they are the winner
|
|
end
|
|
end
|