test/unit/ierail.rb in ierail-0.3.2 vs test/unit/ierail.rb in ierail-0.3.4
- old
+ new
@@ -2,14 +2,25 @@
require_relative 'helper'
require 'minitest/autorun'
require 'ierail'
+require 'tzinfo'
class IERailTest < MiniTest::Unit::TestCase
def setup
@ir = IERail.new
+
+ @now = Time.now
+
+ if TZInfo::Timezone.get('Europe/Dublin').current_period.dst?
+ unless @now.zone == 'IST'
+ @now -= @now.utc_offset - 3600
+ end
+ else
+ @now -= @now.utc_offset
+ end
end
def test_that_the_train_directions_are_correct
northbound_train = @ir.northbound_from('Howth Junction').sample
southbound_train = @ir.southbound_from('Clongriffin').sample
@@ -22,26 +33,26 @@
assert_empty nonexistant
end
def test_that_the_before_time_constraint_works
#Thirty minutes from now
- thirty_mins = Time.now + 60*30
+ thirty_mins = @now + (60 * 30)
time = "#{thirty_mins.hour}:#{thirty_mins.min}" # "HH:MM"
before_train = @ir.southbound_from('Malahide').before(time).sample
- assert Time.parse(before_train.expdepart) <= thirty_mins
+ assert before_train.expdepart <= thirty_mins
end
def test_that_the_after_time_constraint_works
#Thirty minutes from now
- thirty_mins = Time.now + 60*30
+ thirty_mins = @now + (60 * 30)
time = "#{thirty_mins.hour}:#{thirty_mins.min}" # "HH:MM"
after_train = @ir.southbound_from('Malahide').after(time).sample
- assert Time.parse(after_train.expdepart) >= thirty_mins
+ assert after_train.expdepart >= thirty_mins
end
def test_that_the_in_constraint_works
mins = 30
- thirty_mins = Time.now + 60 * mins
+ thirty_mins = @now + (60 * mins)
time = "#{thirty_mins.hour}:#{thirty_mins.min}" # "HH:MM"
before_train = @ir.southbound_from('Malahide').before(time)
in_half_an_hour = @ir.southbound_from('Malahide').in(mins)
assert_equal before_train.count, in_half_an_hour.count