diff options
| author | Luc Donnet | 2018-01-11 11:26:09 +0100 | 
|---|---|---|
| committer | GitHub | 2018-01-11 11:26:09 +0100 | 
| commit | dec9361ab612597c827e1618998965eb38f41b9b (patch) | |
| tree | 1dc57b8c1875d77a04c59b13d4c3f06681ec5ed5 /spec/support | |
| parent | f7ed3ca6615bb4950b644d56136016c4482395a8 (diff) | |
| parent | c8a2e2ce194d3d051bb96522c40c4d34392bdf8e (diff) | |
| download | chouette-core-dec9361ab612597c827e1618998965eb38f41b9b.tar.bz2 | |
Merge pull request #225 from af83/5535-compute-vehicle-journeys-times
5535 compute vehicle journeys times
Diffstat (limited to 'spec/support')
| -rw-r--r-- | spec/support/journey_pattern_helper.rb | 19 | 
1 files changed, 19 insertions, 0 deletions
| diff --git a/spec/support/journey_pattern_helper.rb b/spec/support/journey_pattern_helper.rb new file mode 100644 index 000000000..3ba1c501b --- /dev/null +++ b/spec/support/journey_pattern_helper.rb @@ -0,0 +1,19 @@ +module Support +  module JourneyPatternHelper +    def generate_journey_pattern_costs distance, time +      costs = {} +      (journey_pattern.stop_points.size - 1).times do |i| +        start, finish = journey_pattern.stop_points[i..i+1] +        costs["#{start.stop_area_id}-#{finish.stop_area_id}"] = { +          distance: (distance.respond_to?(:call) ? distance.call(i) : distance), +          time: (time.respond_to?(:call) ? time.call(i) : time) +        } +      end +      costs +    end +  end +end + +RSpec.configure do | config | +  config.include Support::JourneyPatternHelper, type: :model +end | 
