diff options
Diffstat (limited to 'spec/services')
| -rw-r--r-- | spec/services/route_way_cost_calculator_spec.rb | 10 | 
1 files changed, 6 insertions, 4 deletions
| 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, | 
