test/unit/station_data.rb in ierail-0.3.5 vs test/unit/station_data.rb in ierail-0.4.0
- old
+ new
@@ -1,45 +1,62 @@
$:.unshift(File.join(File.dirname(__FILE__), '..','..', 'lib'))
require_relative 'helper'
-require 'minitest/autorun'
-require 'ierail'
-
class StationDataTest < MiniTest::Unit::TestCase
def setup
ir = IERail.new
- @station_data = ir.station('Glenageary').sample
+
+ VCR.configure do |c|
+ c.cassette_library_dir = 'fixtures/vcr_cassettes'
+ c.hook_into :webmock
+ end
+
+ VCR.use_cassette('station') do
+ @station_data = ir.station('Dublin Connolly').sample #Use a random station
+ end
end
- def test_that_there_is_a_traincode
- refute_empty @station_data.traincode
+ def test_that_there_is_a_server_time
+ refute_nil @station_data.server_time
end
+ def test_that_there_is_a_train_code
+ refute_empty @station_data.train_code
+ end
+
def test_that_there_is_a_station_name_and_code
refute_empty @station_data.name
refute_empty @station_data.code
end
+ def test_that_there_is_a_query_time
+ refute_nil @station_data.query_time
+ end
+
def test_that_there_is_a_status
refute_empty @station_data.status
end
- def test_that_there_is_a_due_value
- refute_empty @station_data.due_in
+ def test_that_there_is_a_due_in_value
+ refute_nil @station_data.due_in
end
- def test_that_there_is_a_late_value
- refute_empty @station_data.late
+ def test_that_there_is_a_minutes_early_value
+ refute_nil @station_data.minutes_early
end
+ def test_that_there_is_a_minutes_late_value
+ refute_nil @station_data.minutes_late
+ end
+
def test_that_there_is_a_query_time
refute_nil @station_data.query_time
end
def test_that_there_is_a_train_date
- refute_empty @station_data.train_date
+ refute_nil @station_data.train_date
end
def test_that_origin_method_returns_a_hash
assert_equal @station_data.origin.class, Hash
end
@@ -60,23 +77,52 @@
def test_that_arrival_method_returns_a_hash
assert_equal @station_data.arrival.class, Hash
end
- def test_that_there_is_an_arrival_sched_and_exp
+ def test_that_there_is_an_arrival_scheduled_and_expected
refute_nil @station_data.arrival[:scheduled]
refute_nil @station_data.arrival[:expected]
end
def test_that_departure_method_returns_a_hash
assert_equal @station_data.departure.class, Hash
end
- def test_that_there_is_a_departure_sched_and_exp
+ def test_that_there_is_a_departure_scheduled_and_expected
refute_nil @station_data.departure[:scheduled]
refute_nil @station_data.departure[:expected]
end
def test_that_it_responds_to_late?
assert_respond_to @station_data, :late?
+ end
+
+ def test_that_late_not_early_or_on_time
+ if @station_data.late?
+ refute_same @station_data.late?, @station_data.early?
+ refute_same @station_data.late?, @station_data.on_time?
+ end
+ end
+
+ def test_that_it_responds_to_early?
+ assert_respond_to @station_data, :early?
+ end
+
+ def test_that_early_not_late_or_on_time
+ if @station_data.early?
+ refute_same @station_data.early?, @station_data.late?
+ refute_same @station_data.early?, @station_data.on_time?
+ end
+ end
+
+ def test_that_it_responds_to_on_time?
+ assert_respond_to @station_data, :on_time?
+ end
+
+ def test_that_on_time_not_early_or_late
+ if @station_data.on_time?
+ refute_same @station_data.on_time?, @station_data.early?
+ refute_same @station_data.on_time?, @station_data.late?
+ end
end
end