Skip to content

Instantly share code, notes, and snippets.

@kellydunn
Created November 30, 2010 22:14
Show Gist options
  • Save kellydunn/722522 to your computer and use it in GitHub Desktop.
Save kellydunn/722522 to your computer and use it in GitHub Desktop.
active record validation failure upon joining game
vagrant@vagrantup:/vagrant$ bundle exec rspec spec/integration/boards/show_spec.rb
..F..
Failures:
1) Showing Boards should start the countdown to match the server timer
Failure/Error: @user.join_game!(@game)
Validation failed: User has already been taken
# ./app/models/user.rb:30:in `join_game!'
# ./spec/integration/boards/show_spec.rb:59
============================================
def join_game!(game)
self.game_board = game.game_boards.first
ugb = user_game_boards.create(:game_board => self.game_board)
ugb.started_at_epoch = ((ugb.created_at.to_f) * 1000.0).to_i
ugb.save!
self.save!
end
============================================
before :each do
@user = login_as_user
@game = Factory.create(:game)
@game.generate_boards
@board = @game.boards.first
visit_first_board(@game)
sleep 1
all_board_rows.should_not be_empty
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment