ierail 0.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +37 -18
- data/README.md +37 -1
- data/fixtures/vcr_cassettes/find_station.yml +40 -0
- data/fixtures/vcr_cassettes/northbound.yml +241 -0
- data/fixtures/vcr_cassettes/southbound.yml +241 -0
- data/fixtures/vcr_cassettes/southbound_from.yml +241 -0
- data/fixtures/vcr_cassettes/station.yml +241 -0
- data/fixtures/vcr_cassettes/station_times.yml +100 -0
- data/fixtures/vcr_cassettes/stations.yml +520 -0
- data/fixtures/vcr_cassettes/train_movements.yml +78 -0
- data/fixtures/vcr_cassettes/trains.yml +326 -0
- data/fixtures/vcr_cassettes/westbound.yml +88 -0
- data/ierail.gemspec +7 -4
- data/lib/core_ext.rb +5 -5
- data/lib/ierail.rb +40 -58
- data/lib/station.rb +3 -3
- data/lib/station_data.rb +46 -33
- data/lib/train.rb +3 -3
- data/test/unit/helper.rb +19 -0
- data/test/unit/ierail.rb +125 -38
- data/test/unit/station.rb +10 -5
- data/test/unit/station_data.rb +59 -13
- data/test/unit/train.rb +10 -5
- data/test/unit/train_movement.rb +34 -12
- metadata +84 -14
data/test/unit/station.rb
CHANGED
@@ -2,13 +2,18 @@ $:.unshift(File.join(File.dirname(__FILE__), '..','..', 'lib'))
|
|
2
2
|
|
3
3
|
require_relative 'helper'
|
4
4
|
|
5
|
-
require 'minitest/autorun'
|
6
|
-
require 'ierail'
|
7
|
-
|
8
5
|
class StationTest < MiniTest::Unit::TestCase
|
9
6
|
def setup
|
10
7
|
ir = IERail.new
|
11
|
-
|
8
|
+
|
9
|
+
VCR.configure do |c|
|
10
|
+
c.cassette_library_dir = 'fixtures/vcr_cassettes'
|
11
|
+
c.hook_into :webmock
|
12
|
+
end
|
13
|
+
|
14
|
+
VCR.use_cassette('stations') do
|
15
|
+
@station = ir.stations.sample #Use a random station
|
16
|
+
end
|
12
17
|
end
|
13
18
|
|
14
19
|
def test_that_a_station_has_a_description
|
@@ -37,7 +42,7 @@ class StationTest < MiniTest::Unit::TestCase
|
|
37
42
|
end
|
38
43
|
|
39
44
|
def test_that_a_stations_has_an_id
|
40
|
-
|
45
|
+
refute_nil @station.id
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
data/test/unit/station_data.rb
CHANGED
@@ -2,17 +2,26 @@ $:.unshift(File.join(File.dirname(__FILE__), '..','..', 'lib'))
|
|
2
2
|
|
3
3
|
require_relative 'helper'
|
4
4
|
|
5
|
-
require 'minitest/autorun'
|
6
|
-
require 'ierail'
|
7
|
-
|
8
5
|
class StationDataTest < MiniTest::Unit::TestCase
|
9
6
|
def setup
|
10
7
|
ir = IERail.new
|
11
|
-
|
8
|
+
|
9
|
+
VCR.configure do |c|
|
10
|
+
c.cassette_library_dir = 'fixtures/vcr_cassettes'
|
11
|
+
c.hook_into :webmock
|
12
|
+
end
|
13
|
+
|
14
|
+
VCR.use_cassette('station') do
|
15
|
+
@station_data = ir.station('Dublin Connolly').sample #Use a random station
|
16
|
+
end
|
12
17
|
end
|
13
18
|
|
14
|
-
def
|
15
|
-
|
19
|
+
def test_that_there_is_a_server_time
|
20
|
+
refute_nil @station_data.server_time
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_that_there_is_a_train_code
|
24
|
+
refute_empty @station_data.train_code
|
16
25
|
end
|
17
26
|
|
18
27
|
def test_that_there_is_a_station_name_and_code
|
@@ -20,16 +29,24 @@ class StationDataTest < MiniTest::Unit::TestCase
|
|
20
29
|
refute_empty @station_data.code
|
21
30
|
end
|
22
31
|
|
32
|
+
def test_that_there_is_a_query_time
|
33
|
+
refute_nil @station_data.query_time
|
34
|
+
end
|
35
|
+
|
23
36
|
def test_that_there_is_a_status
|
24
37
|
refute_empty @station_data.status
|
25
38
|
end
|
26
39
|
|
27
|
-
def
|
28
|
-
|
40
|
+
def test_that_there_is_a_due_in_value
|
41
|
+
refute_nil @station_data.due_in
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_that_there_is_a_minutes_early_value
|
45
|
+
refute_nil @station_data.minutes_early
|
29
46
|
end
|
30
47
|
|
31
|
-
def
|
32
|
-
|
48
|
+
def test_that_there_is_a_minutes_late_value
|
49
|
+
refute_nil @station_data.minutes_late
|
33
50
|
end
|
34
51
|
|
35
52
|
def test_that_there_is_a_query_time
|
@@ -37,7 +54,7 @@ class StationDataTest < MiniTest::Unit::TestCase
|
|
37
54
|
end
|
38
55
|
|
39
56
|
def test_that_there_is_a_train_date
|
40
|
-
|
57
|
+
refute_nil @station_data.train_date
|
41
58
|
end
|
42
59
|
|
43
60
|
def test_that_origin_method_returns_a_hash
|
@@ -62,7 +79,7 @@ class StationDataTest < MiniTest::Unit::TestCase
|
|
62
79
|
assert_equal @station_data.arrival.class, Hash
|
63
80
|
end
|
64
81
|
|
65
|
-
def
|
82
|
+
def test_that_there_is_an_arrival_scheduled_and_expected
|
66
83
|
refute_nil @station_data.arrival[:scheduled]
|
67
84
|
refute_nil @station_data.arrival[:expected]
|
68
85
|
end
|
@@ -71,7 +88,7 @@ class StationDataTest < MiniTest::Unit::TestCase
|
|
71
88
|
assert_equal @station_data.departure.class, Hash
|
72
89
|
end
|
73
90
|
|
74
|
-
def
|
91
|
+
def test_that_there_is_a_departure_scheduled_and_expected
|
75
92
|
refute_nil @station_data.departure[:scheduled]
|
76
93
|
refute_nil @station_data.departure[:expected]
|
77
94
|
end
|
@@ -79,4 +96,33 @@ class StationDataTest < MiniTest::Unit::TestCase
|
|
79
96
|
def test_that_it_responds_to_late?
|
80
97
|
assert_respond_to @station_data, :late?
|
81
98
|
end
|
99
|
+
|
100
|
+
def test_that_late_not_early_or_on_time
|
101
|
+
if @station_data.late?
|
102
|
+
refute_same @station_data.late?, @station_data.early?
|
103
|
+
refute_same @station_data.late?, @station_data.on_time?
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_that_it_responds_to_early?
|
108
|
+
assert_respond_to @station_data, :early?
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_that_early_not_late_or_on_time
|
112
|
+
if @station_data.early?
|
113
|
+
refute_same @station_data.early?, @station_data.late?
|
114
|
+
refute_same @station_data.early?, @station_data.on_time?
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_that_it_responds_to_on_time?
|
119
|
+
assert_respond_to @station_data, :on_time?
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_that_on_time_not_early_or_late
|
123
|
+
if @station_data.on_time?
|
124
|
+
refute_same @station_data.on_time?, @station_data.early?
|
125
|
+
refute_same @station_data.on_time?, @station_data.late?
|
126
|
+
end
|
127
|
+
end
|
82
128
|
end
|
data/test/unit/train.rb
CHANGED
@@ -2,13 +2,18 @@ $:.unshift(File.join(File.dirname(__FILE__), '..','..', 'lib'))
|
|
2
2
|
|
3
3
|
require_relative 'helper'
|
4
4
|
|
5
|
-
require 'minitest/autorun'
|
6
|
-
require 'ierail'
|
7
|
-
|
8
5
|
class TrainTest < MiniTest::Unit::TestCase
|
9
6
|
def setup
|
10
7
|
ir = IERail.new
|
11
|
-
|
8
|
+
|
9
|
+
VCR.configure do |c|
|
10
|
+
c.cassette_library_dir = 'fixtures/vcr_cassettes'
|
11
|
+
c.hook_into :webmock
|
12
|
+
end
|
13
|
+
|
14
|
+
VCR.use_cassette('trains') do
|
15
|
+
@train = ir.trains.sample #Use a random station
|
16
|
+
end
|
12
17
|
end
|
13
18
|
|
14
19
|
def test_that_a_train_has_status
|
@@ -32,7 +37,7 @@ class TrainTest < MiniTest::Unit::TestCase
|
|
32
37
|
end
|
33
38
|
|
34
39
|
def test_that_a_train_has_a_date
|
35
|
-
|
40
|
+
refute_nil @train.date
|
36
41
|
end
|
37
42
|
|
38
43
|
def test_that_a_train_has_a_message
|
data/test/unit/train_movement.rb
CHANGED
@@ -2,28 +2,40 @@ $:.unshift(File.join(File.dirname(__FILE__), '..','..', 'lib'))
|
|
2
2
|
|
3
3
|
require_relative 'helper'
|
4
4
|
|
5
|
-
require 'minitest/autorun'
|
6
|
-
require 'ierail'
|
7
|
-
|
8
5
|
class TrainMovementTest < MiniTest::Unit::TestCase
|
9
6
|
def setup
|
10
7
|
ir = IERail.new
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
|
9
|
+
VCR.configure do |c|
|
10
|
+
c.cassette_library_dir = 'fixtures/vcr_cassettes'
|
11
|
+
c.hook_into :webmock
|
12
|
+
end
|
13
|
+
|
14
|
+
VCR.use_cassette('trains') do
|
15
|
+
@train_code = ir.trains.first.code #Use a random train code
|
16
|
+
|
17
|
+
VCR.use_cassette('train_movements') do
|
18
|
+
# The hard-code of the Time here is to match the VCR cassette
|
19
|
+
# for this API call - otherwise we re-create all the fixtures,
|
20
|
+
# all the time, electrons squandered, early heat-death of
|
21
|
+
# universe ensues, exuent omnes, persued by entropy.
|
22
|
+
sample_t = Time.new(2014, 4, 19)
|
23
|
+
@train_movement = ir.train_movements(@train_code, sample_t).sample #Use a random movement from the random train
|
24
|
+
end
|
25
|
+
end
|
14
26
|
end
|
15
|
-
|
27
|
+
|
16
28
|
def test_that_location_method_returns_a_hash
|
17
29
|
assert_equal @train_movement.location.class, Hash
|
18
30
|
end
|
19
|
-
|
31
|
+
|
20
32
|
def test_that_there_is_a_location_code_and_name_and_stop_number_and_type
|
21
33
|
refute_empty @train_movement.location[:code]
|
22
34
|
refute_empty @train_movement.location[:name]
|
23
35
|
refute_nil @train_movement.location[:stop_number]
|
24
36
|
refute_empty @train_movement.location[:type]
|
25
37
|
end
|
26
|
-
|
38
|
+
|
27
39
|
def test_that_arrival_method_returns_a_hash
|
28
40
|
assert_equal @train_movement.arrival.class, Hash
|
29
41
|
end
|
@@ -33,7 +45,7 @@ class TrainMovementTest < MiniTest::Unit::TestCase
|
|
33
45
|
refute_nil @train_movement.arrival[:expected]
|
34
46
|
refute_nil @train_movement.arrival[:actual]
|
35
47
|
end
|
36
|
-
|
48
|
+
|
37
49
|
def test_that_departure_method_returns_a_hash
|
38
50
|
assert_equal @train_movement.departure.class, Hash
|
39
51
|
end
|
@@ -43,8 +55,18 @@ class TrainMovementTest < MiniTest::Unit::TestCase
|
|
43
55
|
refute_nil @train_movement.departure[:expected]
|
44
56
|
refute_nil @train_movement.departure[:actual]
|
45
57
|
end
|
46
|
-
|
58
|
+
|
47
59
|
def test_that_it_responds_to_station
|
48
60
|
assert_respond_to @train_movement, :station
|
49
61
|
end
|
50
|
-
|
62
|
+
|
63
|
+
def test_that_train_method_returns_a_hash
|
64
|
+
assert_equal @train_movement.train.class, Hash
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_that_there_is_a_train_code_date_and_origin
|
68
|
+
refute_nil @train_movement.train[:code]
|
69
|
+
refute_nil @train_movement.train[:date]
|
70
|
+
refute_nil @train_movement.train[:origin]
|
71
|
+
end
|
72
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ierail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oisin Hurley
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-04-
|
13
|
+
date: 2014-04-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -18,20 +18,20 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '1.
|
21
|
+
version: '1.8'
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 1.
|
24
|
+
version: 1.8.1
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
29
|
- - "~>"
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: '1.
|
31
|
+
version: '1.8'
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.
|
34
|
+
version: 1.8.1
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rest-client
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,40 +58,100 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
61
|
+
version: '1.6'
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 1.
|
64
|
+
version: 1.6.1
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - "~>"
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: '1.
|
71
|
+
version: '1.6'
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 1.
|
74
|
+
version: 1.6.1
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: tzinfo
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
81
|
+
version: '1.1'
|
82
82
|
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
84
|
+
version: 1.1.0
|
85
85
|
type: :runtime
|
86
86
|
prerelease: false
|
87
87
|
version_requirements: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: '
|
91
|
+
version: '1.1'
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 1.1.0
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: vcr
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '2.9'
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 2.9.0
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '2.9'
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 2.9.0
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: webmock
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '1.17'
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.17.4
|
125
|
+
type: :development
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.17'
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: 1.17.4
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: timecop
|
137
|
+
requirement: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - "~>"
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0.6'
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 0.6.2
|
145
|
+
type: :development
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0.6'
|
92
152
|
- - ">="
|
93
153
|
- !ruby/object:Gem::Version
|
94
|
-
version: 0.
|
154
|
+
version: 0.6.2
|
95
155
|
description: Irish Rail Train Schedule and Status API
|
96
156
|
email: oi.sin@nis.io
|
97
157
|
executables: []
|
@@ -106,6 +166,16 @@ files:
|
|
106
166
|
- LICENSE.txt
|
107
167
|
- README.md
|
108
168
|
- Rakefile
|
169
|
+
- fixtures/vcr_cassettes/find_station.yml
|
170
|
+
- fixtures/vcr_cassettes/northbound.yml
|
171
|
+
- fixtures/vcr_cassettes/southbound.yml
|
172
|
+
- fixtures/vcr_cassettes/southbound_from.yml
|
173
|
+
- fixtures/vcr_cassettes/station.yml
|
174
|
+
- fixtures/vcr_cassettes/station_times.yml
|
175
|
+
- fixtures/vcr_cassettes/stations.yml
|
176
|
+
- fixtures/vcr_cassettes/train_movements.yml
|
177
|
+
- fixtures/vcr_cassettes/trains.yml
|
178
|
+
- fixtures/vcr_cassettes/westbound.yml
|
109
179
|
- ierail.gemspec
|
110
180
|
- lib/core_ext.rb
|
111
181
|
- lib/ierail.rb
|