amtrak 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3eba83171c15751acc34cfca614a5fb542cb4137
4
- data.tar.gz: b299e5b1d3c52f60066b5792ad9ac25547a3c4a3
3
+ metadata.gz: 5e6f2af5819b3bc8d69a509b5424ac1642ca3225
4
+ data.tar.gz: 9acdc2c34c1205a12ead90465939c796f4f0bc53
5
5
  SHA512:
6
- metadata.gz: 690330fcc13bd7b00e67d76560b1349b9cebb73627794c4b0d1cf7c7d88aa86dda80a4f6553a7ab5916c0e3dc5e82b0ea02ab18742accdc20040d2567107b80b
7
- data.tar.gz: b5bf6dd747477bcc3b55d5971a4c55c38c05a7f4cdc109111d2ce64401546d9926a61c8e5ac0d091a148746e8d87b569f1bedabdb9fcfe87aca7173c7e4d17c9
6
+ metadata.gz: 7eabdc4126fd285c7bf630de6f1678a5875a0cf5d7b7b22107f0f054176003138fa87d201393bf2d4e781ffce3ebe4bcc39a2b90e56c8216037ebcaaa2edb95b
7
+ data.tar.gz: 46551c2535e81286c55a9b04a868fa667409a65a3520a608c2f72a15b7e542714e6078da05a0e9ebfbedca0f9f11d0a4bfd7bf480906f7c31e8474c8ad0baeee
@@ -15,7 +15,7 @@ module Amtrak
15
15
  end
16
16
 
17
17
  def parse
18
- json['journeys']
18
+ (json['journeys'] || [])
19
19
  .map(&method(:parse_journey))
20
20
  .compact
21
21
  end
@@ -1,6 +1,6 @@
1
1
  module Amtrak
2
2
  # This module holds the Amtrak version
3
3
  module Version
4
- VERSION = '3.0.1'.freeze
4
+ VERSION = '3.0.2'.freeze
5
5
  end
6
6
  end
@@ -28,5 +28,25 @@ describe Amtrak::TrainParser do
28
28
  it 'returns a list of train times' do
29
29
  expect(output).to eq(expected)
30
30
  end
31
+
32
+ context 'when the train status is unavailable' do
33
+ let(:document) do
34
+ File.read(File.join('spec', 'fixtures', 'json', 'unavailable.json'))
35
+ end
36
+
37
+ it 'does not return any trains' do
38
+ expect(output).to eq([])
39
+ end
40
+ end
41
+
42
+ context 'when the train is not operated by amtrak' do
43
+ let(:document) do
44
+ File.read(File.join('spec', 'fixtures', 'json', 'not_operated_by_amtrak.json'))
45
+ end
46
+
47
+ it 'does not return any trains' do
48
+ expect(output).to eq([])
49
+ end
50
+ end
31
51
  end
32
52
  end
@@ -0,0 +1,16 @@
1
+ {
2
+ "appVersion": "1.51",
3
+ "authenticationToken": null,
4
+ "buildNumber": "1.51_20170909.0300",
5
+ "errors": [
6
+ {
7
+ "ariesMessage": "011NO TRAIN SERVICE FOR THIS DATE",
8
+ "code": "3",
9
+ "text": "The train number provided is not operated by Amtrak. Please check the number or try a search using two stations. [011A]",
10
+ "type": "3"
11
+ }
12
+ ],
13
+ "hostName": "ussbpri021amtra",
14
+ "infoNotification": null,
15
+ "responseCode": "ERROR"
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "appVersion": "1.51",
3
+ "authenticationToken": null,
4
+ "buildNumber": "1.51_20170909.0300",
5
+ "errors": [
6
+ {
7
+ "ariesMessage": "008INVALID DATE 09OCT",
8
+ "code": "15",
9
+ "text": "Train Status is currently unavailable. Please try again later [R412]",
10
+ "type": "3"
11
+ }
12
+ ],
13
+ "hostName": "ussbpri031amtra",
14
+ "infoNotification": null,
15
+ "responseCode": "ERROR"
16
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amtrak
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Lunter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-13 00:00:00.000000000 Z
11
+ date: 2017-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -146,7 +146,9 @@ files:
146
146
  - spec/amtrak_spec.rb
147
147
  - spec/fixtures/json/_get.json
148
148
  - spec/fixtures/json/_parse.json
149
+ - spec/fixtures/json/not_operated_by_amtrak.json
149
150
  - spec/fixtures/json/pvd_to_bby.json
151
+ - spec/fixtures/json/unavailable.json
150
152
  - spec/fixtures/vcr/Amtrak/_get/returns_a_list_of_train_times.yml
151
153
  - spec/fixtures/vcr/Amtrak_TrainFetcher/_get/does_the_same_as_get.yml
152
154
  - spec/fixtures/vcr/Amtrak_TrainFetcher/_get/given_a_valid_date_and_invalid_train_stations/does_not_include_various_keys_and_includes_an_error.yml
@@ -184,7 +186,9 @@ test_files:
184
186
  - spec/amtrak_spec.rb
185
187
  - spec/fixtures/json/_get.json
186
188
  - spec/fixtures/json/_parse.json
189
+ - spec/fixtures/json/not_operated_by_amtrak.json
187
190
  - spec/fixtures/json/pvd_to_bby.json
191
+ - spec/fixtures/json/unavailable.json
188
192
  - spec/fixtures/vcr/Amtrak/_get/returns_a_list_of_train_times.yml
189
193
  - spec/fixtures/vcr/Amtrak_TrainFetcher/_get/does_the_same_as_get.yml
190
194
  - spec/fixtures/vcr/Amtrak_TrainFetcher/_get/given_a_valid_date_and_invalid_train_stations/does_not_include_various_keys_and_includes_an_error.yml