This repository has been archived by the owner on Nov 14, 2020. It is now read-only.
/
location_spec.rb
94 lines (67 loc) · 3.8 KB
/
location_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#
# This file is part of TSDBExplorer.
#
# TSDBExplorer is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# TSDBExplorer is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with TSDBExplorer. If not, see <http://www.gnu.org/licenses/>.
#
# $Id$
#
require 'spec_helper'
describe Location do
it "should identify locations that that are not for picking up or setting down passengers" do
TSDBExplorer::CIF::process_cif_file('test/fixtures/cif/activity_record_test.cif')
willesden_to_stratford = BasicSchedule.runs_on_by_uid_and_date('L97307', Date.parse('2011-05-22')).first
willesden_bay_to_high_level = willesden_to_stratford.locations.where(:tiploc_code => 'WLSDLUC').first
willesden_bay_to_high_level.is_public?.should_not be_true
willesden_bay_to_high_level.pickup_only?.should_not be_true
willesden_bay_to_high_level.setdown_only?.should_not be_true
end
it "should identify locations where the train picks up passengers only" do
TSDBExplorer::CIF::process_cif_file('test/fixtures/cif/activity_record_test.cif')
euston_to_wolverhampton = BasicSchedule.runs_on_by_uid_and_date('P64437', Date.parse('2011-05-22')).first
watford_junction = euston_to_wolverhampton.locations.where(:tiploc_code => 'WATFDJ').first
watford_junction.is_public?.should be_true
watford_junction.pickup_only?.should be_true
watford_junction.setdown_only?.should_not be_true
end
it "should identify locations where the train picks up and sets down passengers" do
TSDBExplorer::CIF::process_cif_file('test/fixtures/cif/activity_record_test.cif')
euston_to_wolverhampton = BasicSchedule.runs_on_by_uid_and_date('P64437', Date.parse('2011-05-22')).first
milton_keynes_central = euston_to_wolverhampton.locations.where(:tiploc_code => 'MKNSCEN').first
milton_keynes_central.is_public?.should be_true
milton_keynes_central.pickup_only?.should_not be_true
milton_keynes_central.setdown_only?.should_not be_true
end
it "should identify locations where the train sets down passengers only" do
TSDBExplorer::CIF::process_cif_file('test/fixtures/cif/activity_record_test.cif')
wolverhampton_to_euston = BasicSchedule.runs_on_by_uid_and_date('P64027', Date.parse('2011-05-22')).first
watford_junction = wolverhampton_to_euston.locations.where(:tiploc_code => 'WATFDJ').first
watford_junction.is_public?.should be_true
watford_junction.pickup_only?.should_not be_true
watford_junction.setdown_only?.should be_true
end
it "should return true if the schedule starts at this location" do
TSDBExplorer::CIF::process_cif_file('test/fixtures/cif/activity_record_test.cif')
willesden_to_stratford = BasicSchedule.runs_on_by_uid_and_date('L97307', Date.parse('2011-05-22')).first
willesden_ll_bay = willesden_to_stratford.locations.where(:tiploc_code => 'WLSDNJL').first
willesden_ll_bay.is_origin?.should be_true
willesden_ll_bay.is_destination?.should_not be_true
end
it "should return true if the schedule finishes at this location" do
TSDBExplorer::CIF::process_cif_file('test/fixtures/cif/activity_record_test.cif')
willesden_to_stratford = BasicSchedule.runs_on_by_uid_and_date('L97307', Date.parse('2011-05-22')).first
stratford = willesden_to_stratford.locations.where(:tiploc_code => 'STFD').first
stratford.is_origin?.should_not be_true
stratford.is_destination?.should be_true
end
end