From e5f9e9afaa6d4920eefedc63e0983289848c0985 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Tue, 31 Oct 2023 19:25:24 +0000 Subject: [PATCH] Refactor: pushed a detail up towards the test. --- spec/moving_forwards_spec.rb | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/spec/moving_forwards_spec.rb b/spec/moving_forwards_spec.rb index 0046e78..73f2e3a 100644 --- a/spec/moving_forwards_spec.rb +++ b/spec/moving_forwards_spec.rb @@ -123,7 +123,10 @@ def self.mars_rover(map: Map.new(x_domain: (0..10), y_domain: (-9..9)), located_ context 'moving towards the north and south pole' do it 'can move to the north pole of the planet' do - mars_rover = a_mars_rover(located_at: Location.new(coordinates: Coordinates.new(x: 0, y: 8), direction: 'N')) + mars_rover = + a_mars_rover( + map: Map.new(x_domain: (-18..18), y_domain: (-9..9)), + located_at: Location.new(coordinates: Coordinates.new(x: 0, y: 8), direction: 'N')) mars_rover.execute(['f']) @@ -132,7 +135,11 @@ def self.mars_rover(map: Map.new(x_domain: (0..10), y_domain: (-9..9)), located_ end it 'faces south upon reaching the north pole' do - mars_rover = a_mars_rover(located_at: Location.new(coordinates: Coordinates.new(x: 0, y: 8), direction: 'N')) + mars_rover = + a_mars_rover( + map: Map.new(x_domain: (-18..18), y_domain: (-9..9)), + located_at: Location.new(coordinates: Coordinates.new(x: 0, y: 8), direction: 'N') + ) mars_rover.execute(['f']) @@ -140,7 +147,11 @@ def self.mars_rover(map: Map.new(x_domain: (0..10), y_domain: (-9..9)), located_ end it 'can move to the north pole from any longitude' do - mars_rover = a_mars_rover(located_at: Location.new(coordinates: Coordinates.new(x: 1, y: 8), direction: 'N')) + mars_rover = + a_mars_rover( + map: Map.new(x_domain: (-18..18), y_domain: (-9..9)), + located_at: Location.new(coordinates: Coordinates.new(x: 1, y: 8), direction: 'N') + ) mars_rover.execute(['f']) @@ -148,7 +159,11 @@ def self.mars_rover(map: Map.new(x_domain: (0..10), y_domain: (-9..9)), located_ end it 'faces north upon reaching the south pole' do - mars_rover = a_mars_rover(located_at: Location.new(coordinates: Coordinates.new(x: 0, y: -8), direction: 'S')) + mars_rover = + a_mars_rover( + map: Map.new(x_domain: (-18..18), y_domain: (-9..9)), + located_at: Location.new(coordinates: Coordinates.new(x: 0, y: -8), direction: 'S') + ) mars_rover.execute(['f']) @@ -156,7 +171,11 @@ def self.mars_rover(map: Map.new(x_domain: (0..10), y_domain: (-9..9)), located_ end it 'can move to the south pole of the planet' do - mars_rover = a_mars_rover(located_at: Location.new(coordinates: Coordinates.new(x: 0, y: -8), direction: 'S')) + mars_rover = + a_mars_rover( + map: Map.new(x_domain: (-18..18), y_domain: (-9..9)), + located_at: Location.new(coordinates: Coordinates.new(x: 0, y: -8), direction: 'S') + ) mars_rover.execute(['f'])