Fix game tests
This commit is contained in:
parent
196174401e
commit
69ce3f6b4c
@ -2,7 +2,8 @@ require 'rails_helper'
|
|||||||
|
|
||||||
RSpec.describe Game, type: :model do
|
RSpec.describe Game, type: :model do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@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)
|
||||||
end
|
end
|
||||||
@ -13,10 +14,6 @@ RSpec.describe Game, type: :model do
|
|||||||
it { should respond_to(:play_to_beat) }
|
it { should respond_to(:play_to_beat) }
|
||||||
it { should respond_to(:winner) }
|
it { should respond_to(:winner) }
|
||||||
|
|
||||||
it '#title returns a string' do
|
|
||||||
expect(@game.title).to match 'Test Game'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has a winner' do
|
it 'has a winner' do
|
||||||
# Start the game
|
# Start the game
|
||||||
@player1 = @user1.sit_in(@game.seats.first)
|
@player1 = @user1.sit_in(@game.seats.first)
|
||||||
@ -29,6 +26,7 @@ RSpec.describe Game, type: :model do
|
|||||||
@player.play_hand [card]
|
@player.play_hand [card]
|
||||||
@game.reload
|
@game.reload
|
||||||
while (@game.controlling_player != @player) do
|
while (@game.controlling_player != @player) do
|
||||||
|
break if @game.over?
|
||||||
@game.controlling_player.pass
|
@game.controlling_player.pass
|
||||||
@game.reload
|
@game.reload
|
||||||
end
|
end
|
||||||
@ -67,7 +65,6 @@ RSpec.describe Game, type: :model do
|
|||||||
@game.players.new(user_id: User.last.id)
|
@game.players.new(user_id: User.last.id)
|
||||||
expect { @game.validate_startable }.to raise_error StandardError
|
expect { @game.validate_startable }.to raise_error StandardError
|
||||||
expect(@game.startable?).to eq(false)
|
expect(@game.startable?).to eq(false)
|
||||||
binding.pry
|
|
||||||
expect(@game.errors[:players])
|
expect(@game.errors[:players])
|
||||||
.to include 'Must be less than 5 players.'
|
.to include 'Must be less than 5 players.'
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user