# Feature: Bot takes turns
#   As a player
#   I want bots to take turns
#   So I can play against the computer
feature 'Bot takes turn', type: :feature do
    before(:each) do
      @table = FactoryGirl.create :table
      @game = @table.current_game
      visit table_path @table
    end

  scenario 'bot player passes' do
    @button = page.find_button('+ Bot', match: :first).click
    expect(page).to have_content "BotPlayer"
    @button = page.find_button('Sit', match: :first).click
    click_button "Start"
    click_button 'Pass'
    expect(page).to have_content "Bot is passes"
  end

  scenario 'bot player plays single' do
    @button = page.find_button('+ Bot', match: :first).click
    expect(page).to have_content "BotPlayer"
    @button = page.find_button('Sit', match: :first).click
    click_button "Start"
    @game = @table.current_game
    if @game.controlling_player.soft_token == page.current_user.soft_token
      @card_to_play = @game.controlling_player.inventory.first
      find("[data-card-name='#{@card_to_play.to_s}']").click
      click_button 'Play Hand'
    end
    expect(@game.play_to_beat.player.is_bot?).to eq true
    expect(@game.play_to_beat.hand_type).to eq "single"
  end
end
