Fix game tests

This commit is contained in:
Jesse C. Fisher 2021-07-16 23:24:42 -07:00
parent 196174401e
commit 69ce3f6b4c

View File

@ -2,7 +2,8 @@ require 'rails_helper'
RSpec.describe Game, type: :model do
before(:each) do
@game = FactoryGirl.create(:game)
@table = FactoryGirl.create :table
@game = @table.current_game
@user1 = FactoryGirl.create(:user)
@user2 = FactoryGirl.create(:user)
end
@ -13,10 +14,6 @@ RSpec.describe Game, type: :model do
it { should respond_to(:play_to_beat) }
it { should respond_to(:winner) }
it '#title returns a string' do
expect(@game.title).to match 'Test Game'
end
it 'has a winner' do
# Start the game
@player1 = @user1.sit_in(@game.seats.first)
@ -29,6 +26,7 @@ RSpec.describe Game, type: :model do
@player.play_hand [card]
@game.reload
while (@game.controlling_player != @player) do
break if @game.over?
@game.controlling_player.pass
@game.reload
end
@ -67,7 +65,6 @@ RSpec.describe Game, type: :model do
@game.players.new(user_id: User.last.id)
expect { @game.validate_startable }.to raise_error StandardError
expect(@game.startable?).to eq(false)
binding.pry
expect(@game.errors[:players])
.to include 'Must be less than 5 players.'
end