ratis 3.1.0 → 3.1.1
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.
- data/.gitignore +6 -0
- data/.rspec +3 -0
- data/.rvmrc +1 -0
- data/CHANGELOG +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +89 -0
- data/Rakefile +8 -0
- data/lib/ratis/next_bus.rb +1 -1
- data/lib/ratis/next_bus2.rb +1 -1
- data/lib/ratis/schedule_nearby.rb +1 -1
- data/lib/ratis/version.rb +1 -1
- data/ratis.gemspec +33 -0
- data/spec/ratis/area_spec.rb +41 -0
- data/spec/ratis/closest_stop_spec.rb +99 -0
- data/spec/ratis/config_spec.rb +44 -0
- data/spec/ratis/core_ext_spec.rb +54 -0
- data/spec/ratis/itinerary_spec.rb +722 -0
- data/spec/ratis/landmark_category_spec.rb +46 -0
- data/spec/ratis/landmark_spec.rb +63 -0
- data/spec/ratis/location_spec.rb +207 -0
- data/spec/ratis/next_bus2_spec.rb +148 -0
- data/spec/ratis/next_bus_spec.rb +230 -0
- data/spec/ratis/pattern_spec.rb +122 -0
- data/spec/ratis/point_2_point_spec.rb +223 -0
- data/spec/ratis/request_spec.rb +132 -0
- data/spec/ratis/route_pattern_spec.rb +123 -0
- data/spec/ratis/route_spec.rb +75 -0
- data/spec/ratis/route_stops_spec.rb +82 -0
- data/spec/ratis/schedule_nearby_spec.rb +153 -0
- data/spec/ratis/timetable_spec.rb +115 -0
- data/spec/ratis/walk_spec.rb +72 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/support/ratis_helpers.rb +96 -0
- data/spec/support/vcr_cassettes/Point2Point.yml +200 -0
- metadata +64 -34
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ratis::Request do
|
4
|
+
before do
|
5
|
+
Ratis.reset
|
6
|
+
Ratis.configure do |config|
|
7
|
+
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-252/soap.cgi'
|
8
|
+
config.namespace = 'PX_WEB'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'new Requests get config from Ratis.configure block' do
|
13
|
+
it 'gets config from initializing' do
|
14
|
+
pending
|
15
|
+
Ratis::Request.client.wsdl.endpoint.should eql('http://soap.valleymetro.org/cgi-bin-soap-web-252/soap.cgi')
|
16
|
+
Ratis::Request.client.wsdl.namespace.should eql('PX_WEB')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'configured incorrectly' do
|
21
|
+
context 'without Ratis.configure being called' do
|
22
|
+
before do
|
23
|
+
Ratis.reset
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'raises an exception when initialized before configuring' do
|
27
|
+
expect do
|
28
|
+
Ratis::Request.get 'SomeAction'
|
29
|
+
end.to raise_error Ratis::Errors::ConfigError, 'It appears that Ratis.configure has not been called or properly setup'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe Ratis::Request do
|
36
|
+
describe '#get' do
|
37
|
+
before do
|
38
|
+
Ratis.reset
|
39
|
+
Ratis.configure do |config|
|
40
|
+
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-252/soap.cgi'
|
41
|
+
config.namespace = 'PX_WEB'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'with no parameters' do
|
46
|
+
it 'only makes one request with the correct SOAP action' do
|
47
|
+
|
48
|
+
Ratis::Request.client.should_receive(:request) do |action, options|
|
49
|
+
action.should eq('Mymethod')
|
50
|
+
options[:soap_action].should eq("PX_WEB#Mymethod")
|
51
|
+
options[:xmlns].should eq("PX_WEB")
|
52
|
+
end.once
|
53
|
+
|
54
|
+
Ratis::Request.get 'Mymethod'
|
55
|
+
Ratis::Request.client.rspec_reset
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'returns the response' do
|
59
|
+
response = Ratis::Request.get 'Getcategories'
|
60
|
+
response.should be_a(Savon::SOAP::Response)
|
61
|
+
response.should be_success
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'with parameters' do
|
66
|
+
it 'passes the parameters' do
|
67
|
+
response = Ratis::Request.get 'Point2point',
|
68
|
+
{"Routesonly" => true,
|
69
|
+
"Originlat" => 33.446931,
|
70
|
+
"Originlong" => -112.097903,
|
71
|
+
"Destinationlat" => 33.447098,
|
72
|
+
"Destinationlong" => -112.077213,
|
73
|
+
"Date" => Date.today.strftime("%m/%d/%Y"),
|
74
|
+
"Starttime" => '1700',
|
75
|
+
"Endtime" => '1800'}
|
76
|
+
|
77
|
+
response.should be_a(Savon::SOAP::Response)
|
78
|
+
response.should be_success
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'unsuccessful requests' do
|
83
|
+
describe 'connection refused' do
|
84
|
+
it 're-raises an ECONNREFUSED' do
|
85
|
+
Ratis::Request.client.should_receive(:request){ raise(Errno::ECONNREFUSED ) }
|
86
|
+
|
87
|
+
expect do
|
88
|
+
Ratis::Request.get 'Mymethod'
|
89
|
+
end.to raise_error Errno::ECONNREFUSED
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'with errorneous parameters' do
|
94
|
+
it 'parses out fault code and strings' do
|
95
|
+
begin
|
96
|
+
Ratis::Request.get 'Closeststop', {'Locationlat' => '1', 'Locationlong' => '1'}
|
97
|
+
|
98
|
+
rescue Ratis::Errors::SoapError => e
|
99
|
+
e.fault_code.should eql 15016
|
100
|
+
e.fault_string.should eql 'SOAP - invalid Locationtext'
|
101
|
+
e.verbose_fault_string.should eql 'Either the origin or destination could not be recognized by the server'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'raises an AtisError' do
|
106
|
+
expect do
|
107
|
+
Ratis::Request.get 'Mymethod'
|
108
|
+
end.to raise_error(Ratis::Errors::SoapError)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe Ratis::Request do
|
117
|
+
describe '#all_conditions_used?' do
|
118
|
+
it 'raises an exception if there are members in the hash' do
|
119
|
+
expect do
|
120
|
+
Ratis.all_conditions_used? :a => 1
|
121
|
+
|
122
|
+
end.to raise_error ArgumentError, 'Conditions not used by this class: [:a]'
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'does not raise an exception for an empty hash' do
|
126
|
+
expect do
|
127
|
+
Ratis.all_conditions_used? Hash.new
|
128
|
+
|
129
|
+
end.not_to raise_error
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ratis::RoutePattern do
|
4
|
+
before do
|
5
|
+
Ratis.reset
|
6
|
+
Ratis.configure do |config|
|
7
|
+
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-252/soap.cgi'
|
8
|
+
config.namespace = 'PX_WEB'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#where' do
|
13
|
+
|
14
|
+
before do
|
15
|
+
@today = Chronic.parse('tomorrow at 8am') # Time.now.strftime("%m/%d/%Y")
|
16
|
+
@conditions = {:route_short_name => '0',
|
17
|
+
:direction => 'N',
|
18
|
+
:date => @today,
|
19
|
+
:service_type => 'W',
|
20
|
+
:routeid => '83720' }
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'only makes one request' do
|
24
|
+
# false just to stop further processing of response
|
25
|
+
Ratis::Request.should_receive(:get).once.and_call_original
|
26
|
+
Ratis::RoutePattern.all(@conditions.dup)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'requests the correct SOAP action' do
|
30
|
+
Ratis::Request.should_receive(:get) do |action, options|
|
31
|
+
action.should eq('Routepattern')
|
32
|
+
options["Route"].should eq('0')
|
33
|
+
options["Direction"].should eq('N')
|
34
|
+
options["Date"].should eq(@today)
|
35
|
+
options["Servicetype"].should eq('W')
|
36
|
+
options["Routeid"].should eq('83720')
|
37
|
+
|
38
|
+
end.and_return(double('response', :success? => false))
|
39
|
+
|
40
|
+
Ratis::RoutePattern.all(@conditions.dup)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should return a collection Ratis::RoutePattern::Stop(s)' do
|
44
|
+
routepattern = Ratis::RoutePattern.all(@conditions.dup)
|
45
|
+
routepattern.stops.each do |obj|
|
46
|
+
expect(obj).to be_a(Ratis::RoutePattern::Stop)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should return a collection Ratis::RoutePattern::Point(s)' do
|
52
|
+
routepattern = Ratis::RoutePattern.all(@conditions.dup)
|
53
|
+
routepattern.points.each do |obj|
|
54
|
+
expect(obj).to be_a(Ratis::RoutePattern::Point)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should parse the stop fields' do
|
60
|
+
routepattern = Ratis::RoutePattern.all(@conditions.dup)
|
61
|
+
stop = routepattern.stops.first
|
62
|
+
|
63
|
+
expect(stop.desc).to eq('CENTRAL AVE & DOBBINS RD')
|
64
|
+
expect(stop.area).to eq('Phoenix')
|
65
|
+
expect(stop.atisid).to eq('3317')
|
66
|
+
expect(stop.stopid).to eq('10050')
|
67
|
+
expect(stop.point).to eq("33.36369,-112.07319")
|
68
|
+
expect(stop.lat).to eq('33.36369')
|
69
|
+
expect(stop.lng).to eq('-112.07319')
|
70
|
+
expect(stop.boardflag).to eq('E')
|
71
|
+
expect(stop.timepoint).to eq('Y')
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should raise error for missing arg route_short_name" do
|
75
|
+
conditions = @conditions.dup
|
76
|
+
conditions.delete(:route_short_name)
|
77
|
+
|
78
|
+
expect do
|
79
|
+
Ratis::RoutePattern.all(conditions)
|
80
|
+
end.to raise_error(ArgumentError, 'You must provide a route_short_name')
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should raise error for missing arg direction" do
|
84
|
+
conditions = @conditions.dup
|
85
|
+
conditions.delete(:direction)
|
86
|
+
|
87
|
+
expect do
|
88
|
+
Ratis::RoutePattern.all(conditions)
|
89
|
+
end.to raise_error(ArgumentError, 'You must provide a direction')
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should raise error for missing arg date" do
|
93
|
+
conditions = @conditions.dup
|
94
|
+
conditions.delete(:date)
|
95
|
+
|
96
|
+
expect do
|
97
|
+
Ratis::RoutePattern.all(conditions)
|
98
|
+
end.to raise_error(ArgumentError, 'You must provide a date')
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should raise error for missing arg service_type" do
|
102
|
+
conditions = @conditions.dup
|
103
|
+
conditions.delete(:service_type)
|
104
|
+
|
105
|
+
expect do
|
106
|
+
Ratis::RoutePattern.all(conditions)
|
107
|
+
end.to raise_error(ArgumentError, 'You must provide a service_type')
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should raise error for missing arg routeid" do
|
111
|
+
conditions = @conditions.dup
|
112
|
+
conditions.delete(:routeid)
|
113
|
+
|
114
|
+
expect do
|
115
|
+
Ratis::RoutePattern.all(conditions)
|
116
|
+
end.to raise_error(ArgumentError, 'You must provide a routeid')
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ratis::Route do
|
4
|
+
before do
|
5
|
+
Ratis.reset
|
6
|
+
Ratis.configure do |config|
|
7
|
+
config.endpoint = 'http://example.com/soap.cgi'
|
8
|
+
config.namespace = 'TEST_NS'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#all' do
|
13
|
+
|
14
|
+
before do
|
15
|
+
stub_atis_request.to_return( atis_response 'Allroutes', '1.5', '0', <<-BODY )
|
16
|
+
<Routes>
|
17
|
+
0, N, S
|
18
|
+
1, E, W
|
19
|
+
</Routes>
|
20
|
+
BODY
|
21
|
+
|
22
|
+
@all_routes = Ratis::Route.all
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'only makes one request' do
|
26
|
+
an_atis_request.should have_been_made.times 1
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'gets all routes' do
|
30
|
+
@all_routes.should have(2).items
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'gets all route directions' do
|
34
|
+
@all_routes.each do |route|
|
35
|
+
route.should have(2).directions
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#timetable' do
|
42
|
+
|
43
|
+
let(:route) { Ratis::Route.new '0', ['N', 'S'] }
|
44
|
+
|
45
|
+
before do
|
46
|
+
resp = atis_response_timetable({ :route => '0', :direction => 'N', :service_type => 'W', :operator => 'OP', :effective => '01/15/12' })
|
47
|
+
stub_atis_request.to_return( atis_response 'Timetable', '1.1', '0', resp)
|
48
|
+
|
49
|
+
@timetable = route.timetable :direction => 'N', :service_type => 'W'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'only makes one request' do
|
53
|
+
an_atis_request.should have_been_made.times 1
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'assigns settings correctly' do
|
57
|
+
@timetable.should_not be_nil
|
58
|
+
|
59
|
+
@timetable.route_short_name.should eql '0'
|
60
|
+
@timetable.direction.should eql 'N'
|
61
|
+
@timetable.service_type.should eql 'W'
|
62
|
+
@timetable.operator.should eql 'OP'
|
63
|
+
@timetable.effective.should eql '01/15/12'
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should initialize' do
|
69
|
+
route = Ratis::Route.new '123', ['N', 'S']
|
70
|
+
|
71
|
+
route.short_name.should eql '123'
|
72
|
+
route.directions.should eql ['N', 'S']
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ratis::RouteStops do
|
4
|
+
before do
|
5
|
+
Ratis.reset
|
6
|
+
Ratis.configure do |config|
|
7
|
+
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-252/soap.cgi'
|
8
|
+
config.namespace = 'PX_WEB'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#all' do
|
13
|
+
|
14
|
+
before do
|
15
|
+
@today = Time.now.strftime("%m/%d/%Y")
|
16
|
+
@conditions = {:route => '0',
|
17
|
+
:direction => 'N',
|
18
|
+
:order => 'A' }
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'only makes one request' do
|
22
|
+
# false just to stop further processing of response
|
23
|
+
Ratis::Request.should_receive(:get).once.and_call_original
|
24
|
+
Ratis::RouteStops.all(@conditions.dup)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'requests the correct SOAP action with correct args' do
|
28
|
+
Ratis::Request.should_receive(:get) do |action, options|
|
29
|
+
action.should eq('Routestops')
|
30
|
+
options["Route"].should eq('0')
|
31
|
+
options["Direction"].should eq('N')
|
32
|
+
options["Order"].should eq('A')
|
33
|
+
|
34
|
+
end.and_return(double('response', :success? => false))
|
35
|
+
|
36
|
+
Ratis::RouteStops.all(@conditions.dup)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should return a collection of Ratis::RouteStops::Stop(s)' do
|
40
|
+
route_stops = Ratis::RouteStops.all(@conditions.dup)
|
41
|
+
route_stops.each do |obj|
|
42
|
+
expect(obj).to be_a(Ratis::RouteStops::Stop)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'parses out the stop fields correctly' do
|
47
|
+
route_stops = Ratis::RouteStops.all(@conditions.dup)
|
48
|
+
stop = route_stops.first
|
49
|
+
|
50
|
+
expect(stop.description).to eq('CENTRAL AVE & ADAMS ST')
|
51
|
+
expect(stop.area).to eq('Phoenix')
|
52
|
+
expect(stop.atis_stop_id).to eq('2854')
|
53
|
+
expect(stop.stop_seq).to eq('24')
|
54
|
+
expect(stop.stop_id).to be_nil
|
55
|
+
expect(stop.point).to be_nil
|
56
|
+
expect(stop.alpha_seq).to be_nil
|
57
|
+
expect(stop.latitude).to eq('33.448994')
|
58
|
+
expect(stop.longitude).to eq('-112.073813')
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should raise error for missing arg route" do
|
62
|
+
conditions = @conditions.dup
|
63
|
+
conditions.delete(:route)
|
64
|
+
|
65
|
+
expect do
|
66
|
+
Ratis::RouteStops.all(conditions)
|
67
|
+
end.to raise_error(ArgumentError, 'You must provide a route')
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should raise error for missing arg direction" do
|
71
|
+
conditions = @conditions.dup
|
72
|
+
conditions.delete(:direction)
|
73
|
+
|
74
|
+
expect do
|
75
|
+
Ratis::RouteStops.all(conditions)
|
76
|
+
end.to raise_error(ArgumentError, 'You must provide a direction')
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
@@ -0,0 +1,153 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ratis::ScheduleNearby do
|
4
|
+
before do
|
5
|
+
Ratis.reset
|
6
|
+
Ratis.configure do |config|
|
7
|
+
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-252/soap.cgi'
|
8
|
+
config.namespace = 'PX_WEB'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#where' do
|
13
|
+
before do
|
14
|
+
@today = Time.now.strftime("%m/%d/%Y")
|
15
|
+
@conditions = {:latitude => '33.4556',
|
16
|
+
:longitude => '-112.071807',
|
17
|
+
:date => @today,
|
18
|
+
:time => '1323',
|
19
|
+
:window => '60',
|
20
|
+
:walk_distance => '0.18',
|
21
|
+
:landmark_id => '0',
|
22
|
+
:stop_id => nil,
|
23
|
+
:app_id => 'na' }
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'only makes one request' do
|
27
|
+
# false just to stop further processing of response
|
28
|
+
Ratis::Request.should_receive(:get).once.and_call_original
|
29
|
+
Ratis::ScheduleNearby.where(@conditions.dup)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should return no data error when date is in the past' do
|
33
|
+
old_date_conditions = @conditions.merge(:date => '01/28/2012')
|
34
|
+
expect do
|
35
|
+
Ratis::ScheduleNearby.where(old_date_conditions)
|
36
|
+
end.to raise_error(Ratis::Errors::SoapError, "#20005--No service at origin at the date/time specified")
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'requests the correct SOAP action with correct args' do
|
40
|
+
Ratis::Request.should_receive(:get) do |action, options|
|
41
|
+
action.should eq('Schedulenearby')
|
42
|
+
options["Locationlat"].should eq(@conditions[:latitude])
|
43
|
+
options["Locationlong"].should eq(@conditions[:longitude])
|
44
|
+
options["Date"].should eq(@conditions[:date])
|
45
|
+
options["Time"].should eq(@conditions[:time])
|
46
|
+
options["Window"].should eq(@conditions[:window])
|
47
|
+
options["Walkdist"].should eq(@conditions[:walk_distance])
|
48
|
+
options["Landmarkid"].should eq(@conditions[:landmark_id])
|
49
|
+
options["Stopid"].should eq('')
|
50
|
+
options["Appid"].should eq(@conditions[:app_id])
|
51
|
+
|
52
|
+
end.and_return(double('response', :success? => false))
|
53
|
+
|
54
|
+
Ratis::ScheduleNearby.where(@conditions.dup)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'returns a non nil ScheduleNearby' do
|
58
|
+
Ratis::ScheduleNearby.where(@conditions.dup).should_not be_nil
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'returns all the stops' do
|
62
|
+
Ratis::ScheduleNearby.where(@conditions.dup).atstops.should have(3).items
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'returns a single service at the stop' do
|
66
|
+
Ratis::ScheduleNearby.where(@conditions.dup).atstops.first[:services].should have(1).item
|
67
|
+
end
|
68
|
+
|
69
|
+
describe 'with single service' do
|
70
|
+
describe 'with a single trip' do
|
71
|
+
describe '#to_hash' do
|
72
|
+
|
73
|
+
it 'returns a subset of Schedule params' do
|
74
|
+
pending('find a call that returns less results')
|
75
|
+
hash =
|
76
|
+
{ :atstops=>
|
77
|
+
[
|
78
|
+
{ :walkdir=>"NW", :walkdist=>"0.41", :description=>"ROOSEVELT/CENTRAL AVE LIGHT RAIL STATION",
|
79
|
+
:lat=>"33.459821", :stopid=>"10011", :heading => "NB", :long=>"-112.073847",
|
80
|
+
:services=>[
|
81
|
+
{ :routetype=>"L", :times=>"12:10 AM", :operator=>"LRT",
|
82
|
+
:route=>"LTRL", :sign=>"Metro light rail To 44th St/Washington",
|
83
|
+
:trips=> [ { :triptime=>"12:10 AM"} ],
|
84
|
+
}
|
85
|
+
]
|
86
|
+
}
|
87
|
+
]
|
88
|
+
}
|
89
|
+
|
90
|
+
HashDiff.diff(Ratis::ScheduleNearby.where(@conditions.dup), hash).should eql []
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
describe 'two stops nearby' do
|
101
|
+
|
102
|
+
describe 'each with two services' do
|
103
|
+
|
104
|
+
describe '#to_hash' do
|
105
|
+
|
106
|
+
it 'returns a subset of Schedule params' do
|
107
|
+
pending
|
108
|
+
hash =
|
109
|
+
{ :atstops=>
|
110
|
+
[
|
111
|
+
{ :walkdir=>"W", :walkdist=>"0.05", :description=>"1ST AVE & VAN BUREN ST",
|
112
|
+
:lat=>"33.451748", :stopid=>"10161", :heading=>"SB", :long=>"-112.075169",
|
113
|
+
:services=>[
|
114
|
+
{ :routetype=>"B", :times=>"12:40 PM, 01:00 PM", :operator=>"AP",
|
115
|
+
:route=>"0", :sign=>"0 CENTRAL South to Dobbins",
|
116
|
+
:trips=> [ { :triptime=>"12:40 PM" }, { :triptime=>"01:00 PM" } ]
|
117
|
+
},
|
118
|
+
{ :routetype=>"B", :times=>"01:30 PM, 01:45 PM", :operator=>"AP",
|
119
|
+
:route=>"0", :sign=>"0 Central South To Baseline Rd",
|
120
|
+
:trips=> [ { :triptime=>"01:30 PM" }, { :triptime=>"01:45 PM" } ]
|
121
|
+
}
|
122
|
+
]
|
123
|
+
},
|
124
|
+
{ :walkdir=>"SW", :walkdist=>"0.09", :description=>"VAN BUREN ST & 1ST AVE",
|
125
|
+
:lat=>"33.451367", :stopid=>"10342", :heading=>"EB", :long=>"-112.075485",
|
126
|
+
:services=>[
|
127
|
+
{ :routetype=>"B", :times=>"12:59 PM, 01:29 PM", :operator=>"FT",
|
128
|
+
:route=>"3", :sign=>"3 VAN BUREN East to 48th St.",
|
129
|
+
:trips=> [ { :triptime=>"12:59 PM" }, { :triptime=>"01:29 PM" } ]
|
130
|
+
},
|
131
|
+
{ :routetype=>"B", :times=>"12:44 PM, 01:14 PM", :operator=>"FT",
|
132
|
+
:route=>"3", :sign=>"3 VAN BUREN East to Phoenix Zoo",
|
133
|
+
:trips=> [ { :triptime=>"12:44 PM" }, { :triptime=>"01:14 PM" } ]
|
134
|
+
}
|
135
|
+
]
|
136
|
+
}
|
137
|
+
]
|
138
|
+
}
|
139
|
+
|
140
|
+
HashDiff.diff(@schedule_nearby.to_hash, hash).should eql []
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|