adapt JSON parsing in tests to allow for omitted fields

This commit is contained in:
Dennis Luxen 2014-05-16 16:13:25 +02:00
parent a80815d57a
commit 2d498cb88b
2 changed files with 38 additions and 34 deletions

View File

@ -93,11 +93,13 @@ def route_status response
end end
def extract_instruction_list instructions, index, postfix=nil def extract_instruction_list instructions, index, postfix=nil
if instructions
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }. instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
map { |r| r[index] }. map { |r| r[index] }.
map { |r| (r=="" || r==nil) ? '""' : "#{r}#{postfix}" }. map { |r| (r=="" || r==nil) ? '""' : "#{r}#{postfix}" }.
join(',') join(',')
end end
end
def way_list instructions def way_list instructions
extract_instruction_list instructions, 1 extract_instruction_list instructions, 1
@ -112,6 +114,7 @@ def bearing_list instructions
end end
def turn_list instructions def turn_list instructions
if instructions
types = { types = {
0 => :none, 0 => :none,
1 => :straight, 1 => :straight,
@ -140,6 +143,7 @@ def turn_list instructions
end end
end.join(',') end.join(',')
end end
end
def mode_list instructions def mode_list instructions
extract_instruction_list instructions, 8 extract_instruction_list instructions, 8