summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authormo k <mo@mokhan.ca>2012-02-12 14:19:44 -0700
committermo k <mo@mokhan.ca>2012-02-12 14:19:44 -0700
commitccbc65bd01a9c460539e936cfbc5eba8f97c0104 (patch)
tree1860e1a57878d4d525388a06d65a1f4e79913964 /spec
parenta1a0e9e7d63aa013fdfc54e87ce05ba776cd4135 (diff)
move forward when facing east or west.
Diffstat (limited to 'spec')
-rw-r--r--spec/rover_specs.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/rover_specs.rb b/spec/rover_specs.rb
index c8e5ec8..a54e2c2 100644
--- a/spec/rover_specs.rb
+++ b/spec/rover_specs.rb
@@ -73,11 +73,19 @@ describe Rover do
@sut.heading.must_equal :north
end
end
+ describe "when driving forward" do
+ before do
+ @sut.move_forward(@terrain)
+ end
+ it "should increment the x coordinate on the terrain" do
+ @sut.location.must_equal({:x => 1, :y => 0})
+ end
+ end
end
describe "when facing west" do
before do
- @sut = create_sut :west
+ @sut = create_sut :west, 1, 0
end
describe "when turning right" do
it "should face north" do
@@ -91,6 +99,14 @@ describe Rover do
@sut.heading.must_equal :south
end
end
+ describe "when driving forward" do
+ before do
+ @sut.move_forward(@terrain)
+ end
+ it "should decrement the x coordinate on the terrain" do
+ @sut.location.must_equal({:x => 0, :y => 0})
+ end
+ end
end
end