aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-05-24 11:46:01 +0200
committerRobert2017-05-29 08:49:52 +0200
commit8efdf7cadf0659601bb303a4eaeb9a5d7f6a78fc (patch)
tree95b6321fa283ce5299e35e0542c4625bdee51dc7
parent8b9d4a03548b6fd8783e596974a51383d7e17c57 (diff)
downloadchouette-core-8efdf7cadf0659601bb303a4eaeb9a5d7f6a78fc.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.rb22
-rw-r--r--spec/models/chouette/vehicle_journey_at_stops_are_in_increasing_time_order_validator_spec.rb18
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 }