working on reimplimenting server

This commit is contained in:
2025-12-19 19:23:54 -07:00
parent 4737531805
commit 057164122a
20 changed files with 1145 additions and 6 deletions
+51
View File
@@ -0,0 +1,51 @@
# Nathan Hinton 19 Dec 2025
# Test file for the player class.
require 'securerandom'
require './player'
RSpec.describe Player do
# Set the testing id
let(:id) { 'cfeab1a60864fd529cb9ce993e9c3af4' }
before(:each) do
# Make sure that we get the same ID every time.
allow(SecureRandom).to receive(:hex).and_return(id)
end
describe '#initialize' do
it 'initializes with name' do
expect(Player.new(name: 'Nathan').name).to eq 'Nathan'
end
end
describe '#get_id' do
it 'returns the id' do
player = Player.new()
expect(player.instance_variable_get(:@id_retrieved)).to be false
expect(player.get_id).to eq id
expect(player.instance_variable_get(:@id_retrieved)).to be true
end
it 'prints a warning when the id is gotten more than once' do
player = Player.new()
player.get_id
expect(player.instance_variable_get(:@id_retrieved)).to be true
expect(player.get_id).to eq id
expect(player.instance_variable_get(:@id_retrieved)).to be true
end
end
describe '#planets' do
end
describe '#fleets', pending: 'Ships not yet implimented' do
end
describe '#tech', pending: 'Tech not yet implimented' do
end
end