summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authormo k <mo@mokhan.ca>2012-02-12 15:23:58 -0700
committermo k <mo@mokhan.ca>2012-02-12 15:23:58 -0700
commit43cbb56b76fcb4d8a1dd18310a91f3b82b479447 (patch)
treeb1bf381d79a903b9a4b43825e97504baab3ca501 /spec
parent1cdb42b82c58fd2b2512a41d11db4285561a9b9d (diff)
add boundary checks when facing north and moving forward.
Diffstat (limited to 'spec')
-rw-r--r--spec/north_specs.rb20
-rw-r--r--spec/rover_specs.rb1
-rw-r--r--spec/ts_all.rb1
3 files changed, 22 insertions, 0 deletions
diff --git a/spec/north_specs.rb b/spec/north_specs.rb
new file mode 100644
index 0000000..aeb1308
--- /dev/null
+++ b/spec/north_specs.rb
@@ -0,0 +1,20 @@
+require 'north'
+
+describe North do
+ before(:each) do
+ @sut = North.new
+ end
+ describe "when at the edge of the terrain" do
+ describe "when moving forward" do
+ it "should just stay at the current position" do
+ @location[:y].must_equal 3
+ end
+ before do
+ terrain = fake
+ terrain.stub(:is_out_of_bounds).with({:x => 0, :y => 4}).and_return(true)
+ @location = {:x => 0, :y => 3}
+ @sut.forward(@location, terrain)
+ end
+ end
+ end
+end
diff --git a/spec/rover_specs.rb b/spec/rover_specs.rb
index 5e99495..52b45c3 100644
--- a/spec/rover_specs.rb
+++ b/spec/rover_specs.rb
@@ -28,6 +28,7 @@ describe Rover do
end
describe "when driving forward" do
before do
+ @terrain = fake
@sut.move_forward(@terrain)
end
it "should increment the y coordinate on the terrain" do
diff --git a/spec/ts_all.rb b/spec/ts_all.rb
index 9bf43ab..b783a1e 100644
--- a/spec/ts_all.rb
+++ b/spec/ts_all.rb
@@ -7,4 +7,5 @@ require "book_specs"
require "library_specs"
require "stack_specs"
require "rover_specs"
+require "north_specs"
require "specifications/find_all_books_by_author_specs"