require 'rspec'
require 'space'
describe Space do
it 'should be an instance of Space' do
test_space = Space.new(2,3)
test_space.should be_an_instance_of Space
end
it 'should initialize with coordinates and "false" for dead state' do
test_space = Space.new(2,3)
test_space.x.should eq 2
test_space.y.should eq 3
test_space.state.should eq false
end
describe '.all' do
it 'starts empty' do
Space.all.should eq []
end
it 'is filled with all spaces' do
test_board = Board.new(10,10)
test_space1 = Space.create(0,0)
test_space2 = Space.create(1,0)
Space.all.should eq [test_space1, test_space2]
end
end
describe '.create' do
it 'creates a space object and pushes into all_spaces array' do
test_space = Space.create(0,0)
Space.all.should eq [test_space]
end
end
end
require 'rspec'
require 'space'
describe Space do
it 'should be an instance of Space' do
test_space = Space.new(2,3)
test_space.should be_an_instance_of Space
end
it 'should initialize with coordinates and "false" for dead state' do
test_space = Space.new(2,3)
test_space.x.should eq 2
test_space.y.should eq 3
test_space.state.should eq false
end
describe '.all' do
it 'starts empty' do
Space.all.should eq []
end
it 'is filled with all spaces' do
test_board = Board.new(10,10)
test_space1 = Space.create(0,0)
test_space2 = Space.create(1,0)
Space.all.should eq [test_space1, test_space2]
end
end
describe '.create' do
it 'creates a space object and pushes into all_spaces array' do
test_space = Space.create(0,0)
Space.all.should eq [test_space]
end
end
end
require 'rspec'
require 'board'
describe Board do
it 'initializes a board instance' do
test_board = Board.new(10, 10)
test_board.should be_an_instance_of Board
end
it 'initializes with correct number of spaces' do
test_board = Board.new(10, 10)
test_board.height.should eq 10
test_board.width.should eq 10
test_board.number_spaces.should eq 100
end
# describe '.create' do
# it 'creates a board object and fills it with space objects' do
# test_board = Board.create(10, 10)
# test_space = Space.new(2,3,false)
# test_board
# end
# end
end
class Board
def initialize(height, width)
@height = height
@width = width
@number_spaces = height * width
end
def height
@height
end
def width
@width
end
def number_spaces
@number_spaces
end
end