Commit 8d13801
Changed files (2)
lib
spec
lib/south.rb
@@ -1,3 +1,11 @@
class South
-
+ def turn_right
+ West.new
+ end
+ def turn_left
+ East.new
+ end
+ def forward(location)
+ location[:y] = location[:y]-1
+ end
end
spec/south_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe South do
+ let(:sut) { South.new }
+ context "when driving forward" do
+ it "should move forward" do
+ @location[:y].should == 0
+ end
+ before do
+ @location = {:x => 0, :y => 1}
+ sut.forward(@location)
+ end
+ end
+ context "when turning left" do
+ it "should face east" do
+ sut.turn_left.should be_an_instance_of(East)
+ end
+ end
+ context "when turning right" do
+ it "should face west" do
+ sut.turn_right.should be_an_instance_of(West)
+ end
+ end
+end