Commit 94e5e26

mo k <mo@mokhan.ca>
2012-08-11 05:14:08
implement to_s on each heading.
1 parent 08cb61b
lib/east.rb
@@ -8,4 +8,7 @@ class East
   def forward(location)
     location[:x] = location[:x]+1
   end
+  def to_s
+    'E'
+  end
 end
lib/south.rb
@@ -8,4 +8,7 @@ class South
   def forward(location)
     location[:y] = location[:y]-1
   end
+  def to_s
+    'S'
+  end
 end
lib/west.rb
@@ -8,4 +8,7 @@ class West
   def forward(current_location)
     current_location[:x] = current_location[:x]-1
   end
+  def to_s
+    'W'
+  end
 end
spec/unit/east_spec.rb
@@ -22,4 +22,9 @@ describe East do
       sut.turn_left.should be_an_instance_of(North)
     end
   end
+  context "when displayed" do
+    it "should display 'E'" do
+      sut.to_s.should == 'E'
+    end
+  end
 end
spec/unit/south_spec.rb
@@ -21,4 +21,9 @@ describe South do
       sut.turn_right.should be_an_instance_of(West)
     end
   end
+  context "when displayed" do
+    it "should display 'S'" do
+      sut.to_s.should == 'S'
+    end
+  end
 end
spec/unit/west_spec.rb
@@ -22,4 +22,9 @@ describe West do
       sut.turn_left.should be_an_instance_of(South)
     end
   end
+  context "when displayed" do
+    it "should display 'W'" do
+      sut.to_s.should == 'W'
+    end
+  end
 end