Add GameHelpers
This commit is contained in:
parent
f65df4826e
commit
aca20160a0
@ -17,12 +17,7 @@ feature 'Play a hand', type: :feature do
|
|||||||
# expect successful play message
|
# expect successful play message
|
||||||
|
|
||||||
# TODO: extract game setup to a factory
|
# TODO: extract game setup to a factory
|
||||||
game = FactoryGirl.create :game
|
game = setup_game
|
||||||
user1 = FactoryGirl.create :user
|
|
||||||
user2 = FactoryGirl.create :user
|
|
||||||
game.add_player_from_user user1
|
|
||||||
game.add_player_from_user user2
|
|
||||||
game.start
|
|
||||||
login_as(game.current_player.user, scope: :user)
|
login_as(game.current_player.user, scope: :user)
|
||||||
visit game_path game
|
visit game_path game
|
||||||
# Click the lowest card checkbox
|
# Click the lowest card checkbox
|
||||||
@ -35,12 +30,7 @@ feature 'Play a hand', type: :feature do
|
|||||||
scenario 'first play does not contain lowest card' do
|
scenario 'first play does not contain lowest card' do
|
||||||
# current_player plays hand not containing lowest card
|
# current_player plays hand not containing lowest card
|
||||||
# expect unsuccessful play message hand MUST contain lowest card
|
# expect unsuccessful play message hand MUST contain lowest card
|
||||||
game = FactoryGirl.create :game
|
game = setup_game
|
||||||
user1 = FactoryGirl.create :user
|
|
||||||
user2 = FactoryGirl.create :user
|
|
||||||
game.add_player_from_user user1
|
|
||||||
game.add_player_from_user user2
|
|
||||||
game.start
|
|
||||||
login_as(game.current_player.user, scope: :user)
|
login_as(game.current_player.user, scope: :user)
|
||||||
visit game_path game
|
visit game_path game
|
||||||
# Click the lowest card checkbox
|
# Click the lowest card checkbox
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
require 'support/helpers/session_helpers'
|
require 'support/helpers/session_helpers'
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.include Features::SessionHelpers, type: :feature
|
config.include Features::SessionHelpers, type: :feature
|
||||||
|
config.include Features::GameHelpers, type: :feature
|
||||||
end
|
end
|
||||||
|
|||||||
18
spec/support/helpers/game_helpers.rb
Normal file
18
spec/support/helpers/game_helpers.rb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
module Features
|
||||||
|
module GameHelpers
|
||||||
|
def setup_game
|
||||||
|
# Default game has 4 players
|
||||||
|
game = FactoryGirl.create :game
|
||||||
|
user1 = FactoryGirl.create :user
|
||||||
|
user2 = FactoryGirl.create :user
|
||||||
|
user3 = FactoryGirl.create :user
|
||||||
|
user4 = FactoryGirl.create :user
|
||||||
|
game.add_player_from_user user1
|
||||||
|
game.add_player_from_user user2
|
||||||
|
game.add_player_from_user user3
|
||||||
|
game.add_player_from_user user4
|
||||||
|
game.start
|
||||||
|
return game
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user