From d726ce6340e79807d1d3f1861979f42c3bf9bea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Gru=C3=9F?= Date: Sun, 7 Jun 2015 12:20:03 +0200 Subject: [PATCH] removed send_simple_request --- features/step_definitions/locate.rb | 2 +- features/step_definitions/nearest.rb | 2 +- features/support/http.rb | 16 ---------------- features/support/locate.rb | 10 +++++----- features/support/nearest.rb | 8 ++++---- 5 files changed, 11 insertions(+), 27 deletions(-) diff --git a/features/step_definitions/locate.rb b/features/step_definitions/locate.rb index 190795c26..2fd8e627b 100644 --- a/features/step_definitions/locate.rb +++ b/features/step_definitions/locate.rb @@ -9,7 +9,7 @@ When /^I request locate I should get$/ do |table| out_node = find_node_by_name row['out'] raise "*** unknown out-node '#{row['out']}" unless out_node - response = request_locate("#{in_node.lat},#{in_node.lon}") + response = request_locate(in_node) if response.code == "200" && response.body.empty? == false json = JSON.parse response.body if json['status'] == 0 diff --git a/features/step_definitions/nearest.rb b/features/step_definitions/nearest.rb index 099f4e06f..481c74167 100644 --- a/features/step_definitions/nearest.rb +++ b/features/step_definitions/nearest.rb @@ -9,7 +9,7 @@ When /^I request nearest I should get$/ do |table| out_node = find_node_by_name row['out'] raise "*** unknown out-node '#{row['out']}" unless out_node - response = request_nearest("#{in_node.lat},#{in_node.lon}") + response = request_nearest(in_node) if response.code == "200" && response.body.empty? == false json = JSON.parse response.body if json['status'] == 0 diff --git a/features/support/http.rb b/features/support/http.rb index 2eb298547..80dad8a85 100644 --- a/features/support/http.rb +++ b/features/support/http.rb @@ -10,22 +10,6 @@ def generate_request_url path end end -def send_simple_request uri, path - Timeout.timeout(OSRM_TIMEOUT) do - if @http_method.eql? "POST" - pos = path.index('=') + 1 - path.slice!(0, pos) - response = Net::HTTP.post_form uri, "loc" => path - else - response = Net::HTTP.get_response uri - end - end -rescue Errno::ECONNREFUSED => e - raise "*** osrm-routed is not running." -rescue Timeout::Error - raise "*** osrm-routed did not respond." -end - def send_request uri, waypoints=[], options={}, timestamps=[] @query = uri.to_s Timeout.timeout(OSRM_TIMEOUT) do diff --git a/features/support/locate.rb b/features/support/locate.rb index 586d0b393..a62e53aa9 100644 --- a/features/support/locate.rb +++ b/features/support/locate.rb @@ -1,12 +1,12 @@ require 'net/http' -def request_locate_url path +def request_locate_url path, node @query = path - + uri = generate_request_url path - response = send_simple_request uri, path + response = send_request uri, [node] end -def request_locate a - request_locate_url "locate?loc=#{a}" +def request_locate node + request_locate_url "locate?loc=#{node.lat},#{node.lon}", node end diff --git a/features/support/nearest.rb b/features/support/nearest.rb index f76ddc9f6..af52b49e0 100644 --- a/features/support/nearest.rb +++ b/features/support/nearest.rb @@ -1,12 +1,12 @@ require 'net/http' -def request_nearest_url path +def request_nearest_url path, node @query = path uri = generate_request_url path - response = send_simple_request uri, path + response = send_request uri, [node] end -def request_nearest a - request_nearest_url "nearest?loc=#{a}" +def request_nearest node + request_nearest_url "nearest?loc=#{node.lat},#{node.lon}", node end