Commit 94e5e26
Changed files (6)
spec
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