main
 1require 'spec_helper'
 2
 3describe Location do
 4  let(:plateau) {Plateau.new(3,  3)}
 5
 6  context "when moving forward" do
 7    context "when the next position is to far east" do
 8      it "should move to the other side of the board" do
 9        @location.current(:x).should == 0
10        @location.current(:y).should == 0
11      end
12      before do
13        @location = Location.new(3, 0, East.new)
14        @location.forward(plateau)
15      end
16    end
17
18    context "when the next position is to far west" do
19      it "should move to the other side of the board" do
20        @location.current(:x).should == 3
21        @location.current(:y).should == 0
22      end
23      before do
24        @location = Location.new(0, 0, West.new)
25        @location.forward(plateau)
26      end
27    end
28
29    context "when the next position is to far north" do
30      it "should move to the other side of the board" do
31        @location.current(:x).should == 0
32        @location.current(:y).should == 0
33      end
34      before do
35        @location = Location.new(0, 3, North.new)
36        @location.forward(plateau)
37      end
38    end
39
40    context "when the next position is to far south" do
41      it "should move to the other side of the board" do
42        @location.current(:x).should == 0
43        @location.current(:y).should == 3
44      end
45      before do
46        @location = Location.new( 0,  0, South.new)
47        @location.forward(plateau)
48      end
49    end
50
51    context "when the next position is just fine" do
52      it "should move position forward" do
53        @location.current(:x).should == 1
54        @location.current(:y).should == 1
55      end
56      before do
57        @location = Location.new( 1,  0, North.new)
58        @location.forward(plateau)
59      end
60    end
61  end
62end