2012-12-10 10:07:47 -05:00
|
|
|
When /^I request \/(.*)$/ do |path|
|
|
|
|
reprocess
|
2014-03-19 14:28:24 -04:00
|
|
|
OSRMBackgroundLauncher.new("#{@osm_file}.osrm") do
|
2012-12-10 10:07:47 -05:00
|
|
|
@response = request_path path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^I should get a response/ do
|
|
|
|
@response.code.should == "200"
|
|
|
|
@response.body.should_not == nil
|
|
|
|
@response.body.should_not == ''
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^response should be valid JSON$/ do
|
|
|
|
@json = JSON.parse @response.body
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^response should be well-formed$/ do
|
|
|
|
@json['status'].class.should == Fixnum
|
|
|
|
end
|
|
|
|
|
2014-04-29 13:29:26 -04:00
|
|
|
Then /^status code should be (\d+)$/ do |code|
|
|
|
|
@json = JSON.parse @response.body
|
|
|
|
@json['status'].should == code.to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^status message should be "(.*?)"$/ do |message|
|
|
|
|
@json = JSON.parse @response.body
|
|
|
|
@json['status_message'].should == message
|
|
|
|
end
|
|
|
|
|
2012-12-16 07:36:47 -05:00
|
|
|
Then /^response should be a well-formed route$/ do
|
|
|
|
step "response should be well-formed"
|
|
|
|
@json['status_message'].class.should == String
|
|
|
|
@json['route_summary'].class.should == Hash
|
|
|
|
@json['route_geometry'].class.should == String
|
|
|
|
@json['route_instructions'].class.should == Array
|
|
|
|
@json['via_points'].class.should == Array
|
2013-12-12 18:37:00 -05:00
|
|
|
@json['via_indices'].class.should == Array
|
2012-12-16 07:36:47 -05:00
|
|
|
end
|
|
|
|
|
2012-12-16 08:10:33 -05:00
|
|
|
Then /^"([^"]*)" should return code (\d+)$/ do |binary, code|
|
2012-12-17 13:27:18 -05:00
|
|
|
@process_error.is_a?(OSRMError).should == true
|
2012-12-16 08:10:33 -05:00
|
|
|
@process_error.process.should == binary
|
2012-12-16 07:36:47 -05:00
|
|
|
@process_error.code.to_i.should == code.to_i
|
2014-04-21 09:24:42 -04:00
|
|
|
end
|