Finished testing and docs for now. Time for new features!
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../ship' # <-- adjust to the actual path of ship.rb
|
||||
require './ship'
|
||||
|
||||
require './player'
|
||||
|
||||
RSpec.describe Ship do
|
||||
let(:ship) { Ship.new(0, 0) }
|
||||
let(:ship) { Ship.new(0, 0, Player.new('test player 01')) }
|
||||
|
||||
describe '#initialize' do
|
||||
it 'stores the given position' do
|
||||
expect(ship.instance_variable_get(:@position)).to eq([0, 0])
|
||||
expect(ship.instance_variable_get(:@position)).to eq [0, 0]
|
||||
end
|
||||
|
||||
it 'sets the speed to 0.1' do
|
||||
expect(ship.instance_variable_get(:@speed)).to eq(0.1)
|
||||
expect(ship.instance_variable_get(:@speed)).to eq 0.1
|
||||
end
|
||||
|
||||
it 'does not set @moving until a direction is chosen' do
|
||||
@@ -70,7 +72,7 @@ RSpec.describe Ship do
|
||||
}
|
||||
mapping.each do |dir, expected|
|
||||
expect { ship.move_direction(dir) }.not_to raise_error
|
||||
expect(ship.instance_variable_get(:@moving)).to eq(expected)
|
||||
expect(ship.instance_variable_get(:@moving)).to eq expected
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user