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,10 +93,12 @@ def route_status response
end
def extract_instruction_list instructions, index, postfix=nil
if instructions
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
map { |r| r[index] }.
map { |r| (r=="" || r==nil) ? '""' : "#{r}#{postfix}" }.
join(',')
end
end
def way_list instructions
@ -112,6 +114,7 @@ def bearing_list instructions
end
def turn_list instructions
if instructions
types = {
0 => :none,
1 => :straight,
@ -139,6 +142,7 @@ def turn_list instructions
types[match.to_i].to_s
end
end.join(',')
end
end
def mode_list instructions