Files
space_game_server/core/spec/player_spec.rb
T

52 lines
1.2 KiB
Ruby

# 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