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,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ratis::ClosestStop do
|
4
|
-
|
5
|
-
before do
|
6
|
-
Ratis.reset
|
7
|
-
Ratis.configure do |config|
|
8
|
-
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-262/soap.cgi'
|
9
|
-
config.namespace = 'PX_WEB'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
4
|
describe '#where', vcr: {} do
|
14
5
|
before do
|
15
6
|
@today = Time.now.strftime("%m/%d/%Y")
|
@@ -32,7 +23,6 @@ describe Ratis::ClosestStop do
|
|
32
23
|
options["Locationlong"].should eq(@conditions[:longitude])
|
33
24
|
options["Locationtext"].should eq(@conditions[:location_text])
|
34
25
|
options["Numstops"].should eq(@conditions[:num_stops])
|
35
|
-
|
36
26
|
end.and_return(double('response', :success? => false))
|
37
27
|
|
38
28
|
Ratis::ClosestStop.where(@conditions.dup)
|
@@ -92,8 +82,4 @@ describe Ratis::ClosestStop do
|
|
92
82
|
end.to raise_error(ArgumentError, 'You must provide a longitude')
|
93
83
|
end
|
94
84
|
end
|
95
|
-
|
96
|
-
|
97
|
-
|
98
85
|
end
|
99
|
-
|
data/spec/ratis/config_spec.rb
CHANGED
@@ -1,44 +1,35 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ratis::Config do
|
4
|
+
it 'is valid' do
|
5
|
+
expect(Ratis.config).to be_valid
|
6
|
+
end
|
4
7
|
|
5
|
-
context '
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
it 'is valid' do
|
10
|
-
Ratis.config.valid?.should be_true
|
11
|
-
end
|
12
|
-
|
8
|
+
context 'nil endpoint' do
|
9
|
+
it 'is not valid' do
|
10
|
+
expect(Ratis.config).to receive(:endpoint).at_least(:once).and_return(nil)
|
11
|
+
expect(Ratis.config).to_not be_valid
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
16
14
|
|
17
|
-
context '
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
# Ratis.config = Ratis::Config.new
|
15
|
+
context 'empty endpoint' do
|
16
|
+
it 'is not valid' do
|
17
|
+
expect(Ratis.config).to receive(:endpoint).at_least(:once).and_return('')
|
18
|
+
expect(Ratis.config).to_not be_valid
|
22
19
|
end
|
20
|
+
end
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
Ratis.config.valid?.should be_false
|
29
|
-
end
|
30
|
-
|
22
|
+
context 'nil namespace' do
|
23
|
+
it 'is not valid' do
|
24
|
+
expect(Ratis.config).to receive(:namespace).at_least(:once).and_return(nil)
|
25
|
+
expect(Ratis.config).to_not be_valid
|
31
26
|
end
|
27
|
+
end
|
32
28
|
|
33
|
-
|
34
|
-
|
35
|
-
Ratis.
|
36
|
-
|
37
|
-
config.namespace = 'TEST_NS'
|
38
|
-
end
|
29
|
+
context 'empty namespace' do
|
30
|
+
it 'is not valid' do
|
31
|
+
expect(Ratis.config).to receive(:namespace).at_least(:once).and_return('')
|
32
|
+
expect(Ratis.config).to_not be_valid
|
39
33
|
end
|
40
|
-
|
41
34
|
end
|
42
|
-
|
43
35
|
end
|
44
|
-
|
data/spec/ratis/core_ext_spec.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Hash do
|
4
|
-
|
5
4
|
describe 'which is one level deep' do
|
6
|
-
|
7
5
|
describe '#to_array' do
|
8
|
-
|
9
6
|
it 'returns [] if key is not present in Hash' do
|
10
7
|
{}.to_array(:a).should eql []
|
11
8
|
end
|
@@ -21,15 +18,11 @@ describe Hash do
|
|
21
18
|
it 'returns Array if value is an Array' do
|
22
19
|
{ :a => [1,2,3] }.to_array(:a).should eql [1,2,3]
|
23
20
|
end
|
24
|
-
|
25
21
|
end
|
26
|
-
|
27
22
|
end
|
28
23
|
|
29
24
|
describe 'which is two levels deep' do
|
30
|
-
|
31
25
|
describe '#to_array' do
|
32
|
-
|
33
26
|
it 'returns [] if key is not present in Hash' do
|
34
27
|
{ :a => {} }.to_array(:a, :b).should eql []
|
35
28
|
end
|
@@ -45,10 +38,6 @@ describe Hash do
|
|
45
38
|
it 'returns Array if value is an Array' do
|
46
39
|
{ :a => { :b => [1,2,3] } }.to_array(:a, :b).should eql [1,2,3]
|
47
40
|
end
|
48
|
-
|
49
41
|
end
|
50
|
-
|
51
42
|
end
|
52
|
-
|
53
43
|
end
|
54
|
-
|
@@ -1,56 +1,41 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ratis::FleetLocation do
|
4
|
-
|
5
|
-
before do
|
6
|
-
Ratis.reset
|
7
|
-
Ratis.configure do |config|
|
8
|
-
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-271/soap.cgi'
|
9
|
-
config.namespace = 'PX_WEB'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
4
|
describe "#current" do
|
14
|
-
before do
|
15
|
-
@conditions = {:app_id => 'WEB'}
|
16
|
-
end
|
17
|
-
|
18
5
|
it 'only makes one request', vcr: {} do
|
19
6
|
# false just to stop further processing of response
|
20
7
|
Ratis::Request.should_receive(:get).once.and_call_original
|
21
|
-
Ratis::FleetLocation.current
|
8
|
+
Ratis::FleetLocation.current
|
22
9
|
end
|
23
10
|
|
24
11
|
it 'requests the correct SOAP action' do
|
25
12
|
Ratis::Request.should_receive(:get) do |action, options|
|
26
13
|
action.should eq('Fleetlocation')
|
27
|
-
options["Appid"].should eq(@conditions[:app_id])
|
28
|
-
|
29
14
|
end.and_return(double('response', :success? => false))
|
30
15
|
|
31
|
-
Ratis::FleetLocation.current
|
16
|
+
Ratis::FleetLocation.current
|
32
17
|
end
|
33
18
|
|
34
19
|
it "should return a collection of Ratis::Vehicle(s)", vcr: {} do
|
35
|
-
stops = Ratis::FleetLocation.current
|
20
|
+
stops = Ratis::FleetLocation.current
|
36
21
|
stops.each do |obj|
|
37
22
|
expect(obj).to be_a(Ratis::Vehicle)
|
38
23
|
end
|
39
24
|
end
|
40
25
|
|
41
26
|
it 'returns multiple vehicles', vcr: {} do
|
42
|
-
stops = Ratis::FleetLocation.current
|
43
|
-
stops.should have(
|
27
|
+
stops = Ratis::FleetLocation.current
|
28
|
+
stops.should have(469).items
|
44
29
|
end
|
45
30
|
|
46
31
|
it 'parses out the vehicle fields correctly', vcr: {} do
|
47
|
-
vehicles = Ratis::FleetLocation.current
|
32
|
+
vehicles = Ratis::FleetLocation.current
|
48
33
|
vehicle = vehicles.first
|
49
34
|
|
50
35
|
expect(vehicle.route).to eq('1')
|
51
36
|
expect(vehicle.direction).to eq('E')
|
52
|
-
expect(vehicle.updatetime).to eq('
|
53
|
-
expect(vehicle.adherance).to eq('
|
37
|
+
expect(vehicle.updatetime).to eq('05:38 PM')
|
38
|
+
expect(vehicle.adherance).to eq('-1')
|
54
39
|
expect(vehicle.adhchange).to eq('S')
|
55
40
|
expect(vehicle.vehicle_id).to be_nil
|
56
41
|
expect(vehicle.offroute).to eq('N')
|
@@ -58,7 +43,5 @@ describe Ratis::FleetLocation do
|
|
58
43
|
expect(vehicle.reliable).to eq('Y')
|
59
44
|
expect(vehicle.inservice).to eq('Y')
|
60
45
|
end
|
61
|
-
|
62
46
|
end
|
63
|
-
|
64
47
|
end
|
@@ -1,19 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ratis::Itinerary 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 '#initialize' do
|
13
5
|
it "does something" do
|
14
6
|
pending
|
15
7
|
end
|
16
8
|
end
|
17
|
-
|
18
9
|
end
|
19
|
-
|
@@ -1,16 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ratis::LandmarkCategory do
|
4
|
-
|
5
|
-
before do
|
6
|
-
Ratis.reset
|
7
|
-
Ratis.configure do |config|
|
8
|
-
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-262/soap.cgi'
|
9
|
-
config.namespace = 'PX_WEB'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '.all', vcr: {} do
|
4
|
+
describe '#all', vcr: {} do
|
14
5
|
it 'only makes one request' do
|
15
6
|
# false just to stop further processing of response
|
16
7
|
Ratis::Request.should_receive(:get).once.and_call_original
|
@@ -49,6 +40,4 @@ describe Ratis::LandmarkCategory do
|
|
49
40
|
end
|
50
41
|
end
|
51
42
|
end
|
52
|
-
|
53
43
|
end
|
54
|
-
|
data/spec/ratis/landmark_spec.rb
CHANGED
@@ -1,52 +1,39 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ratis::Landmark do
|
4
|
-
|
5
|
-
before do
|
6
|
-
Ratis.reset
|
7
|
-
Ratis.configure do |config|
|
8
|
-
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-262/soap.cgi'
|
9
|
-
config.namespace = 'PX_WEB'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
4
|
describe "#where" do
|
14
|
-
|
15
|
-
@conditions = {:type => '*',
|
16
|
-
:zipcode => '85224'}
|
17
|
-
end
|
5
|
+
let(:conditions) { { :type => '*', :zipcode => '85224' } }
|
18
6
|
|
19
7
|
it 'only makes one request', vcr: {} do
|
20
8
|
# false just to stop further processing of response
|
21
9
|
Ratis::Request.should_receive(:get).once.and_call_original
|
22
|
-
Ratis::Landmark.where(
|
10
|
+
Ratis::Landmark.where(conditions.dup)
|
23
11
|
end
|
24
12
|
|
25
13
|
it 'requests the correct SOAP action' do
|
26
14
|
Ratis::Request.should_receive(:get) do |action, options|
|
27
15
|
action.should eq('Getlandmarks')
|
28
|
-
options["Type"].should eq(
|
29
|
-
options["Zipcode"].should eq(
|
30
|
-
|
16
|
+
options["Type"].should eq(conditions[:type])
|
17
|
+
options["Zipcode"].should eq(conditions[:zipcode])
|
31
18
|
end.and_return(double('response', :success? => false))
|
32
19
|
|
33
|
-
Ratis::Landmark.where(
|
20
|
+
Ratis::Landmark.where(conditions.dup)
|
34
21
|
end
|
35
22
|
|
36
23
|
it "should return a collection of Ratis::Landmark(s)", vcr: {} do
|
37
|
-
stops = Ratis::Landmark.where(
|
24
|
+
stops = Ratis::Landmark.where(conditions.dup)
|
38
25
|
stops.each do |obj|
|
39
26
|
expect(obj).to be_a(Ratis::Landmark)
|
40
27
|
end
|
41
28
|
end
|
42
29
|
|
43
30
|
it 'returns multiple landmarks', vcr: {} do
|
44
|
-
stops = Ratis::Landmark.where(
|
45
|
-
stops.should have(
|
31
|
+
stops = Ratis::Landmark.where(conditions.dup)
|
32
|
+
stops.should have(1034).items
|
46
33
|
end
|
47
34
|
|
48
35
|
it 'parses out the landmark fields correctly', vcr: {} do
|
49
|
-
landmarks = Ratis::Landmark.where(
|
36
|
+
landmarks = Ratis::Landmark.where(conditions.dup)
|
50
37
|
landmark = landmarks.first
|
51
38
|
|
52
39
|
expect(landmark.type).to eq('LRT')
|
@@ -56,11 +43,11 @@ describe Ratis::Landmark do
|
|
56
43
|
end
|
57
44
|
|
58
45
|
it "should raise error for missing arg type" do
|
59
|
-
|
60
|
-
|
46
|
+
conds = conditions.dup
|
47
|
+
conds.delete(:type)
|
61
48
|
|
62
49
|
expect do
|
63
|
-
Ratis::Landmark.where(
|
50
|
+
Ratis::Landmark.where(conds)
|
64
51
|
end.to raise_error(ArgumentError, 'You must provide a type')
|
65
52
|
end
|
66
53
|
end
|
data/spec/ratis/location_spec.rb
CHANGED
@@ -1,24 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ratis::Location 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 '#where', vcr: {} do
|
13
|
-
|
14
|
-
@conditions = {:location => '1315 W. Straford Dr.',
|
15
|
-
:media => 'W' }
|
16
|
-
end
|
5
|
+
let(:conditions) { { :location => '1315 W. Straford Dr.', :media => 'W' } }
|
17
6
|
|
18
7
|
it 'only makes one request' do
|
19
8
|
# false just to stop further processing of response
|
20
9
|
Ratis::Request.should_receive(:get).once.and_call_original
|
21
|
-
Ratis::Location.where(
|
10
|
+
Ratis::Location.where(conditions.dup)
|
22
11
|
end
|
23
12
|
|
24
13
|
it 'requests the correct SOAP action with correct args' do
|
@@ -30,18 +19,18 @@ describe Ratis::Location do
|
|
30
19
|
|
31
20
|
end.and_return(double('response', :success? => false))
|
32
21
|
|
33
|
-
Ratis::Location.where(
|
22
|
+
Ratis::Location.where(conditions.dup)
|
34
23
|
end
|
35
24
|
|
36
25
|
it 'should return a collection of Ratis::Location(s)' do
|
37
|
-
locations = Ratis::Location.where(
|
26
|
+
locations = Ratis::Location.where(conditions.dup)
|
38
27
|
locations.each do |obj|
|
39
28
|
expect(obj).to be_a(Ratis::Location)
|
40
29
|
end
|
41
30
|
end
|
42
31
|
|
43
32
|
it 'parses out fields correctly' do
|
44
|
-
locations = Ratis::Location.where(
|
33
|
+
locations = Ratis::Location.where(conditions.dup)
|
45
34
|
first_location = locations.first
|
46
35
|
|
47
36
|
expect(first_location.name).to eql 'W STRAFORD DR'
|
@@ -1,21 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ratis::LocationTypeAheadItem do
|
4
|
-
let(:item){
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
let(:item) {
|
5
|
+
Ratis::LocationTypeAheadItem.new({
|
6
|
+
name: '1315 W STRAFORD DR',
|
7
|
+
area: 'Chandler',
|
8
|
+
areacode: 'CH',
|
9
|
+
postcode: '85224',
|
10
|
+
type: 'N'
|
11
|
+
})
|
12
|
+
}
|
9
13
|
|
10
14
|
describe '#initialize' do
|
11
|
-
it "should
|
15
|
+
it "should correctly assign instance variables" do
|
12
16
|
expect(item.name).to eq('1315 W STRAFORD DR')
|
13
17
|
expect(item.area).to eq('Chandler')
|
14
18
|
expect(item.areacode).to eq('CH')
|
15
19
|
expect(item.postcode).to eq('85224')
|
16
20
|
expect(item.type).to eq('N')
|
17
21
|
end
|
18
|
-
|
19
22
|
end
|
20
|
-
|
21
|
-
end
|
23
|
+
end
|
@@ -1,54 +1,40 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ratis::LocationTypeAhead 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 '#where', vcr: {} do
|
13
|
-
|
14
|
-
@conditions = {:search => '1315 w straford dr'}
|
15
|
-
end
|
5
|
+
let(:conditions) { { :search => '1315 w straford dr' } }
|
16
6
|
|
17
7
|
it 'only makes one request' do
|
18
8
|
# false just to stop further processing of response
|
19
9
|
Ratis::Request.should_receive(:get).once.and_call_original
|
20
|
-
Ratis::LocationTypeAhead.where(
|
10
|
+
Ratis::LocationTypeAhead.where(conditions.dup)
|
21
11
|
end
|
22
12
|
|
23
13
|
it 'requests the correct SOAP action with correct args' do
|
24
14
|
Ratis::Request.should_receive(:get) do |action, options|
|
25
15
|
action.should eq('Locationtypeahead')
|
26
16
|
options["Search"].should eq('1315 w straford dr')
|
27
|
-
options["Appid"].should eq('WEB') # default
|
28
|
-
|
29
17
|
end.and_return(double('response', :success? => false))
|
30
18
|
|
31
|
-
Ratis::LocationTypeAhead.where(
|
19
|
+
Ratis::LocationTypeAhead.where(conditions.dup)
|
32
20
|
end
|
33
21
|
|
34
22
|
it 'should return a collection of Ratis::LocationTypeAheadItem(s)' do
|
35
|
-
locations = Ratis::LocationTypeAhead.where(
|
23
|
+
locations = Ratis::LocationTypeAhead.where(conditions.dup)
|
36
24
|
locations.each do |obj|
|
37
25
|
expect(obj).to be_a(Ratis::LocationTypeAheadItem)
|
38
26
|
end
|
39
27
|
end
|
40
28
|
|
41
29
|
it 'parses out fields correctly' do
|
42
|
-
locations = Ratis::LocationTypeAhead.where(
|
30
|
+
locations = Ratis::LocationTypeAhead.where(conditions.dup)
|
43
31
|
location = locations.first
|
44
32
|
|
45
33
|
expect(location.name).to eql '1315 W STRAFORD DR'
|
46
34
|
expect(location.area).to eql 'Chandler'
|
47
35
|
expect(location.areacode).to eql 'CH'
|
48
|
-
expect(location.postcode).to
|
36
|
+
expect(location.postcode).to be_nil # Applies only to landmarks
|
49
37
|
expect(location.type).to eql 'N'
|
50
38
|
end
|
51
|
-
|
52
39
|
end
|
53
|
-
|
54
|
-
end
|
40
|
+
end
|