Fixed tests. Need to check for damage from AI code
This commit is contained in:
+14
-4
@@ -36,8 +36,12 @@ require 'json'
|
||||
HOSTNAME = 'localhost'
|
||||
PORT = 2000
|
||||
|
||||
server_pid = spawn('rake serve', out: File::NULL, err: File::NULL)
|
||||
sleep(0.5)
|
||||
|
||||
RSpec.describe "app.rb" do
|
||||
let(:client) {TCPSocket.open(HOSTNAME, PORT)}
|
||||
|
||||
it 'responds with an error when a non JSON request is sent' do
|
||||
client.puts 'this is non json test data'
|
||||
expect(JSON.parse(client.gets)).to eq({'type' => 'error', 'domain' => 'error', 'payload' => 'Server unable to decode JSON'})
|
||||
@@ -46,10 +50,6 @@ RSpec.describe "app.rb" do
|
||||
describe 'type: hello' do
|
||||
describe 'domain: player' do
|
||||
describe 'payload: player_id, faction' do
|
||||
it 'Connects the player:' do
|
||||
client.puts({'type' => 'hello', 'domain' => 'player', 'payload' => {'player_id' => 'test_player', 'faction' => 'good'}}.to_json)
|
||||
expect(JSON.parse(client.gets)).to eq('')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -73,5 +73,15 @@ RSpec.describe "app.rb" do
|
||||
end
|
||||
|
||||
describe 'type: error' do
|
||||
it 'returns an error when a player does not exist' do
|
||||
client.puts({'type' => 'hello', 'domain' => 'player', 'payload' => {'player_id' => 'test_esfe_player', 'faction' => 'good'}}.to_json)
|
||||
expect(JSON.parse(client.gets)).to eq({"payload" => "Player not registered!",
|
||||
"request_id" => -1,
|
||||
"type" => "error",}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Process.kill('TERM', server_pid)
|
||||
Process.wait(server_pid)
|
||||
|
||||
Reference in New Issue
Block a user