Skip to content

Commit

Permalink
Corrected some tests and the implementation to allow us
Browse files Browse the repository at this point in the history
to only operate in the positive quadrant.
  • Loading branch information
hemalvarambhia committed Oct 25, 2023
1 parent fcfddcb commit 730d94e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/map.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Map
attr_reader :left_hand_edge, :right_hand_edge

def initialize(left_hand_edge: -10, right_hand_edge: 10)
def initialize(left_hand_edge: 0, right_hand_edge: 10)
@right_hand_edge = right_hand_edge
@left_hand_edge = left_hand_edge
end
Expand Down
14 changes: 7 additions & 7 deletions spec/operating_mars_rover_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

mars_rover.execute(['f'])

left_hand_edge = Coordinates.new(x: -10, y: 0)
left_hand_edge = Coordinates.new(x: 0, y: 0)
expect(mars_rover).to be_located_at(left_hand_edge)
end

Expand All @@ -135,21 +135,21 @@

mars_rover.execute(['f'])

left_hand_edge = Coordinates.new(x: -10, y: 5)
left_hand_edge = Coordinates.new(x: 0, y: 5)
expect(mars_rover).to be_located_at(left_hand_edge)
end

it 'can move to the left-hand edge of the planet' do
mars_rover = MarsRover.new(map: Map.new, starting_position: Coordinates.new(x: -9, y: 5), direction: 'W')
mars_rover = MarsRover.new(map: Map.new, starting_position: Coordinates.new(x: 1, y: 5), direction: 'W')

mars_rover.execute(['f'])

left_hand_edge = Coordinates.new(x: -10, y: 5)
left_hand_edge = Coordinates.new(x: 0, y: 5)
expect(mars_rover).to be_located_at(left_hand_edge)
end

it 'can move from the left-hand edge of the planet and reappear at the right-hand edge' do
mars_rover = MarsRover.new(map: Map.new, starting_position: Coordinates.new(x: -10, y: 0), direction: 'W')
mars_rover = MarsRover.new(map: Map.new, starting_position: Coordinates.new(x: 0, y: 0), direction: 'W')

mars_rover.execute(['f'])

Expand All @@ -158,11 +158,11 @@
end

it 'can move from the left-hand edge of the planet from anywhere on that edge and reappear on the right hand edge' do
mars_rover = MarsRover.new(map: Map.new, starting_position: Coordinates.new(x: -10, y: -1), direction: 'W')
mars_rover = MarsRover.new(map: Map.new, starting_position: Coordinates.new(x: 0, y: 1), direction: 'W')

mars_rover.execute(['f'])

right_hand_edge = Coordinates.new(x: 10, y: -1)
right_hand_edge = Coordinates.new(x: 10, y: 1)
expect(mars_rover).to be_located_at(right_hand_edge)
end

Expand Down

0 comments on commit 730d94e

Please sign in to comment.