From d1963bdd52c1d0fdc23606cd21e79b1f4fc9dc82 Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Thu, 17 May 2018 10:14:36 +0200 Subject: Update RouteWayCostCalculator spec. Refs #6884 --- spec/services/route_way_cost_calculator_spec.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'spec') diff --git a/spec/services/route_way_cost_calculator_spec.rb b/spec/services/route_way_cost_calculator_spec.rb index c417f137a..7b9c36596 100644 --- a/spec/services/route_way_cost_calculator_spec.rb +++ b/spec/services/route_way_cost_calculator_spec.rb @@ -1,10 +1,12 @@ RSpec.describe RouteWayCostCalculator do describe "#calculate!" do + before do + allow(TomTom).to receive(:api_key).and_return('dummy') + end + it "calculates and stores WayCosts in the given route's #cost field" do route = create(:route) - allow(TomTom).to receive(:api_key).and_return('dummy') - # Fake the request to the TomTom API, but don't actually send the right # things in the request or response. This is just to fake the request so # we don't actually call their API in tests. The test doesn't test @@ -37,14 +39,14 @@ RSpec.describe RouteWayCostCalculator do stub_request( :post, - "https://api.tomtom.com/routing/1/matrix/json?key&routeType=shortest&travelMode=bus" + "https://api.tomtom.com/routing/1/matrix/json?key=dummy&routeType=shortest&traffic=false&travelMode=bus" ) .with( headers: { 'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', - 'User-Agent'=>'Faraday v0.9.2' + 'User-Agent'=>'Faraday v0.15.1' }) .to_return( status: 200, -- cgit v1.2.3