diff options
| author | Luc Donnet | 2018-04-10 17:30:55 +0200 | 
|---|---|---|
| committer | GitHub | 2018-04-10 17:30:55 +0200 | 
| commit | 537a5078657ead0b89aa5220c05dfbc01ae94dca (patch) | |
| tree | 54072303cdbab71e6005e7fc5c2af6db6a4f9d0b /spec/lib | |
| parent | dad504f5794a36be8dac97a257cdecd87704763b (diff) | |
| parent | 22e7844c1d2392e2a651a33bf83c32664a879619 (diff) | |
| download | chouette-core-537a5078657ead0b89aa5220c05dfbc01ae94dca.tar.bz2 | |
Merge pull request #438 from af83/6368-gtfs-import
GTFS import (first step)
Diffstat (limited to 'spec/lib')
| -rw-r--r-- | spec/lib/gtfs/time_spec.rb | 27 | 
1 files changed, 27 insertions, 0 deletions
| diff --git a/spec/lib/gtfs/time_spec.rb b/spec/lib/gtfs/time_spec.rb new file mode 100644 index 000000000..540d7cc79 --- /dev/null +++ b/spec/lib/gtfs/time_spec.rb @@ -0,0 +1,27 @@ +require "rails_helper" + +RSpec.describe GTFS::Time do + +  it "returns an UTC Time with given H:M:S" do +    expect(GTFS::Time.parse("14:29:00").time).to eq(Time.parse("2000-01-01 14:29:00 +00")) +  end + +  it "support hours with a single number" do +    expect(GTFS::Time.parse("4:29:00").time).to eq(Time.parse("2000-01-01 04:29:00 +00")) +  end + +  it "return nil for invalid format" do +    expect(GTFS::Time.parse("abc")).to be_nil +  end + +  it "removes 24 hours after 23:59:59" do +    expect(GTFS::Time.parse("25:29:00").time).to eq(Time.parse("2000-01-01 01:29:00 +00")) +  end + +  it "returns a day_offset for each 24 hours turn" do +    expect(GTFS::Time.parse("10:00:00").day_offset).to eq(0) +    expect(GTFS::Time.parse("30:00:00").day_offset).to eq(1) +    expect(GTFS::Time.parse("50:00:00").day_offset).to eq(2) +  end + +end | 
