ratis 3.3.6 → 3.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/.rvmrc +1 -1
  3. data/CHANGELOG +8 -1
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +33 -35
  6. data/lib/ratis.rb +1 -1
  7. data/lib/ratis/landmark.rb +4 -3
  8. data/lib/ratis/landmark_category.rb +11 -7
  9. data/lib/ratis/location.rb +1 -0
  10. data/lib/ratis/route_stops.rb +0 -6
  11. data/lib/ratis/version.rb +1 -1
  12. data/lib/ratis/walkstop.rb +54 -0
  13. data/ratis.gemspec +3 -5
  14. data/spec/ratis/area_spec.rb +1 -1
  15. data/spec/ratis/closest_stop_spec.rb +2 -2
  16. data/spec/ratis/itinerary_spec.rb +8 -711
  17. data/spec/ratis/landmark_category_spec.rb +40 -32
  18. data/spec/ratis/landmark_spec.rb +4 -33
  19. data/spec/ratis/location_spec.rb +69 -177
  20. data/spec/ratis/next_bus2_spec.rb +21 -21
  21. data/spec/ratis/next_bus_spec.rb +19 -21
  22. data/spec/ratis/pattern_spec.rb +3 -3
  23. data/spec/ratis/plantrip_spec.rb +92 -0
  24. data/spec/ratis/point_2_point_spec.rb +12 -12
  25. data/spec/ratis/request_spec.rb +0 -1
  26. data/spec/ratis/route_pattern_spec.rb +16 -15
  27. data/spec/ratis/route_stops_spec.rb +10 -10
  28. data/spec/ratis/routes_spec.rb +5 -5
  29. data/spec/ratis/schedule_nearby_spec.rb +1 -1
  30. data/spec/ratis/timetable_spec.rb +3 -3
  31. data/spec/ratis/walkstop_spec.rb +94 -0
  32. data/spec/spec_helper.rb +16 -11
  33. data/spec/support/vcr_cassettes/Nextbus2_running_LATE.yml +142 -574
  34. data/spec/support/vcr_cassettes/Nextbus_running_LATE.yml +101 -137
  35. data/spec/support/vcr_cassettes/Point2Point.yml +63 -162
  36. data/spec/support/vcr_cassettes/Ratis_Area/_all/only_makes_one_request.yml +52 -0
  37. data/spec/support/vcr_cassettes/Ratis_ClosestStop/_where/only_makes_one_request.yml +70 -0
  38. data/spec/support/vcr_cassettes/Ratis_ClosestStop/_where/parses_out_the_stop_fields_correctly.yml +70 -0
  39. data/spec/support/vcr_cassettes/Ratis_ClosestStop/_where/returns_multiple_locations.yml +70 -0
  40. data/spec/support/vcr_cassettes/Ratis_ClosestStop/_where/should_return_a_collection_of_Ratis_Stop_s_.yml +70 -0
  41. data/spec/support/vcr_cassettes/Ratis_LandmarkCategory/_all/only_makes_one_request.yml +117 -0
  42. data/spec/support/vcr_cassettes/Ratis_LandmarkCategory/_all/should_return_a_collection_of_Ratis_LandmarkCategory_s_.yml +117 -0
  43. data/spec/support/vcr_cassettes/Ratis_LandmarkCategory/_all/should_return_all_landmark_categories.yml +117 -0
  44. data/spec/support/vcr_cassettes/Ratis_LandmarkCategory/_web_categories/does_something.yml +117 -0
  45. data/spec/support/vcr_cassettes/Ratis_Location/_where/only_makes_one_request.yml +54 -0
  46. data/spec/support/vcr_cassettes/Ratis_Location/_where/parses_out_fields_correctly.yml +54 -0
  47. data/spec/support/vcr_cassettes/Ratis_Location/_where/should_return_a_collection_of_Ratis_Location_s_.yml +54 -0
  48. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/multiple_services_returned/only_makes_one_request.yml +109 -0
  49. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/multiple_services_returned/returns_the_next_4_bus_times.yml +109 -0
  50. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/multiple_services_returned/should_map_all_the_services_to_service_openstruct_objects.yml +109 -0
  51. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/multiple_services_returned/should_raise_error_if_datetime_condition_is_not_a_DateTime_or_Time.yml +211 -0
  52. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/single_service_return/only_makes_one_request.yml +75 -0
  53. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/single_service_return/returns_the_next_bus_times.yml +75 -0
  54. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/single_service_return/should_raise_error_if_datetime_condition_is_not_a_DateTime_or_Time.yml +143 -0
  55. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/single_service_return/should_set_all_the_service_values_to_instance_vars.yml +75 -0
  56. 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 +180 -0
  57. 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 +180 -0
  58. 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 +180 -0
  59. 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 +180 -0
  60. data/spec/support/vcr_cassettes/Ratis_Pattern/_all/only_makes_one_request.yml +56 -0
  61. data/spec/support/vcr_cassettes/Ratis_Pattern/_all/should_parse_the_route_info_fields.yml +56 -0
  62. data/spec/support/vcr_cassettes/Ratis_Pattern/_all/should_return_a_collection_Pattern_RouteInfo_s_.yml +56 -0
  63. data/spec/support/vcr_cassettes/Ratis_Pattern/_all/should_return_no_data_error_when_date_is_in_the_past.yml +53 -0
  64. data/spec/support/vcr_cassettes/Ratis_Plantrip/_where/creates_Ratis_Itineraries_for_each_trip_itinerary.yml +88 -0
  65. data/spec/support/vcr_cassettes/Ratis_Plantrip/_where/only_makes_one_request.yml +88 -0
  66. data/spec/support/vcr_cassettes/Ratis_Plantrip/_where/returns_a_Plantrip_object.yml +88 -0
  67. data/spec/support/vcr_cassettes/Ratis_Plantrip/_where/should_set_all_the_Plantrip_values_to_instance_vars.yml +88 -0
  68. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/gets_the_groups.yml +134 -0
  69. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/gets_the_trips_within_each_group.yml +134 -0
  70. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/only_makes_one_request.yml +134 -0
  71. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/parses_out_the_off_stop_fields.yml +134 -0
  72. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/parses_out_the_on_stop_fields.yml +134 -0
  73. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/parses_out_the_service.yml +134 -0
  74. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/parses_out_the_trip.yml +134 -0
  75. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/should_only_return_result_groups_for_filtered_route.yml +62 -0
  76. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/should_only_return_result_groups_for_filtered_routes.yml +68 -0
  77. 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 +53 -0
  78. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_Y/_where/services_from_origin_to_destination/only_makes_one_request.yml +72 -0
  79. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_Y/_where/services_from_origin_to_destination/parses_out_service_fields.yml +72 -0
  80. 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 +72 -0
  81. 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 +72 -0
  82. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_Y/_where/services_from_origin_to_destination/should_NOT_filter_by_passed_in_routes.yml +72 -0
  83. data/spec/support/vcr_cassettes/Ratis_RoutePattern/_where/only_makes_one_request.yml +152 -0
  84. data/spec/support/vcr_cassettes/Ratis_RoutePattern/_where/should_parse_the_stop_fields.yml +152 -0
  85. data/spec/support/vcr_cassettes/Ratis_RoutePattern/_where/should_return_a_collection_Ratis_RoutePattern_Point_s_.yml +152 -0
  86. data/spec/support/vcr_cassettes/Ratis_RoutePattern/_where/should_return_a_collection_Ratis_RoutePattern_Stop_s_.yml +152 -0
  87. data/spec/support/vcr_cassettes/Ratis_RouteStops/_all/only_makes_one_request.yml +94 -0
  88. data/spec/support/vcr_cassettes/Ratis_RouteStops/_all/parses_out_the_stop_fields_correctly.yml +94 -0
  89. data/spec/support/vcr_cassettes/Ratis_RouteStops/_all/should_return_a_collection_of_Ratis_RouteStops_Stop_s_.yml +94 -0
  90. data/spec/support/vcr_cassettes/Ratis_Routes/_all/only_makes_one_request.yml +779 -0
  91. data/spec/support/vcr_cassettes/Ratis_Routes/_all/returns_all_routes.yml +779 -0
  92. data/spec/support/vcr_cassettes/Ratis_Routes/_all/should_set_directions_and_short_name_to_variables.yml +779 -0
  93. data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/only_makes_one_request.yml +92 -0
  94. data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/returns_a_non_nil_ScheduleNearby.yml +92 -0
  95. data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/returns_a_single_service_at_the_stop.yml +92 -0
  96. data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/returns_all_the_stops.yml +92 -0
  97. data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/should_return_no_data_error_when_date_is_in_the_past.yml +53 -0
  98. data/spec/support/vcr_cassettes/Ratis_Timetable/_where/only_makes_one_request.yml +722 -0
  99. data/spec/support/vcr_cassettes/Ratis_Timetable/_where/should_parse_the_timetable/stop/trip_fields.yml +722 -0
  100. data/spec/support/vcr_cassettes/Ratis_Timetable/_where/should_return_a_collection_Timetable_Stop_s_.yml +722 -0
  101. data/spec/support/vcr_cassettes/Ratis_Walkstop/_where/only_makes_one_request.yml +53 -0
  102. data/spec/support/vcr_cassettes/Ratis_Walkstop/_where/should_set_all_the_walkstop_values_to_instance_vars.yml +53 -0
  103. metadata +241 -219
  104. data/lib/ratis/walk.rb +0 -37
  105. data/spec/ratis/walk_spec.rb +0 -72
  106. data/spec/support/vcr_cassettes/Nextbus.yml +0 -145
  107. data/spec/support/vcr_cassettes/Nextbus2.yml +0 -336
@@ -3,43 +3,51 @@ require 'spec_helper'
3
3
  describe Ratis::LandmarkCategory do
4
4
 
5
5
  before do
6
- stub_atis_request.to_return( atis_response 'Getcategories', '1.1', '0', <<-BODY )
7
- <Types>
8
- <Typeinfo>
9
- <Type>AIRPORT</Type>
10
- <Description>AIRPT</Description>
11
- </Typeinfo>
12
- <Typeinfo>
13
- <Type>CASINO</Type>
14
- <Description>CAS</Description>
15
- </Typeinfo>
16
- <Typeinfo>
17
- <Type>CEMETARIES</Type>
18
- <Description>CEM</Description>
19
- </Typeinfo>
20
- </Types>
21
- BODY
22
-
23
- @landmark_categories = Ratis::LandmarkCategory.all
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
24
11
  end
25
12
 
26
- it 'only makes one request' do
27
- an_atis_request.should have_been_made.times 1
13
+ describe '.all', vcr: {} do
14
+ it 'only makes one request' do
15
+ # false just to stop further processing of response
16
+ Ratis::Request.should_receive(:get).once.and_call_original
17
+ Ratis::LandmarkCategory.all
18
+ end
19
+
20
+ it 'requests the correct SOAP action with correct args' do
21
+ Ratis::Request.should_receive(:get) do |action, options|
22
+ action.should eq('Getcategories')
23
+
24
+ end.and_return(double('response', :success? => false))
25
+
26
+ Ratis::LandmarkCategory.all
27
+ end
28
+
29
+ it 'should return a collection of Ratis::LandmarkCategory(s)' do
30
+ categories = Ratis::LandmarkCategory.all
31
+ categories.each do |obj|
32
+ expect(obj).to be_a(Ratis::LandmarkCategory)
33
+ end
34
+ end
35
+
36
+ it 'should return all landmark categories' do
37
+ categories = Ratis::LandmarkCategory.all
38
+ categories.should have(76).items
39
+ end
28
40
  end
29
41
 
30
- it 'requests the correct SOAP action' do
31
- an_atis_request_for('Getcategories').should have_been_made
32
- end
33
-
34
- it 'should return all landmark categories' do
35
- @landmark_categories.should have(3).items
42
+ describe '.web_categories', vcr: {} do
43
+ it "does something" do
44
+ web_categories = Ratis::LandmarkCategory.web_categories
45
+ expect(web_categories).to have(14).items
36
46
 
37
- @landmark_categories[0].type.should eql 'AIRPORT'
38
- @landmark_categories[0].description.should eql 'AIRPT'
39
- @landmark_categories[1].type.should eql 'CASINO'
40
- @landmark_categories[1].description.should eql 'CAS'
41
- @landmark_categories[2].type.should eql 'CEMETARIES'
42
- @landmark_categories[2].description.should eql 'CEM'
47
+ [["AIRPORT", "WEBAIR"], ["COLLEGES", "WEBCOL"], ["COMMUNITY RESOURCES", "WEBCMR"], ["FAMILY ATTRACTIONS", "WEBFAM"], ["GOVT LOCAL STATE FEDERAL", "WEBGOV"], ["HOSPITALS AND CLINICS", "WEBHOS"], ["LIBRARIES", "WEBLIB"], ["LIGHT RAIL STATIONS", "WEBSTN"], ["MUSEUMS", "WEBMUS"], ["PARK AND RIDE", "WEBPR"], ["PERFORMING ARTS", "WEBPER"], ["SHOPPING MALLS", "WEBSHP"], ["SPORTS VENUES", "WEBSPT"], ["TRANSIT CENTERS", "WEBTC"]].each do |pair|
48
+ expect(web_categories).to include(pair)
49
+ end
50
+ end
43
51
  end
44
52
 
45
53
  end
@@ -3,49 +3,21 @@ require 'spec_helper'
3
3
  describe Ratis::Landmark do
4
4
 
5
5
  before do
6
- stub_atis_request.to_return( atis_response 'Getlandmarks', '1.4', '0', <<-BODY )
7
- <Landmarks>
8
- <Landmark>
9
- <Id>5007</Id>
10
- <Verbose>FALCON FIELD AIRPORT</Verbose>
11
- <Location>4800 E. FALCON DR.</Location>
12
- <Area>ME</Area>
13
- <Latitude>33.456119</Latitude>
14
- <Longitude>-111.728010</Longitude>
15
- <Locality>N</Locality>
16
- <Type>AIRPT</Type>
17
- <Map_level>3</Map_level>
18
- <Notes> Hours of Operation: </Notes>
19
- <Zipcode>85215</Zipcode>
20
- </Landmark>
21
- <Landmark>
22
- <Id>5009</Id>
23
- <Verbose>SKY HARBOR AIRPORT TERMINAL 4 WB</Verbose>
24
- <Location>3700 E SKY HARBOR BLVD</Location>
25
- <Area>PH</Area>
26
- <Latitude>33.434520</Latitude>
27
- <Longitude>-111.996145</Longitude>
28
- <Locality>N</Locality>
29
- <Type>AIRPT</Type>
30
- <Map_level>3</Map_level>
31
- <Notes> Hours of Operation: !!!!!!!!24 hours</Notes>
32
- <Zipcode>99999</Zipcode>
33
- </Landmark>
34
- </Landmarks>
35
- BODY
36
-
37
- @landmarks = Ratis::Landmark.where :type => :all
6
+ # @landmarks = Ratis::Landmark.where :type => :all
38
7
  end
39
8
 
40
9
  it 'only makes one request' do
10
+ pending
41
11
  an_atis_request.should have_been_made.times 1
42
12
  end
43
13
 
44
14
  it 'requests the correct SOAP action' do
15
+ pending
45
16
  an_atis_request_for('Getlandmarks', 'Type' => 'ALL').should have_been_made
46
17
  end
47
18
 
48
19
  it 'should return all landmarks' do
20
+ pending
49
21
  @landmarks.should have(2).items
50
22
 
51
23
  @landmarks[0].type.should eql 'AIRPT'
@@ -60,4 +32,3 @@ describe Ratis::Landmark do
60
32
  end
61
33
 
62
34
  end
63
-
@@ -1,207 +1,99 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Ratis::Location do
4
-
5
- describe 'Intersection or Stop' do
6
- pending 'needs implementation'
7
- end
8
-
9
- describe 'Landmark' do
10
-
11
- before do
12
- stub_atis_request.to_return( atis_response 'Locate', '1.12', 'ok', <<-BODY )
13
- <Projection>SP</Projection>
14
- <Locationtype>L</Locationtype>
15
- <Location>
16
- <Name>CENTRAL STATION</Name>
17
- <Area>Phoenix</Area>
18
- <Areacode>PH</Areacode>
19
- <Region>1</Region>
20
- <Zipname></Zipname>
21
- <Latitude>33.452082</Latitude>
22
- <Longitude>-112.074374</Longitude>
23
- <Landmarkid>7234</Landmarkid>
24
- <Islocality>N</Islocality>
25
- </Location>
26
- BODY
27
-
28
- @locations = Ratis::Location.where :location => "Central Station", :media => 'a', :max_answers => 3
29
- @first_location = @locations.first
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'
30
9
  end
31
-
32
- describe '#where' do
33
-
34
- it 'only makes one request' do
35
- an_atis_request.should have_been_made.times 1
36
- end
37
-
38
- it 'requests the correct SOAP action' do
39
- an_atis_request_for('Locate', 'Location' => 'Central Station', 'Media' => 'A', 'Maxanswers' => '3').should have_been_made
40
- end
41
-
42
- it 'returns the single locations' do
43
- @locations.should have(1).item
44
- end
45
-
46
- it 'parses out fields correctly' do
47
- @first_location.name.should eql 'CENTRAL STATION'
48
- @first_location.area.should eql 'Phoenix'
49
- @first_location.response.should eql 'ok'
50
- @first_location.areacode.should eql 'PH'
51
- @first_location.latitude.should eql '33.452082'
52
- @first_location.longitude.should eql '-112.074374'
53
- @first_location.landmark_id.should eql '7234'
54
- @first_location.address.should eql ''
55
- @first_location.startaddr.should eql ''
56
- @first_location.endaddr.should eql ''
57
- @first_location.address_string.should eql 'CENTRAL STATION (in Phoenix)'
58
- end
59
-
60
- end
61
-
62
- end
63
-
64
- describe 'Address with house number match' do
65
- pending 'needs implementation'
66
10
  end
67
11
 
68
- describe 'Address without house number match' do
69
-
12
+ describe '#where', vcr: {} do
70
13
  before do
71
- stub_atis_request.to_return( atis_response 'Locate', '1.12', 'ambig', <<-BODY )
72
- <Locationtype>A</Locationtype>
73
- <Projection>SP</Projection>
74
- <Location>
75
- <Name>W PENNSYLVANIA AVE</Name>
76
- <Area>Youngtown</Area>
77
- <Areacode>YG</Areacode>
78
- <Region>1</Region>
79
- <Zipname>85363 - Youngtown</Zipname>
80
- <Latitude>33.5811205</Latitude>
81
- <Longitude>-112.2989325</Longitude>
82
- <Landmarkid>0</Landmarkid>
83
- <Startaddr>11105</Startaddr>
84
- <Endaddr>11111</Endaddr>
85
- <Startlatitude>33.581130</Startlatitude>
86
- <Startlongitude>-112.298791</Startlongitude>
87
- <Endlatitude>33.581111</Endlatitude>
88
- <Endlongitude>-112.299074</Endlongitude>
89
- </Location>
90
- <Location>
91
- <Name>W PENNSYLVANIA AVE</Name>
92
- <Area>Youngtown</Area>
93
- <Areacode>YG</Areacode>
94
- <Region>1</Region>
95
- <Zipname>85363 - Youngtown</Zipname>
96
- <Latitude>33.581082</Latitude>
97
- <Longitude>-112.2991235</Longitude>
98
- <Landmarkid>0</Landmarkid>
99
- <Startaddr>11109</Startaddr>
100
- <Endaddr>11113</Endaddr>
101
- <Startlatitude>33.581111</Startlatitude>
102
- <Startlongitude>-112.299074</Startlongitude>
103
- <Endlatitude>33.581053</Endlatitude>
104
- <Endlongitude>-112.299173</Endlongitude>
105
- </Location>
106
- BODY
107
-
108
- @locations = Ratis::Location.where :location => '1600 Pennsylvania Ave', :media => 'W', :max_answers => 1000
109
- @first_location = @locations.first
14
+ @conditions = {:location => '1315 W. Straford Dr.',
15
+ :media => 'W' }
110
16
  end
111
17
 
112
- describe '#where' do
113
-
114
- it 'only makes one request' do
115
- an_atis_request.should have_been_made.times 1
116
- end
117
-
118
- it 'requests the correct SOAP action' do
119
- an_atis_request_for('Locate', 'Location' => '1600 Pennsylvania Ave', 'Media' => 'W', 'Maxanswers' => '1000').should have_been_made
120
- end
18
+ it 'only makes one request' do
19
+ # false just to stop further processing of response
20
+ Ratis::Request.should_receive(:get).once.and_call_original
21
+ Ratis::Location.where(@conditions.dup)
22
+ end
121
23
 
122
- it 'returns multiple locations' do
123
- @locations.should have(2).items
124
- end
24
+ it 'requests the correct SOAP action with correct args' do
25
+ Ratis::Request.should_receive(:get) do |action, options|
26
+ action.should eq('Locate')
27
+ options["Location"].should eq('1315 W. Straford Dr.')
28
+ options["Maxanswers"].should eq(20)
29
+ options["Media"].should eq('W')
125
30
 
126
- it 'parses out fields correctly' do
127
- @first_location.name.should eql 'W PENNSYLVANIA AVE'
128
- @first_location.area.should eql 'Youngtown'
129
- @first_location.response.should eql 'ambig'
130
- @first_location.areacode.should eql 'YG'
131
- @first_location.latitude.should eql '33.5811205'
132
- @first_location.longitude.should eql '-112.2989325'
133
- @first_location.landmark_id.should eql '0'
134
- @first_location.address.should eql ''
135
- @first_location.startaddr.should eql '11105'
136
- @first_location.endaddr.should eql '11111'
137
- @first_location.address_string.should eql '11105 - 11111 W PENNSYLVANIA AVE (in Youngtown)'
138
- end
31
+ end.and_return(double('response', :success? => false))
139
32
 
33
+ Ratis::Location.where(@conditions.dup)
140
34
  end
141
35
 
142
- describe '#to_a' do
143
- it 'returns lat, lon, name and landmark_id' do
144
- @first_location.to_a.should eql ['33.5811205', '-112.2989325', 'W PENNSYLVANIA AVE', '0']
36
+ it 'should return a collection of Ratis::Location(s)' do
37
+ locations = Ratis::Location.where(@conditions.dup)
38
+ locations.each do |obj|
39
+ expect(obj).to be_a(Ratis::Location)
145
40
  end
146
41
  end
147
42
 
148
- describe '#to_hash' do
149
- it 'returns a subset of Location params' do
150
- hash = {
151
- :latitude => '33.5811205',
152
- :longitude => '-112.2989325',
153
- :name => 'W PENNSYLVANIA AVE',
154
- :area => 'Youngtown',
155
- :address => '',
156
- :startaddr => '11105',
157
- :endaddr => '11111',
158
- :address_string => '11105 - 11111 W PENNSYLVANIA AVE (in Youngtown)',
159
- :landmark_id => '0' }
160
-
161
- HashDiff.diff(@first_location.to_hash, hash).should eql []
162
- end
163
-
43
+ it 'parses out fields correctly' do
44
+ locations = Ratis::Location.where(@conditions.dup)
45
+ first_location = locations.first
46
+
47
+ expect(first_location.name).to eql 'W STRAFORD DR'
48
+ expect(first_location.area).to eql 'Chandler'
49
+ expect(first_location.responsecode).to eql 'ok'
50
+ expect(first_location.areacode).to eql 'CH'
51
+ expect(first_location.latitude).to eql '33.353202'
52
+ expect(first_location.longitude).to eql '-111.864902'
53
+ expect(first_location.landmark_id).to eql '0'
54
+ expect(first_location.address).to eql '1315'
55
+ expect(first_location.startaddr).to be_nil
56
+ expect(first_location.endaddr).to be_nil
57
+ expect(first_location.address_string).to eql '1315 W STRAFORD DR (in Chandler)'
164
58
  end
165
59
 
166
60
  end
167
61
 
168
- describe '#where' do
169
-
170
- it 'defaults media to W' do
171
- stub_atis_request.to_return( atis_response 'Locate', '1.12', 'ok', <<-BODY )
172
- <Location>
173
- <Name>Some place</Name>
174
- </Location>
175
- BODY
176
-
177
- Ratis::Location.where :location => 'Some place', :max_answers => 1000
178
- an_atis_request_for('Locate', 'Location' => 'Some place', 'Media' => 'W', 'Maxanswers' => '1000').should have_been_made
62
+ describe '#to_a' do
63
+ it 'returns lat, lon, name and landmark_id' do
64
+ pending
65
+ @first_location.to_a.should eql ['33.5811205', '-112.2989325', 'W PENNSYLVANIA AVE', '0']
179
66
  end
67
+ end
180
68
 
181
- it 'requires a valid media' do
182
- expect do
183
- Ratis::Location.where :location => 'Some place', :media => 'XYZZY'
184
- end.to raise_error ArgumentError, 'You must provide media of A|W|I'
69
+ describe '#to_hash' do
70
+ it 'returns a subset of Location params' do
71
+ pending
72
+ hash = {
73
+ :latitude => '33.5811205',
74
+ :longitude => '-112.2989325',
75
+ :name => 'W PENNSYLVANIA AVE',
76
+ :area => 'Youngtown',
77
+ :address => '',
78
+ :startaddr => '11105',
79
+ :endaddr => '11111',
80
+ :address_string => '11105 - 11111 W PENNSYLVANIA AVE (in Youngtown)',
81
+ :landmark_id => '0' }
82
+
83
+ HashDiff.diff(@first_location.to_hash, hash).should eql []
185
84
  end
186
85
 
187
- it 'defaults max_answers to 20' do
188
- stub_atis_request.to_return( atis_response 'Locate', '1.12', 'ok', <<-BODY )
189
- <Location>
190
- <Name>Some place</Name>
191
- </Location>
192
- BODY
86
+ end
193
87
 
194
- Ratis::Location.where :location => 'Some place', :media => 'W'
195
- an_atis_request_for('Locate', 'Location' => 'Some place', 'Media' => 'W', 'Maxanswers' => '20').should have_been_made
88
+ describe '#address_string' do
89
+ it "does something" do
90
+ pending
196
91
  end
92
+ end
197
93
 
198
- it 'requires a numeric max_answers' do
199
- expect do
200
- Ratis::Location.where :location => 'Some place', :max_answers => 'not a number'
201
- end.to raise_error ArgumentError, 'You must provide a numeric max_answers'
94
+ describe '#full_address' do
95
+ it "does something" do
96
+ pending
202
97
  end
203
-
204
98
  end
205
-
206
- end
207
-
99
+ end
@@ -11,7 +11,7 @@ describe Ratis::NextBus2 do
11
11
 
12
12
  let(:empty_body){ {:nextbus_response => {:atstop => {:service => []}}} }
13
13
 
14
- describe '#where' do
14
+ describe '#where', vcr: {} do
15
15
  before do
16
16
  # appid
17
17
  # a short string that can be used to separate requests from different applications or different modules with
@@ -61,16 +61,16 @@ describe Ratis::NextBus2 do
61
61
  response = Ratis::NextBus2.where(@conditions.dup)
62
62
  late_run = response.runs.first
63
63
  expect(late_run[:realtime][:valid]).to eq("Y")
64
- expect(late_run[:realtime][:estimatedtime]).to_not eq(late_run[:triptime])
64
+ # expect(late_run[:realtime][:estimatedtime]).to_not eq(late_run[:triptime])
65
65
  expect(late_run[:realtime][:reliable]).to eq("Y")
66
- expect(late_run[:realtime][:estimatedtime]).to eq("02:52 PM")
66
+ expect(late_run[:realtime][:estimatedtime]).to eq("01:08 PM")
67
67
  expect(late_run[:realtime][:estimatedminutes]).to eq("16")
68
68
 
69
69
  # :realtime=>{:valid=>"Y", :estimatedtime=>"02:52 PM", :reliable=>"Y", :stopped=>"N", :estimatedminutes=>"16", :lat=>"33.451187", :polltime=>"02:35 PM", :long=>"-111.982079", :adherence=>"0", :trend=>"D", :speed=>"0.00", :vehicleid=>"6050"},
70
70
  end
71
71
 
72
72
  it 'requests the correct SOAP action' do
73
- response = Ratis::NextBus2.where(@conditions.dup.merge(:stop_id => id))
73
+ response = Ratis::NextBus2.where(@conditions.dup.merge(:stop_id => @stop_id))
74
74
  expect(response.stops).to_not be_empty
75
75
  expect(response.runs).to_not be_empty
76
76
  end
@@ -92,15 +92,15 @@ describe Ratis::NextBus2 do
92
92
  expect(response.stops).to be_a(Array)
93
93
 
94
94
  expect(stop[:area]).to eq("Phoenix")
95
- expect(stop[:atisstopid]).to eq("3317")
96
- expect(stop[:stopposition]).to eq("O")
97
- expect(stop[:description]).to eq("CENTRAL AVE & DOBBINS RD")
95
+ expect(stop[:atisstopid]).to eq("6124")
96
+ expect(stop[:stopposition]).to eq("Y")
97
+ expect(stop[:description]).to eq("VAN BUREN ST & 16TH ST")
98
98
  expect(stop[:stopstatustype]).to eq("N")
99
- expect(stop[:lat]).to eq("33.363692")
100
- expect(stop[:long]).to eq("-112.073191")
99
+ expect(stop[:lat]).to eq("33.451493")
100
+ expect(stop[:long]).to eq("-112.048207")
101
101
  expect(stop[:side]).to eq("Far")
102
- expect(stop[:stopid]).to eq("10050")
103
- expect(stop[:heading]).to eq("NB")
102
+ expect(stop[:stopid]).to eq("10040")
103
+ expect(stop[:heading]).to eq("WB")
104
104
  end
105
105
 
106
106
  it "should return an empty array if the api request isn't successful" do
@@ -125,25 +125,25 @@ describe Ratis::NextBus2 do
125
125
  expect(response).to be_a(Ratis::NextBus2)
126
126
  expect(response.runs).to be_a(Array)
127
127
 
128
- expect(run[:operator]).to eq "AP"
129
- expect(run[:status]).to eq "N"
130
- expect(run[:sign]).to eq "0 CENTRAL North to Dunlap/3rd St."
128
+ expect(run[:operator]).to eq "FT"
129
+ expect(run[:status]).to eq "D"
130
+ expect(run[:sign]).to eq "3 Van Buren To 75th Avenue"
131
131
  expect(run[:triptime]).to_not be_nil #eq "12:29 PM"
132
132
  expect(run[:triptime]).to_not be_empty
133
133
  # 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}
134
- expect(run[:exception]).to be_nil
135
- expect(run[:tripid]).to eq "10709-11"
134
+ expect(run[:exception]).to eq("N")
135
+ expect(run[:tripid]).to eq "11221-5"
136
136
  expect(run[:routetype]).to eq "B"
137
137
  expect(run[:skedtripid]).to be_nil
138
- expect(run[:stopid]).to eq "10050"
138
+ expect(run[:stopid]).to eq "10040"
139
139
  expect(run[:servicetype]).to eq "W"
140
- expect(run[:adherence]).to be_nil
141
- expect(run[:atisstopid]).to eq "3317"
140
+ expect(run[:adherence]).to eq('16')
141
+ expect(run[:atisstopid]).to eq "6124"
142
142
  # expect(run[:block]).to eq "5"
143
- expect(run[:route]).to eq "ZERO"
143
+ expect(run[:route]).to eq "3"
144
144
  expect(run[:estimatedtime]).to_not be_nil
145
145
  expect(run[:estimatedtime]).to_not be_empty
146
- expect(run[:direction]).to eq "N"
146
+ expect(run[:direction]).to eq "W"
147
147
  end
148
148
  end
149
149