cuke: test travel time of individual instructions

This commit is contained in:
Emil Tin
2014-04-02 15:52:26 +02:00
parent 165c252fc8
commit df83dfdfe8
3 changed files with 89 additions and 55 deletions
+19 -16
View File
@@ -80,25 +80,23 @@ def route_status response
end
end
def way_list instructions
def extract_instruction_list instructions, index, postfix=nil
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
map { |r| r[1] }.
map { |r| r=="" ? '""' : r }.
map { |r| r[index] }.
map { |r| (r=="" || r==nil) ? '""' : "#{r}#{postfix}" }.
join(',')
end
def way_list instructions
extract_instruction_list instructions, 1
end
def compass_list instructions
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
map { |r| r[6] }.
map { |r| r=="" ? '""' : r }.
join(',')
extract_instruction_list instructions, 6
end
def bearing_list instructions
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
map { |r| r[7] }.
map { |r| r=="" ? '""' : r }.
join(',')
extract_instruction_list instructions, 7
end
def turn_list instructions
@@ -125,15 +123,20 @@ def turn_list instructions
# replace instructions codes with strings
# "11-3" (enter roundabout and leave a 3rd exit) gets converted to "enter_roundabout-3"
instructions.map do |r|
r[0].to_s.gsub!(/^\d*/) do |match|
r[0].to_s.gsub(/^\d*/) do |match|
types[match.to_i].to_s
end
end.join(',')
end
def mode_list instructions
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
map { |r| r[8] }.
map { |r| (r=="" || r==nil) ? '""' : r }.
join(',')
extract_instruction_list instructions, 8
end
def time_list instructions
extract_instruction_list instructions, 4, "s"
end
def distance_list instructions
extract_instruction_list instructions, 2, "m"
end