diff options
| author | Teddy Wing | 2017-05-24 11:46:01 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-05-26 13:20:55 +0200 |
| commit | 6e7bafb1447476b464e87a4e24a07d1162eb6d7c (patch) | |
| tree | 51dc84e268c18f68253b3accc99cf44480374ef2 | |
| parent | fdd66e2298eda51f67b587bb677591925ee5b859 (diff) | |
| download | chouette-core-6e7bafb1447476b464e87a4e24a07d1162eb6d7c.tar.bz2 | |
TimeDuration: Move `.exceeds_gap?` specs into the module's spec file
Take the specs out of the `IncreasingTimeOrderValidator` spec and move
them into `TimeDuration`. This is part of the consolidation and complete
move of the `exceeds_gap?` method into `TimeDuration`.
Add a context to the two test blocks that specifies the duration at a 4
hour gap. Currently the implementation doesn't do anything with that
argument, but this makes it clearer that we're using a four hour
duration.
Refs #870
| -rw-r--r-- | spec/lib/time_duration_spec.rb | 22 | ||||
| -rw-r--r-- | spec/models/chouette/vehicle_journey_at_stops_are_in_increasing_time_order_validator_spec.rb | 18 |
2 files changed, 22 insertions, 18 deletions
diff --git a/spec/lib/time_duration_spec.rb b/spec/lib/time_duration_spec.rb new file mode 100644 index 000000000..f55457e31 --- /dev/null +++ b/spec/lib/time_duration_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +describe TimeDuration do + describe ".exceeds_gap?" do + let!(:vehicle_journey) { create(:vehicle_journey_odd) } + subject { vehicle_journey.vehicle_journey_at_stops.first } + + context "when duration is 4.hours" do + it "should return false if gap < 1.hour" do + t1 = Time.now + t2 = Time.now + 3.minutes + expect(TimeDuration.exceeds_gap?(4.hours, t1, t2)).to be_falsey + end + + it "should return true if gap > 4.hour" do + t1 = Time.now + t2 = Time.now + (4.hours + 1.minutes) + expect(TimeDuration.exceeds_gap?(4.hours, t1, t2)).to be_truthy + end + end + end +end diff --git a/spec/models/chouette/vehicle_journey_at_stops_are_in_increasing_time_order_validator_spec.rb b/spec/models/chouette/vehicle_journey_at_stops_are_in_increasing_time_order_validator_spec.rb index 0b8565b5b..ed037bcc8 100644 --- a/spec/models/chouette/vehicle_journey_at_stops_are_in_increasing_time_order_validator_spec.rb +++ b/spec/models/chouette/vehicle_journey_at_stops_are_in_increasing_time_order_validator_spec.rb @@ -23,24 +23,6 @@ describe Chouette::VehicleJourneyAtStopsAreInIncreasingTimeOrderValidator do end end - # TODO: Move to TimeDuration - # describe "#exceeds_gap?" do - # let!(:vehicle_journey) { create(:vehicle_journey_odd) } - # subject { vehicle_journey.vehicle_journey_at_stops.first } - # - # it "should return false if gap < 1.hour" do - # t1 = Time.now - # t2 = Time.now + 3.minutes - # expect(subject.exceeds_gap?(t1, t2)).to be_falsey - # end - # - # it "should return true if gap > 4.hour" do - # t1 = Time.now - # t2 = Time.now + (4.hours + 1.minutes) - # expect(subject.exceeds_gap?(t1, t2)).to be_truthy - # end - # end - describe ".increasing_times_validate" do let!(:vehicle_journey) { create(:vehicle_journey_odd) } subject { vehicle_journey.vehicle_journey_at_stops.first } |
