ratis 3.4.3 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG +40 -39
- data/README.md +1 -15
- data/lib/ratis/area.rb +1 -1
- data/lib/ratis/config.rb +2 -4
- data/lib/ratis/fleet_location.rb +2 -7
- data/lib/ratis/landmark.rb +1 -4
- data/lib/ratis/location.rb +1 -3
- data/lib/ratis/location_type_ahead.rb +1 -4
- data/lib/ratis/next_bus.rb +0 -2
- data/lib/ratis/next_bus2.rb +1 -3
- data/lib/ratis/plantrip.rb +1 -3
- data/lib/ratis/request.rb +5 -2
- data/lib/ratis/schedule_nearby.rb +1 -3
- data/lib/ratis/timetable.rb +1 -5
- data/lib/ratis/version.rb +1 -1
- data/lib/ratis/walkstop.rb +1 -3
- data/ratis.gemspec +15 -15
- data/spec/ratis/area_spec.rb +1 -10
- data/spec/ratis/closest_stop_spec.rb +0 -14
- data/spec/ratis/config_spec.rb +21 -30
- data/spec/ratis/core_ext_spec.rb +0 -11
- data/spec/ratis/fleet_location_spec.rb +8 -25
- data/spec/ratis/itinerary_spec.rb +0 -10
- data/spec/ratis/landmark_category_spec.rb +1 -12
- data/spec/ratis/landmark_spec.rb +12 -25
- data/spec/ratis/location_spec.rb +5 -16
- data/spec/ratis/location_type_ahead_item_spec.rb +11 -9
- data/spec/ratis/location_type_ahead_spec.rb +7 -21
- data/spec/ratis/next_bus2_spec.rb +67 -81
- data/spec/ratis/next_bus_spec.rb +20 -37
- data/spec/ratis/pattern_spec.rb +2 -10
- data/spec/ratis/plantrip_spec.rb +19 -18
- data/spec/ratis/point_2_point_spec.rb +3 -11
- data/spec/ratis/request_spec.rb +1 -20
- data/spec/ratis/route_pattern_spec.rb +2 -14
- data/spec/ratis/route_spec.rb +1 -10
- data/spec/ratis/route_stops_spec.rb +1 -10
- data/spec/ratis/routes_spec.rb +1 -9
- data/spec/ratis/schedule_nearby_spec.rb +1 -11
- data/spec/ratis/timetable_spec.rb +24 -44
- data/spec/ratis/walkstop_spec.rb +22 -47
- data/spec/spec_helper.rb +4 -3
- data/spec/support/vcr_cassettes/Nextbus2_running_LATE.yml +141 -1
- data/spec/support/vcr_cassettes/Nextbus_running_LATE.yml +2 -2
- data/spec/support/vcr_cassettes/Point2Point.yml +2 -2
- data/spec/support/vcr_cassettes/Ratis_Area/_all/only_makes_one_request.yml +19 -9
- data/spec/support/vcr_cassettes/Ratis_ClosestStop/_where/only_makes_one_request.yml +9 -9
- data/spec/support/vcr_cassettes/Ratis_ClosestStop/_where/parses_out_the_stop_fields_correctly.yml +9 -9
- data/spec/support/vcr_cassettes/Ratis_ClosestStop/_where/returns_multiple_locations.yml +9 -9
- data/spec/support/vcr_cassettes/Ratis_ClosestStop/_where/should_return_a_collection_of_Ratis_Stop_s_.yml +9 -9
- data/spec/support/vcr_cassettes/Ratis_FleetLocation/_current/only_makes_one_request.yml +661 -563
- data/spec/support/vcr_cassettes/Ratis_FleetLocation/_current/parses_out_the_vehicle_fields_correctly.yml +661 -584
- data/spec/support/vcr_cassettes/Ratis_FleetLocation/_current/returns_multiple_vehicles.yml +661 -575
- data/spec/support/vcr_cassettes/Ratis_FleetLocation/_current/should_return_a_collection_of_Ratis_Vehicle_s_.yml +661 -575
- data/spec/support/vcr_cassettes/Ratis_Landmark/_where/only_makes_one_request.yml +67 -1444
- data/spec/support/vcr_cassettes/Ratis_Landmark/_where/parses_out_the_landmark_fields_correctly.yml +67 -1444
- data/spec/support/vcr_cassettes/Ratis_Landmark/_where/returns_multiple_landmarks.yml +67 -1444
- data/spec/support/vcr_cassettes/Ratis_Landmark/_where/should_return_a_collection_of_Ratis_Landmark_s_.yml +67 -1444
- data/spec/support/vcr_cassettes/Ratis_LandmarkCategory/_all/only_makes_one_request.yml +9 -9
- data/spec/support/vcr_cassettes/Ratis_LandmarkCategory/_all/should_return_a_collection_of_Ratis_LandmarkCategory_s_.yml +9 -9
- data/spec/support/vcr_cassettes/Ratis_LandmarkCategory/_all/should_return_all_landmark_categories.yml +9 -9
- data/spec/support/vcr_cassettes/Ratis_LandmarkCategory/_web_categories/does_something.yml +9 -9
- data/spec/support/vcr_cassettes/Ratis_Location/_where/only_makes_one_request.yml +11 -11
- data/spec/support/vcr_cassettes/Ratis_Location/_where/parses_out_fields_correctly.yml +11 -11
- data/spec/support/vcr_cassettes/Ratis_Location/_where/should_return_a_collection_of_Ratis_Location_s_.yml +11 -11
- data/spec/support/vcr_cassettes/Ratis_LocationTypeAhead/_where/only_makes_one_request.yml +10 -10
- data/spec/support/vcr_cassettes/Ratis_LocationTypeAhead/_where/parses_out_fields_correctly.yml +10 -10
- data/spec/support/vcr_cassettes/Ratis_LocationTypeAhead/_where/should_return_a_collection_of_Ratis_LocationTypeAheadItem_s_.yml +10 -10
- data/spec/support/vcr_cassettes/Ratis_NextBus/_where/multiple_services_returned/only_makes_one_request.yml +29 -28
- data/spec/support/vcr_cassettes/Ratis_NextBus/_where/multiple_services_returned/returns_the_next_4_bus_times.yml +29 -28
- data/spec/support/vcr_cassettes/Ratis_NextBus/_where/multiple_services_returned/should_map_all_the_services_to_service_openstruct_objects.yml +29 -28
- data/spec/support/vcr_cassettes/Ratis_NextBus/_where/multiple_services_returned/should_raise_error_if_datetime_condition_is_not_a_DateTime_or_Time.yml +62 -80
- data/spec/support/vcr_cassettes/Ratis_NextBus/_where/single_service_return/only_makes_one_request.yml +18 -17
- data/spec/support/vcr_cassettes/Ratis_NextBus/_where/single_service_return/returns_the_next_bus_times.yml +18 -17
- data/spec/support/vcr_cassettes/Ratis_NextBus/_where/single_service_return/should_raise_error_if_datetime_condition_is_not_a_DateTime_or_Time.yml +52 -52
- data/spec/support/vcr_cassettes/Ratis_NextBus/_where/single_service_return/should_set_all_the_service_values_to_instance_vars.yml +18 -17
- data/spec/support/vcr_cassettes/Ratis_NextBus2/_where/runs/should_set_the_run_values_to_instance_vars.yml +125 -0
- data/spec/support/vcr_cassettes/Ratis_NextBus2/_where/single_next_bus/only_makes_one_request.yml +125 -0
- data/spec/support/vcr_cassettes/Ratis_NextBus2/_where/single_next_bus/requests_the_correct_SOAP_action.yml +125 -0
- data/spec/support/vcr_cassettes/Ratis_NextBus2/_where/stops/should_set_the_stop_values_to_instance_vars.yml +125 -0
- data/spec/support/vcr_cassettes/Ratis_Pattern/_all/only_makes_one_request.yml +12 -12
- data/spec/support/vcr_cassettes/Ratis_Pattern/_all/should_parse_the_route_info_fields.yml +12 -12
- data/spec/support/vcr_cassettes/Ratis_Pattern/_all/should_return_a_collection_Pattern_RouteInfo_s_.yml +12 -12
- data/spec/support/vcr_cassettes/Ratis_Pattern/_all/should_return_no_data_error_when_date_is_in_the_past.yml +5 -5
- data/spec/support/vcr_cassettes/Ratis_Plantrip/_where/creates_Ratis_Itineraries_for_each_trip_itinerary.yml +30 -30
- data/spec/support/vcr_cassettes/Ratis_Plantrip/_where/only_makes_one_request.yml +30 -30
- data/spec/support/vcr_cassettes/Ratis_Plantrip/_where/returns_a_Plantrip_object.yml +30 -30
- data/spec/support/vcr_cassettes/Ratis_Plantrip/_where/should_set_all_the_Plantrip_values_to_instance_vars.yml +30 -30
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/gets_the_groups.yml +68 -74
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/gets_the_trips_within_each_group.yml +68 -74
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/only_makes_one_request.yml +68 -74
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/parses_out_the_off_stop_fields.yml +68 -74
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/parses_out_the_on_stop_fields.yml +68 -74
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/parses_out_the_service.yml +68 -74
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/parses_out_the_trip.yml +68 -74
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/should_only_return_result_groups_for_filtered_route.yml +15 -17
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/should_only_return_result_groups_for_filtered_routes.yml +19 -21
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/should_raise_error_if_the_trip_is_NOT_possible_for_a_route_being_attempted_to_filter_on.yml +5 -5
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_Y/_where/services_from_origin_to_destination/only_makes_one_request.yml +29 -29
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_Y/_where/services_from_origin_to_destination/parses_out_service_fields.yml +29 -29
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_Y/_where/services_from_origin_to_destination/returns_a_routes_only_response_for_each_matched_service.yml +29 -29
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_Y/_where/services_from_origin_to_destination/returns_all_matching_services_that_fit_the_origin/destination_for_a_given_time_frame.yml +29 -29
- data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_Y/_where/services_from_origin_to_destination/should_NOT_filter_by_passed_in_routes.yml +29 -29
- data/spec/support/vcr_cassettes/Ratis_RoutePattern/_where/only_makes_one_request.yml +133 -70
- data/spec/support/vcr_cassettes/Ratis_RoutePattern/_where/should_parse_the_stop_fields.yml +133 -70
- data/spec/support/vcr_cassettes/Ratis_RoutePattern/_where/should_return_a_collection_Ratis_RoutePattern_Point_s_.yml +132 -69
- data/spec/support/vcr_cassettes/Ratis_RoutePattern/_where/should_return_a_collection_Ratis_RoutePattern_Stop_s_.yml +133 -70
- data/spec/support/vcr_cassettes/Ratis_RouteStops/_all/only_makes_one_request.yml +50 -50
- data/spec/support/vcr_cassettes/Ratis_RouteStops/_all/parses_out_the_stop_fields_correctly.yml +50 -50
- data/spec/support/vcr_cassettes/Ratis_RouteStops/_all/should_return_a_collection_of_Ratis_RouteStops_Stop_s_.yml +50 -50
- data/spec/support/vcr_cassettes/Ratis_Routes/_all/only_makes_one_request.yml +346 -370
- data/spec/support/vcr_cassettes/Ratis_Routes/_all/returns_all_routes.yml +346 -370
- data/spec/support/vcr_cassettes/Ratis_Routes/_all/should_set_directions_and_short_name_to_variables.yml +346 -370
- data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/only_makes_one_request.yml +42 -41
- data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/returns_a_non_nil_ScheduleNearby.yml +42 -41
- data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/returns_a_single_service_at_the_stop.yml +42 -41
- data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/returns_all_the_stops.yml +42 -41
- data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/should_return_no_data_error_when_date_is_in_the_past.yml +5 -5
- data/spec/support/vcr_cassettes/Ratis_Timetable/_where/ATIS_call/should_not_throw_a_500.yml +719 -0
- data/spec/support/vcr_cassettes/Ratis_Timetable/_where/only_makes_one_request.yml +315 -315
- data/spec/support/vcr_cassettes/Ratis_Timetable/_where/should_parse_the_timetable/stop/trip_fields.yml +315 -315
- data/spec/support/vcr_cassettes/Ratis_Timetable/_where/should_return_a_collection_Timetable_Stop_s_.yml +315 -315
- data/spec/support/vcr_cassettes/Ratis_Walkstop/_where/only_makes_one_request.yml +9 -9
- data/spec/support/vcr_cassettes/Ratis_Walkstop/_where/should_set_all_the_walkstop_values_to_instance_vars.yml +9 -9
- metadata +9 -9
- data/.rvmrc +0 -1
- data/spec/support/vcr_cassettes/Ratis_LocationTypeAhead/_where/should_return_a_collection_of_Ratis_Location_s_.yml +0 -54
- data/spec/support/vcr_cassettes/Ratis_NextBus2/_where/Developer_can_find_a_late_bus_to_a_stop/runs/should_set_the_run_values_to_instance_vars.yml +0 -180
- data/spec/support/vcr_cassettes/Ratis_NextBus2/_where/Developer_can_find_a_late_bus_to_a_stop/single_next_bus/only_makes_one_request.yml +0 -180
- data/spec/support/vcr_cassettes/Ratis_NextBus2/_where/Developer_can_find_a_late_bus_to_a_stop/single_next_bus/requests_the_correct_SOAP_action.yml +0 -180
- data/spec/support/vcr_cassettes/Ratis_NextBus2/_where/Developer_can_find_a_late_bus_to_a_stop/stops/should_set_the_stop_values_to_instance_vars.yml +0 -180
@@ -1,15 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ratis::NextBus2 do
|
4
|
-
|
5
|
-
Ratis.reset
|
6
|
-
Ratis.configure do |config|
|
7
|
-
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-262/soap.cgi'
|
8
|
-
config.namespace = 'PX_WEB'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
let(:empty_body){ {:nextbus_response => {:atstop => {:service => []}}} }
|
4
|
+
let(:empty_body) { {:nextbus_response => {:atstop => {:service => []}}} }
|
13
5
|
|
14
6
|
describe '#where', vcr: {} do
|
15
7
|
before do
|
@@ -17,8 +9,7 @@ describe Ratis::NextBus2 do
|
|
17
9
|
# a short string that can be used to separate requests from different applications or different modules with
|
18
10
|
# Optional (highly recommended)
|
19
11
|
@stop_id = 10040
|
20
|
-
@conditions = {:stop_id
|
21
|
-
:app_id => 'ratis-specs'}
|
12
|
+
@conditions = { :stop_id => @stop_id }
|
22
13
|
end
|
23
14
|
|
24
15
|
describe "Developer can find a late bus to a stop" do
|
@@ -32,10 +23,9 @@ describe Ratis::NextBus2 do
|
|
32
23
|
# expect(response.runs).to_not be_empty
|
33
24
|
|
34
25
|
response.runs.each do |run|
|
35
|
-
if run[:realtime][:valid] != 'N'
|
36
|
-
pp run[:realtime]
|
37
|
-
end
|
26
|
+
pp run[:realtime] if run[:realtime][:valid] != 'N'
|
38
27
|
end
|
28
|
+
end
|
39
29
|
end
|
40
30
|
end
|
41
31
|
|
@@ -48,10 +38,9 @@ describe Ratis::NextBus2 do
|
|
48
38
|
|
49
39
|
it 'requests the correct SOAP action with args' do
|
50
40
|
Ratis::Request.should_receive(:get) do |action, options|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running
|
41
|
+
action.should eq('Nextbus2')
|
42
|
+
options["Stopid"].should eq(@stop_id)
|
43
|
+
end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running
|
55
44
|
|
56
45
|
Ratis::NextBus2.where(@conditions.dup)
|
57
46
|
end
|
@@ -71,9 +60,8 @@ describe Ratis::NextBus2 do
|
|
71
60
|
|
72
61
|
it 'requests the correct SOAP action' do
|
73
62
|
response = Ratis::NextBus2.where(@conditions.dup.merge(:stop_id => @stop_id))
|
74
|
-
|
75
|
-
|
76
|
-
end
|
63
|
+
expect(response.stops).to_not be_empty
|
64
|
+
expect(response.runs).to_not be_empty
|
77
65
|
end
|
78
66
|
|
79
67
|
it "should raise error when no stop id provided" do
|
@@ -81,72 +69,70 @@ describe Ratis::NextBus2 do
|
|
81
69
|
Ratis::NextBus2.where(@conditions.dup.merge(:stop_id => nil))
|
82
70
|
}.should raise_error(ArgumentError, 'You must provide a stop ID')
|
83
71
|
end
|
72
|
+
end
|
84
73
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
it "should return an empty array if the api request isn't successful" do
|
107
|
-
Ratis::Request.should_receive(:get) do |action, options|
|
108
|
-
action.should eq('Nextbus2')
|
109
|
-
options["Stopid"].should eq(@stop_id)
|
74
|
+
describe 'stops' do
|
75
|
+
# TODO: should return Stops not hashes
|
76
|
+
it 'should set the stop values to instance vars' do
|
77
|
+
response = Ratis::NextBus2.where(@conditions.dup)
|
78
|
+
stop = response.stops.first
|
79
|
+
|
80
|
+
expect(response).to be_a(Ratis::NextBus2)
|
81
|
+
expect(response.stops).to be_a(Array)
|
82
|
+
|
83
|
+
expect(stop[:area]).to eq("Phoenix")
|
84
|
+
expect(stop[:atisstopid]).to eq("6124")
|
85
|
+
expect(stop[:stopposition]).to eq("Y")
|
86
|
+
expect(stop[:description]).to eq("VAN BUREN ST & 16TH ST")
|
87
|
+
expect(stop[:stopstatustype]).to eq("N")
|
88
|
+
expect(stop[:lat]).to eq("33.451493")
|
89
|
+
expect(stop[:long]).to eq("-112.048207")
|
90
|
+
expect(stop[:side]).to eq("Far")
|
91
|
+
expect(stop[:stopid]).to eq("10040")
|
92
|
+
expect(stop[:heading]).to eq("WB")
|
93
|
+
end
|
110
94
|
|
111
|
-
|
95
|
+
it "should return an empty array if the api request isn't successful" do
|
96
|
+
Ratis::Request.should_receive(:get) do |action, options|
|
97
|
+
action.should eq('Nextbus2')
|
98
|
+
options["Stopid"].should eq(@stop_id)
|
99
|
+
end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running
|
112
100
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
101
|
+
response = Ratis::NextBus2.where(@conditions.dup)
|
102
|
+
expect(response).to be_a(Array)
|
103
|
+
expect(response).to be_empty
|
117
104
|
end
|
105
|
+
end
|
118
106
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
end
|
107
|
+
describe 'runs' do
|
108
|
+
# TODO: should return Runs not hashes
|
109
|
+
it "should set the run values to instance vars" do
|
110
|
+
response = Ratis::NextBus2.where(@conditions.dup)
|
111
|
+
run = response.runs.first
|
112
|
+
|
113
|
+
expect(response).to be_a(Ratis::NextBus2)
|
114
|
+
expect(response.runs).to be_a(Array)
|
115
|
+
|
116
|
+
expect(run[:operator]).to eq "FT"
|
117
|
+
expect(run[:status]).to eq "N"
|
118
|
+
expect(run[:sign]).to eq "3 VAN BUREN West to 51st Ave."
|
119
|
+
expect(run[:triptime]).to_not be_nil #eq "12:29 PM"
|
120
|
+
expect(run[:triptime]).to_not be_empty
|
121
|
+
# expect(run.realtime=>{:valid=>nil, :estimatedminutes=>nil, :polltime=>nil, :lat=>nil, :trend=>nil, :vehicleid=>nil, :speed=>nil, :adherence=>nil, :long=>nil, :reliable=>nil, :estimatedtime=>"12:09 PM", :stopped=>nil}
|
122
|
+
expect(run[:exception]).to eq("N")
|
123
|
+
expect(run[:tripid]).to eq "15765-9"
|
124
|
+
expect(run[:routetype]).to eq "B"
|
125
|
+
expect(run[:skedtripid]).to be_nil
|
126
|
+
expect(run[:stopid]).to eq "10040"
|
127
|
+
expect(run[:servicetype]).to eq "W"
|
128
|
+
expect(run[:adherence]).to eq('3')
|
129
|
+
expect(run[:atisstopid]).to eq "6124"
|
130
|
+
# expect(run[:block]).to eq "5"
|
131
|
+
expect(run[:route]).to eq "3"
|
132
|
+
expect(run[:estimatedtime]).to_not be_nil
|
133
|
+
expect(run[:estimatedtime]).to_not be_empty
|
134
|
+
expect(run[:direction]).to eq "W"
|
148
135
|
end
|
149
|
-
|
150
136
|
end
|
151
137
|
end
|
152
138
|
|
data/spec/ratis/next_bus_spec.rb
CHANGED
@@ -1,24 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ratis::NextBus do
|
4
|
-
|
5
|
-
|
6
|
-
Ratis.configure do |config|
|
7
|
-
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-262/soap.cgi'
|
8
|
-
config.namespace = 'PX_WEB'
|
9
|
-
end
|
10
|
-
|
11
|
-
@time = Chronic.parse('next monday at 6am')
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:empty_body){ {:nextbus_response => {:atstop => {:service => []}}} }
|
4
|
+
let(:empty_body) { {:nextbus_response => {:atstop => {:service => []}}} }
|
5
|
+
let(:time) { Chronic.parse('next monday at 6am') }
|
15
6
|
|
16
7
|
describe "Developer can find a late bus to a stop" do
|
17
8
|
it "will give developer happiness :-)" do
|
18
9
|
pending
|
19
|
-
@conditions = {:
|
20
|
-
:
|
21
|
-
:datetime => Chronic.parse('now') }
|
10
|
+
@conditions = {:type => 'N',
|
11
|
+
:datetime => Chronic.parse('now') }
|
22
12
|
|
23
13
|
require 'pp'
|
24
14
|
10000.upto(10100).each do |id|
|
@@ -53,15 +43,14 @@ describe Ratis::NextBus do
|
|
53
43
|
describe 'time formatting' do
|
54
44
|
it 'should make requests with 24 hour time format' do
|
55
45
|
@stop_id = 10050
|
56
|
-
|
46
|
+
time = Chronic.parse('tomorrow at 3pm')
|
57
47
|
@conditions = {:stop_id => @stop_id,
|
58
|
-
:app_id => 'ratis-specs', # a short string that can be used to separate requests from different applications or different modules with
|
59
48
|
:type => 'N',
|
60
|
-
:datetime =>
|
49
|
+
:datetime => time }
|
61
50
|
|
62
51
|
Ratis::Request.should_receive(:get) do |action, options|
|
63
52
|
action.should eq('Nextbus')
|
64
|
-
options["Time"].should eq(
|
53
|
+
options["Time"].should eq(time.strftime("%H%M"))
|
65
54
|
|
66
55
|
end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running
|
67
56
|
|
@@ -73,9 +62,8 @@ describe Ratis::NextBus do
|
|
73
62
|
before do
|
74
63
|
@stop_id = 10050
|
75
64
|
@conditions = {:stop_id => @stop_id,
|
76
|
-
:app_id => 'ratis-specs', # a short string that can be used to separate requests from different applications or different modules with
|
77
65
|
:type => 'N',
|
78
|
-
:datetime =>
|
66
|
+
:datetime => time }
|
79
67
|
|
80
68
|
end
|
81
69
|
|
@@ -97,9 +85,8 @@ describe Ratis::NextBus do
|
|
97
85
|
Ratis::Request.should_receive(:get) do |action, options|
|
98
86
|
action.should eq('Nextbus')
|
99
87
|
options["Stopid"].should eq(@stop_id)
|
100
|
-
options["
|
101
|
-
options["
|
102
|
-
options["Time"].should eq(@time.strftime("%H%M"))
|
88
|
+
options["Date"].should eq(time.strftime("%m/%d/%Y"))
|
89
|
+
options["Time"].should eq(time.strftime("%H%M"))
|
103
90
|
options["Type"].should eq('N')
|
104
91
|
|
105
92
|
end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running
|
@@ -113,7 +100,7 @@ describe Ratis::NextBus do
|
|
113
100
|
expect(response).to be_a(Ratis::NextBus)
|
114
101
|
expect(response.services).to be_a(Array)
|
115
102
|
|
116
|
-
expect(service.status).to eq('
|
103
|
+
expect(service.status).to eq('N')
|
117
104
|
expect(service.sign).to eq('0 CENTRAL North to Dunlap/3rd St.')
|
118
105
|
expect(service.routetype).to eq('B')
|
119
106
|
expect(service.times).to eq("05:49 AM, 06:09 AM, 06:29 AM, 06:49 AM")
|
@@ -147,9 +134,8 @@ describe Ratis::NextBus do
|
|
147
134
|
Ratis::Request.should_receive(:get) do |action, options|
|
148
135
|
action.should eq('Nextbus')
|
149
136
|
options["Stopid"].should eq(@stop_id)
|
150
|
-
options["
|
151
|
-
options["
|
152
|
-
options["Time"].should eq(@time.strftime("%H%M"))
|
137
|
+
options["Date"].should eq(time.strftime("%m/%d/%Y"))
|
138
|
+
options["Time"].should eq(time.strftime("%H%M"))
|
153
139
|
options["Type"].should eq('N')
|
154
140
|
|
155
141
|
end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running
|
@@ -163,7 +149,6 @@ describe Ratis::NextBus do
|
|
163
149
|
@stop_id = 15894
|
164
150
|
@time = Chronic.parse('next monday at 3pm')
|
165
151
|
@conditions = {:stop_id => @stop_id,
|
166
|
-
:app_id => 'ratis-specs', # a short string that can be used to separate requests from different applications or different modules with
|
167
152
|
:type => 'N',
|
168
153
|
:datetime => @time }
|
169
154
|
end
|
@@ -186,7 +171,6 @@ describe Ratis::NextBus do
|
|
186
171
|
Ratis::Request.should_receive(:get) do |action, options|
|
187
172
|
action.should eq('Nextbus')
|
188
173
|
options["Stopid"].should eq(@stop_id)
|
189
|
-
options["Appid"].should eq('ratis-specs')
|
190
174
|
options["Date"].should eq(@time.strftime("%m/%d/%Y"))
|
191
175
|
options["Time"].should eq(@time.strftime("%H%M"))
|
192
176
|
options["Type"].should eq('N')
|
@@ -248,14 +232,13 @@ describe Ratis::NextBus do
|
|
248
232
|
|
249
233
|
it "should return an empty array if the api request isn't successful" do
|
250
234
|
Ratis::Request.should_receive('get') do |action, options|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
end.and_return(double('response', :success? => false, :body => empty_body))
|
235
|
+
action.should eq('Nextbus')
|
236
|
+
options["Time"].should eq(@time.strftime("%H%M") )
|
237
|
+
options["Type"].should eq("N")
|
238
|
+
options["Stopid"].should eq(@stop_id)
|
239
|
+
options["Date"].should eq(time.strftime("%m/%d/%Y") )
|
240
|
+
|
241
|
+
end.and_return(double('response', :success? => false, :body => empty_body))
|
259
242
|
|
260
243
|
expect(Ratis::NextBus.where(@conditions.dup).services).to be_empty
|
261
244
|
end
|
data/spec/ratis/pattern_spec.rb
CHANGED
@@ -1,14 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ratis::Pattern do
|
4
|
-
before do
|
5
|
-
Ratis.reset
|
6
|
-
Ratis.configure do |config|
|
7
|
-
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-262/soap.cgi'
|
8
|
-
config.namespace = 'PX_WEB'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
4
|
describe '#all', vcr: {} do
|
13
5
|
|
14
6
|
before do
|
@@ -63,10 +55,10 @@ describe Ratis::Pattern do
|
|
63
55
|
expect(routeinfo.operate).to eq('AP')
|
64
56
|
expect(routeinfo.routetype).to eq('B')
|
65
57
|
expect(routeinfo.headsign).to eq("0 CENTRAL North to Dunlap/3rd St.")
|
66
|
-
expect(routeinfo.routeid).to eq('
|
58
|
+
expect(routeinfo.routeid).to eq('168930')
|
67
59
|
expect(routeinfo.route).to eq('ZERO')
|
68
60
|
expect(routeinfo.school).to be_nil
|
69
|
-
expect(routeinfo.effective).to eq("
|
61
|
+
expect(routeinfo.effective).to eq("04/28/14")
|
70
62
|
expect(routeinfo.tripcount).to eq('51')
|
71
63
|
|
72
64
|
end
|
data/spec/ratis/plantrip_spec.rb
CHANGED
@@ -2,12 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Ratis::Plantrip do
|
4
4
|
before do
|
5
|
-
Ratis.reset
|
6
|
-
Ratis.configure do |config|
|
7
|
-
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-262/soap.cgi'
|
8
|
-
config.namespace = 'PX_WEB'
|
9
|
-
end
|
10
|
-
|
11
5
|
@datetime = Chronic.parse('next monday at 6am')
|
12
6
|
end
|
13
7
|
|
@@ -33,7 +27,6 @@ describe Ratis::Plantrip do
|
|
33
27
|
it 'requests the correct SOAP action' do
|
34
28
|
Ratis::Request.should_receive(:get) do |action, options|
|
35
29
|
action.should eq('Plantrip')
|
36
|
-
options["Appid"].should eq('ratis-gem')
|
37
30
|
options["Date"].should eq(@datetime.strftime("%m/%d/%Y"))
|
38
31
|
options["Time"].should eq(@datetime.strftime("%H%M"))
|
39
32
|
options["Minimize"].should eq('T')
|
@@ -64,23 +57,31 @@ describe Ratis::Plantrip do
|
|
64
57
|
expect(plantrip.walkadjust).to eq(nil)
|
65
58
|
|
66
59
|
input = {
|
67
|
-
:accessible => "N",
|
68
|
-
:arrdep => "D",
|
69
|
-
:date => "01/13/2014",
|
70
|
-
:destinationlandmarkid => "0",
|
71
|
-
:destinationlat => "33.446347",
|
72
|
-
:destinationlong => "-112.068689",
|
73
|
-
:destinationtext => "Destination",
|
74
|
-
:minimize => "T",
|
75
|
-
:originlandmarkid => "0",
|
76
60
|
:originlat => "33.452082",
|
77
61
|
:originlong => "-112.074374",
|
62
|
+
:originlandmarkid => "0",
|
78
63
|
:origintext => "Origin",
|
64
|
+
:destinationlat => "33.446347",
|
65
|
+
:destinationlong => "-112.068689",
|
66
|
+
:destinationlandmarkid => "0",
|
67
|
+
:destinationtext => "Destination",
|
68
|
+
:date => "06/16/2014",
|
79
69
|
:time => "06:00 AM",
|
80
|
-
:
|
70
|
+
:minimize => "T",
|
71
|
+
:accessible => "N",
|
72
|
+
:arrdep => "D",
|
73
|
+
:maxtransfers => "-1",
|
74
|
+
:maxanswers => "3",
|
75
|
+
:lessttime => "N",
|
76
|
+
:maxinitialwait => "-1",
|
77
|
+
:maxtriptime => "-1",
|
78
|
+
:walkspeed => " 2.00 ",
|
81
79
|
:walkdist => "0.50",
|
82
80
|
:walkorigin => "0.50",
|
83
|
-
:
|
81
|
+
:walkdestination => "0.50",
|
82
|
+
:walkincrease => "N",
|
83
|
+
:allows2s => "N",
|
84
|
+
:xmode => "BCFKLRSTX"
|
84
85
|
}
|
85
86
|
|
86
87
|
HashDiff.diff(plantrip.input, input).should eql []
|
@@ -1,14 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ratis::Point2Point do
|
4
|
-
before do
|
5
|
-
Ratis.reset
|
6
|
-
Ratis.configure do |config|
|
7
|
-
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-262/soap.cgi'
|
8
|
-
config.namespace = 'PX_WEB'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
4
|
describe 'Routesonly => Y' do
|
13
5
|
describe '#where', vcr: {} do
|
14
6
|
describe 'services from origin to destination' do
|
@@ -142,7 +134,7 @@ describe Ratis::Point2Point do
|
|
142
134
|
on_stop.latitude.should eql(33.4469)
|
143
135
|
on_stop.longitude.should eql(-112.097897)
|
144
136
|
on_stop.atis_stop_id.should eql(9469)
|
145
|
-
on_stop.walk_dist.should eql(0.
|
137
|
+
on_stop.walk_dist.should eql(0.0)
|
146
138
|
on_stop.walk_dir.should eql('S')
|
147
139
|
on_stop.walk_hint.should eql('N')
|
148
140
|
end
|
@@ -154,11 +146,11 @@ describe Ratis::Point2Point do
|
|
154
146
|
|
155
147
|
off_stop.should be_a(Ratis::Point2Point::Stop)
|
156
148
|
|
157
|
-
off_stop.description.should eql('JEFFERSON ST &
|
149
|
+
off_stop.description.should eql('JEFFERSON ST & 18TH AVE')
|
158
150
|
off_stop.latitude.should eql(33.447029)
|
159
151
|
off_stop.longitude.should eql(-112.077181)
|
160
152
|
off_stop.atis_stop_id.should eql(1463)
|
161
|
-
off_stop.walk_dist.should eql(0.
|
153
|
+
off_stop.walk_dist.should eql(0.0)
|
162
154
|
off_stop.walk_dir.should eql('SE')
|
163
155
|
off_stop.walk_hint.should eql('N')
|
164
156
|
end
|
data/spec/ratis/request_spec.rb
CHANGED
@@ -1,14 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
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-262/soap.cgi'
|
8
|
-
config.namespace = 'PX_WEB'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
4
|
context 'new Requests get config from Ratis.configure block' do
|
13
5
|
it 'gets config from initializing' do
|
14
6
|
pending
|
@@ -19,11 +11,8 @@ describe Ratis::Request do
|
|
19
11
|
|
20
12
|
context 'configured incorrectly' do
|
21
13
|
context 'without Ratis.configure being called' do
|
22
|
-
before do
|
23
|
-
Ratis.reset
|
24
|
-
end
|
25
|
-
|
26
14
|
it 'raises an exception when initialized before configuring' do
|
15
|
+
expect(Ratis.config).to receive(:valid?).at_least(:once) { false }
|
27
16
|
expect do
|
28
17
|
Ratis::Request.get 'SomeAction'
|
29
18
|
end.to raise_error Ratis::Errors::ConfigError, 'It appears that Ratis.configure has not been called or properly setup'
|
@@ -34,14 +23,6 @@ end
|
|
34
23
|
|
35
24
|
describe Ratis::Request do
|
36
25
|
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-262/soap.cgi'
|
41
|
-
config.namespace = 'PX_WEB'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
26
|
describe 'with no parameters' do
|
46
27
|
it 'only makes one request with the correct SOAP action' do
|
47
28
|
|