Created
March 27, 2009 14:27
-
-
Save kevinrutherford/86715 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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