Sha256: 8b38a293ed19184eab1fd94553bff64290d69fec41e4267edfee04f17ea35d43

Contents?: true

Size: 1.89 KB

Versions: 13

Compression:

Stored size: 1.89 KB

Contents

Factory.define :vehicle_journey_common, :class => "Chouette::VehicleJourney" do |v|
  v.sequence(:objectid) { |n| "test:VehicleJourney:#{n}" }
end
Factory.define :vehicle_journey, :parent => :vehicle_journey_common do |v|
  v.association :journey_pattern, :factory => :journey_pattern
  v.after_build do |vj|
    vj.route_id = vj.journey_pattern.route_id
  end
  v.after_create do |vj|
    vj.journey_pattern.stop_points.each_with_index do |sp,index|
      vj.vehicle_journey_at_stops << Factory( :vehicle_journey_at_stop, 
               :vehicle_journey => vj, 
               :stop_point => sp, 
               :arrival_time => (-1 * index).minutes.ago, 
               :departure_time => (-1 * index).minutes.ago)
    end
  end
end
Factory.define :vehicle_journey_odd, :parent => :vehicle_journey_common do |v|
  v.association :journey_pattern, :factory => :journey_pattern_odd
  v.after_build do |vj|
    vj.route_id = vj.journey_pattern.route_id
  end
  v.after_create do |vj|
    vj.journey_pattern.stop_points.each_with_index do |sp,index|
      vj.vehicle_journey_at_stops << Factory( :vehicle_journey_at_stop, 
               :vehicle_journey => vj, 
               :stop_point => sp, 
               :arrival_time => (-1 * index).minutes.ago, 
               :departure_time => (-1 * index).minutes.ago)
    end
  end
end
Factory.define :vehicle_journey_even, :parent => :vehicle_journey_common do |v|
  v.association :journey_pattern, :factory => :journey_pattern_even
  v.after_build do |vj|
    vj.route_id = vj.journey_pattern.route_id
  end
  v.after_create do |vj|
    vj.journey_pattern.stop_points.each_with_index do |sp,index|
      vj.vehicle_journey_at_stops << Factory( :vehicle_journey_at_stop, 
               :vehicle_journey => vj, 
               :stop_point => sp, 
               :arrival_time => (-1 * index).minutes.ago, 
               :departure_time => (-1 * index).minutes.ago)
    end
  end
end


Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ninoxe-1.0.3 lib/factories/chouette_vehicle_journey.rb
ninoxe-1.0.2 lib/factories/chouette_vehicle_journey.rb
ninoxe-1.0.1 lib/factories/chouette_vehicle_journey.rb
ninoxe-1.0.0 lib/factories/chouette_vehicle_journey.rb
ninoxe-0.1.6 lib/factories/chouette_vehicle_journey.rb
ninoxe-0.1.5 lib/factories/chouette_vehicle_journey.rb
ninoxe-0.1.4 lib/factories/chouette_vehicle_journey.rb
ninoxe-0.1.3 lib/factories/chouette_vehicle_journey.rb
ninoxe-0.1.2 lib/factories/chouette_vehicle_journey.rb
ninoxe-0.1.1 lib/factories/chouette_vehicle_journey.rb
ninoxe-0.1.0 lib/factories/chouette_vehicle_journey.rb
ninoxe-0.0.9 lib/factories/chouette_vehicle_journey.rb
ninoxe-0.0.8 lib/factories/chouette_vehicle_journey.rb