diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/import/gtfs_spec.rb | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/spec/models/import/gtfs_spec.rb b/spec/models/import/gtfs_spec.rb index bdfc565d3..dcdef45e2 100644 --- a/spec/models/import/gtfs_spec.rb +++ b/spec/models/import/gtfs_spec.rb @@ -116,17 +116,28 @@ RSpec.describe Import::Gtfs do it "should create a VehicleJourney for each trip" do referential.switch + import.import_calendars import.import_routes import.import_trips - defined_attributes = [ - :published_journey_name - ] + defined_attributes = ->(v) { + [v.published_journey_name, v.time_tables.first&.comment] + } expected_attributes = [ - "to Bullfrog", "to Airport", "Shuttle", "CITY1", "CITY2", "to Furnace Creek Resort", "to Bullfrog", "to Amargosa Valley", "to Airport", "to Amargosa Valley", "to Airport" + ["to Bullfrog", "Calendar FULLW"], + ["to Airport", "Calendar FULLW"], + ["Shuttle", "Calendar FULLW"], + ["CITY1", "Calendar FULLW"], + ["CITY2", "Calendar FULLW"], + ["to Furnace Creek Resort", "Calendar FULLW"], + ["to Bullfrog", "Calendar FULLW"], + ["to Amargosa Valley", "Calendar WE"], + ["to Airport", "Calendar WE"], + ["to Amargosa Valley", "Calendar WE"], + ["to Airport", "Calendar WE"] ] - expect(referential.vehicle_journeys.pluck(*defined_attributes)).to eq(expected_attributes) + expect(referential.vehicle_journeys.map(&defined_attributes)).to eq(expected_attributes) end end @@ -182,4 +193,27 @@ RSpec.describe Import::Gtfs do end end + describe "#import_calendars" do + let(:import) { create_import "google-sample-feed.zip" } + + it "should create a Timetable for each calendar" do + referential.switch + + import.import_calendars + + def d(value) + Date.parse(value) + end + + defined_attributes = ->(t) { + [t.comment, t.valid_days, t.periods.first.period_start, t.periods.first.period_end] + } + expected_attributes = [ + ["Calendar FULLW", [1, 2, 3, 4, 5, 6, 7], d("Mon, 01 Jan 2007"), d("Fri, 31 Dec 2010")], + ["Calendar WE", [6, 7], d("Mon, 01 Jan 2007"), d("Fri, 31 Dec 2010")] + ] + expect(referential.time_tables.map(&defined_attributes)).to eq(expected_attributes) + end + end + end |
