Skip to content

Instantly share code, notes, and snippets.

@kevinrutherford
Created March 27, 2009 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinrutherford/86715 to your computer and use it in GitHub Desktop.
Save kevinrutherford/86715 to your computer and use it in GitHub Desktop.
require 'machine'
require 'robot'
describe Robot do
before :each do
@robot = Robot.new
end
describe 'when new' do
it 'should have no location yet' do
@robot.location.should be_nil
end
it 'should not point at a bin yet' do
@robot.bin.should be_nil
end
end
describe 'moving among machines' do
before :each do
@sorter = Machine.new("Sorter", "left")
@oven = Machine.new("Oven", "middle")
end
it 'should report correct location' do
@robot.move_to(@oven)
@robot.location.should == @oven
end
describe 'picking' do
before :each do
@sorter.put("chips")
@robot.move_to(@sorter)
@robot.pick
end
it 'should have the correct bin' do
@robot.bin.should == "chips"
end
it 'should have taken the bin away from the machine' do
@sorter.bin.should be_nil
end
describe 'releasing' do
before :each do
@robot.move_to(@oven)
@robot.release
end
it 'should have no bin' do
@robot.bin.should be_nil
end
it 'should have deposited the bin at the oven' do
@oven.bin.should == "chips"
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment