osrm-backend/features/step_definitions/requests.rb

45 lines
1.1 KiB
Ruby
Raw Normal View History

2012-12-10 10:07:47 -05:00
When /^I request \/(.*)$/ do |path|
reprocess
OSRMLauncher.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
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
@json['via_indices'].class.should == Array
2012-12-16 07:36:47 -05:00
end
When /^I preprocess data$/ do
begin
reprocess
rescue OSRMError => e
@process_error = e
end
end
2012-12-16 08:10:33 -05:00
Then /^"([^"]*)" should return code (\d+)$/ do |binary, code|
@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
end