distances must be specified in meters in tests

This commit is contained in:
Emil Tin 2012-10-01 18:13:44 +02:00
parent 97f04eae91
commit 7610af3378
2 changed files with 68 additions and 67 deletions

View File

@ -217,10 +217,11 @@ When /^I route I should get$/ do |table|
if table.headers.include? 'route'
got['route'] = (instructions || '').strip
if table.headers.include? 'distance'
raise "*** Distance must be specied in meters. (ex: 250m)" unless row['distance'] =~ /\d+m/
got['distance'] = instructions ? json['route_summary']['total_distance'].to_s : ''
end
if table.headers.include? 'time'
raise "*** time must be specied in seconds. (ex: 60s)" unless row['time'] =~ /\d+s/
raise "*** Time must be specied in seconds. (ex: 60s)" unless row['time'] =~ /\d+s/
got['time'] = instructions ? "#{json['route_summary']['total_time'].to_s}s" : ''
end
if table.headers.include? 'bearing'

View File

@ -16,7 +16,7 @@ Feature: Distance calculation
When I route I should get
| from | to | route | distance |
| a | d | abcde | 300 +-1 |
| a | d | abcde | 300m +-1 |
Scenario: Distance should equal sum of segments, rightwinded
Given the node map
@ -30,7 +30,7 @@ Feature: Distance calculation
When I route I should get
| from | to | route | distance |
| a | d | abcde | 300 +-1 |
| a | d | abcde | 300m +-1 |
Scenario: 1m distances
Given a grid size of 1 meters
@ -44,12 +44,12 @@ Feature: Distance calculation
When I route I should get
| from | to | route | distance |
| a | b | abc | 1 +-1 |
| b | a | abc | 1 +-1 |
| b | c | abc | 1 +-1 |
| c | b | abc | 1 +-1 |
| a | c | abc | 2 +-1 |
| c | a | abc | 2 +-1 |
| a | b | abc | 1m +-1 |
| b | a | abc | 1m +-1 |
| b | c | abc | 1m +-1 |
| c | b | abc | 1m +-1 |
| a | c | abc | 2m +-1 |
| c | a | abc | 2m +-1 |
Scenario: 10m distances
Given a grid size of 10 meters
@ -63,12 +63,12 @@ Feature: Distance calculation
When I route I should get
| from | to | route | distance |
| a | b | abc | 10 +-1 |
| b | a | abc | 10 +-1 |
| b | c | abc | 10 +-1 |
| c | b | abc | 10 +-1 |
| a | c | abc | 20 +-1 |
| c | a | abc | 20 +-1 |
| a | b | abc | 10m +-1 |
| b | a | abc | 10m +-1 |
| b | c | abc | 10m +-1 |
| c | b | abc | 10m +-1 |
| a | c | abc | 20m +-1 |
| c | a | abc | 20m +-1 |
Scenario: 100m distances
Given a grid size of 100 meters
@ -82,12 +82,12 @@ Feature: Distance calculation
When I route I should get
| from | to | route | distance |
| a | b | abc | 100 +-1 |
| b | a | abc | 100 +-1 |
| b | c | abc | 100 +-1 |
| c | b | abc | 100 +-1 |
| a | c | abc | 200 +-1 |
| c | a | abc | 200 +-1 |
| a | b | abc | 100m +-1 |
| b | a | abc | 100m +-1 |
| b | c | abc | 100m +-1 |
| c | b | abc | 100m +-1 |
| a | c | abc | 200m +-1 |
| c | a | abc | 200m +-1 |
Scenario: 1km distance
Given a grid size of 1000 meters
@ -101,12 +101,12 @@ Feature: Distance calculation
When I route I should get
| from | to | route | distance |
| a | b | abc | 1000 +-1 |
| b | a | abc | 1000 +-1 |
| b | c | abc | 1000 +-1 |
| c | b | abc | 1000 +-1 |
| a | c | abc | 2000 +-1 |
| c | a | abc | 2000 +-1 |
| a | b | abc | 1000m +-1 |
| b | a | abc | 1000m +-1 |
| b | c | abc | 1000m +-1 |
| c | b | abc | 1000m +-1 |
| a | c | abc | 2000m +-1 |
| c | a | abc | 2000m +-1 |
@winding
Scenario: Distance of a winding south-north path
@ -123,13 +123,13 @@ Feature: Distance calculation
When I route I should get
| from | to | route | distance |
| a | b | abcdefgh | 10 +-1 |
| a | c | abcdefgh | 20 +-1 |
| a | d | abcdefgh | 30 +-1 |
| a | e | abcdefgh | 40 +-1 |
| a | f | abcdefgh | 50 +-1 |
| a | g | abcdefgh | 60 +-1 |
| a | h | abcdefgh | 70 +-1 |
| a | b | abcdefgh | 10m +-1 |
| a | c | abcdefgh | 20m +-1 |
| a | d | abcdefgh | 30m +-1 |
| a | e | abcdefgh | 40m +-1 |
| a | f | abcdefgh | 50m +-1 |
| a | g | abcdefgh | 60m +-1 |
| a | h | abcdefgh | 70m +-1 |
@winding
Scenario: Distance of a winding east-west path
@ -144,13 +144,13 @@ Feature: Distance calculation
When I route I should get
| from | to | route | distance |
| a | b | abcdefgh | 10 +-1 |
| a | c | abcdefgh | 20 +-1 |
| a | d | abcdefgh | 30 +-1 |
| a | e | abcdefgh | 40 +-1 |
| a | f | abcdefgh | 50 +-1 |
| a | g | abcdefgh | 60 +-1 |
| a | h | abcdefgh | 70 +-1 |
| a | b | abcdefgh | 10m +-1 |
| a | c | abcdefgh | 20m +-1 |
| a | d | abcdefgh | 30m +-1 |
| a | e | abcdefgh | 40m +-1 |
| a | f | abcdefgh | 50m +-1 |
| a | g | abcdefgh | 60m +-1 |
| a | h | abcdefgh | 70m +-1 |
Scenario: Geometric distances
Given a grid size of 1000 meters
@ -192,27 +192,27 @@ Feature: Distance calculation
When I route I should get
| from | to | route | distance |
| x | a | xa | 3000 +-1 |
| x | b | xb | 3160 +-1 |
| x | c | xc | 3610 +-1 |
| x | d | xd | 4240 +-1 |
| x | e | xe | 3610 +-1 |
| x | f | xf | 3160 +-1 |
| x | g | xg | 3000 +-1 |
| x | h | xh | 3160 +-1 |
| x | i | xi | 3610 +-1 |
| x | j | xj | 4240 +-1 |
| x | k | xk | 3610 +-1 |
| x | l | xl | 3160 +-1 |
| x | m | xm | 3000 +-1 |
| x | n | xn | 3160 +-1 |
| x | o | xo | 3610 +-1 |
| x | p | xp | 4240 +-1 |
| x | q | xq | 3610 +-1 |
| x | r | xr | 3160 +-1 |
| x | s | xs | 3000 +-1 |
| x | t | xt | 3160 +-1 |
| x | u | xu | 3610 +-1 |
| x | v | xv | 4240 +-1 |
| x | w | xw | 3610 +-1 |
| x | y | xy | 3160 +-1 |
| x | a | xa | 3000m +-1 |
| x | b | xb | 3160m +-1 |
| x | c | xc | 3610m +-1 |
| x | d | xd | 4240m +-1 |
| x | e | xe | 3610m +-1 |
| x | f | xf | 3160m +-1 |
| x | g | xg | 3000m +-1 |
| x | h | xh | 3160m +-1 |
| x | i | xi | 3610m +-1 |
| x | j | xj | 4240m +-1 |
| x | k | xk | 3610m +-1 |
| x | l | xl | 3160m +-1 |
| x | m | xm | 3000m +-1 |
| x | n | xn | 3160m +-1 |
| x | o | xo | 3610m +-1 |
| x | p | xp | 4240m +-1 |
| x | q | xq | 3610m +-1 |
| x | r | xr | 3160m +-1 |
| x | s | xs | 3000m +-1 |
| x | t | xt | 3160m +-1 |
| x | u | xu | 3610m +-1 |
| x | v | xv | 4240m +-1 |
| x | w | xw | 3610m +-1 |
| x | y | xy | 3160m +-1 |