Commit 8d13801

mo k <mo@mokhan.ca>
2012-08-10 03:08:15
create south heading.
1 parent 7aba0b9
Changed files (2)
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