spec/lang/commands/mover_cmd_spec.rb in gobstones-0.0.1.1 vs spec/lang/commands/mover_cmd_spec.rb in gobstones-0.0.2

- old
+ new

@@ -1,38 +1,36 @@ describe Mover do - let(:context) { ProgramExecutionContext.for double('GobstonesProgram') } - let(:north) { Norte.new } - let(:south) { Sur.new } + let(:context) { clean_context } - it "should run" do - Mover.new(north).evaluate(context) + it "moves the head to the specified direction when evaluating" do + Mover.new(norte).evaluate(context) expect(context.head.x_pos).to eq(0) expect(context.head.y_pos).to eq(1) end - it "should undo" do - cmd = Mover.new(north) + it "undoes the given movement" do + cmd = Mover.new norte cmd.evaluate context cmd.undo context expect(context.head.x_pos).to eq(0) expect(context.head.y_pos).to eq(0) end - it "should return opposite cmd" do - expect(Mover.new(north).opposite).to eq(Mover.new(south)) + it "returns the opposite command" do + expect(Mover.new(norte).opposite).to eq(Mover.new(sur)) end - it "should fail if types don't match" do - expect { Mover.new(Verde.new).evaluate(context) }. + it "fails if the argument is not a direction" do + expect { Mover.new(verde).evaluate(context) }. to raise_error(GobstonesTypeError, /is not a direction/) end - it "should fail when out of board" do - expect { Mover.new(south).evaluate(context) }. + it "fails when the resulting position is out of board" do + expect { Mover.new(sur).evaluate(context) }. to raise_error(OutOfBoardError) end -end \ No newline at end of file +end