<commit_before>require_relative '../../../lib/maze/server/maze_server'
require_relative '../../../lib/maze/server/version'
require_relative '../../../lib/maze/game/maze_game'
require 'socket'

describe MazeServer do

  it 'maze server has a version' do
    Maze::Server::VERSION.should_not be_empty
  end

  it 'get player name if they are connected' do
    response = double('response', :chop => '{"playerName" : "player"}')
    socket = double('socket', :gets => response, :puts => nil)
    server = double('server', :accept => socket)
    TCPServer.stub(:open).with(9999).and_return(server)
    server = MazeServer.new(1)
    server.start
    server.players[1].name.should == 'player'
  end

  context 'server runs' do
    before do
      response = double('response', :chop => '{"playerName" : "player"}')
      socket = double('socket', :gets => response, :puts => nil)
      server = double('server', :accept => socket)
      TCPServer.stub(:open).with(9999).and_return(server)
      @server = MazeServer.new(1)
      @server.start
    end

    it 'handle a game' do
      MazeGame.any_instance.stub(:reached_player_exit?).and_return(false, true)
      response = double('response', :chop => '{"move" : "left"}')
      socket = double('socket', :gets => response, :puts => nil)
      Client.any_instance.stub(:socket).and_return(socket)
      @server.start_game
    end
  end

end<commit_msg>fix tests<commit_after>require_relative '../../../lib/maze/server/maze_server'
require_relative '../../../lib/maze/server/version'
require_relative '../../../lib/maze/game/maze_game'
require 'socket'

describe MazeServer do

  it 'maze server has a version' do
    Maze::Server::VERSION.should_not be_empty
  end

  it 'get player name if they are connected' do
    response = double('response', :chop => '{"playerName" : "player"}')
    socket = double('socket', :gets => response, :puts => nil)
    server = double('server', :accept => socket)
    TCPServer.stub(:open).with(1, 9999).and_return(server)
    server = MazeServer.new(1)
    server.start
    server.players[1].name.should == 'player'
  end

  context 'server runs' do
    before do
      response = double('response', :chop => '{"playerName" : "player"}')
      socket = double('socket', :gets => response, :puts => nil)
      server = double('server', :accept => socket)
      TCPServer.stub(:open).with(1, 9999).and_return(server)
      @server = MazeServer.new(1)
      @server.start
    end

    it 'handle a game' do
      MazeGame.any_instance.stub(:reached_player_exit?).and_return(false, true)
      response = double('response', :chop => '{"move" : "left"}')
      socket = double('socket', :gets => response, :puts => nil)
      Client.any_instance.stub(:socket).and_return(socket)
      @server.start_game
    end
  end

end
{'fraction_non_alphanumeric': 0.16654753395282346, 'fraction_numerical': 0.008577555396711936, 'mean_word_length': 3.4287974683544302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2215922', 'n_tokens_mistral': 912, 'n_tokens_neox': 905, 'n_words': 204}