ratis 3.4.3 → 3.5.0

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.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG +40 -39
  5. data/README.md +1 -15
  6. data/lib/ratis/area.rb +1 -1
  7. data/lib/ratis/config.rb +2 -4
  8. data/lib/ratis/fleet_location.rb +2 -7
  9. data/lib/ratis/landmark.rb +1 -4
  10. data/lib/ratis/location.rb +1 -3
  11. data/lib/ratis/location_type_ahead.rb +1 -4
  12. data/lib/ratis/next_bus.rb +0 -2
  13. data/lib/ratis/next_bus2.rb +1 -3
  14. data/lib/ratis/plantrip.rb +1 -3
  15. data/lib/ratis/request.rb +5 -2
  16. data/lib/ratis/schedule_nearby.rb +1 -3
  17. data/lib/ratis/timetable.rb +1 -5
  18. data/lib/ratis/version.rb +1 -1
  19. data/lib/ratis/walkstop.rb +1 -3
  20. data/ratis.gemspec +15 -15
  21. data/spec/ratis/area_spec.rb +1 -10
  22. data/spec/ratis/closest_stop_spec.rb +0 -14
  23. data/spec/ratis/config_spec.rb +21 -30
  24. data/spec/ratis/core_ext_spec.rb +0 -11
  25. data/spec/ratis/fleet_location_spec.rb +8 -25
  26. data/spec/ratis/itinerary_spec.rb +0 -10
  27. data/spec/ratis/landmark_category_spec.rb +1 -12
  28. data/spec/ratis/landmark_spec.rb +12 -25
  29. data/spec/ratis/location_spec.rb +5 -16
  30. data/spec/ratis/location_type_ahead_item_spec.rb +11 -9
  31. data/spec/ratis/location_type_ahead_spec.rb +7 -21
  32. data/spec/ratis/next_bus2_spec.rb +67 -81
  33. data/spec/ratis/next_bus_spec.rb +20 -37
  34. data/spec/ratis/pattern_spec.rb +2 -10
  35. data/spec/ratis/plantrip_spec.rb +19 -18
  36. data/spec/ratis/point_2_point_spec.rb +3 -11
  37. data/spec/ratis/request_spec.rb +1 -20
  38. data/spec/ratis/route_pattern_spec.rb +2 -14
  39. data/spec/ratis/route_spec.rb +1 -10
  40. data/spec/ratis/route_stops_spec.rb +1 -10
  41. data/spec/ratis/routes_spec.rb +1 -9
  42. data/spec/ratis/schedule_nearby_spec.rb +1 -11
  43. data/spec/ratis/timetable_spec.rb +24 -44
  44. data/spec/ratis/walkstop_spec.rb +22 -47
  45. data/spec/spec_helper.rb +4 -3
  46. data/spec/support/vcr_cassettes/Nextbus2_running_LATE.yml +141 -1
  47. data/spec/support/vcr_cassettes/Nextbus_running_LATE.yml +2 -2
  48. data/spec/support/vcr_cassettes/Point2Point.yml +2 -2
  49. data/spec/support/vcr_cassettes/Ratis_Area/_all/only_makes_one_request.yml +19 -9
  50. data/spec/support/vcr_cassettes/Ratis_ClosestStop/_where/only_makes_one_request.yml +9 -9
  51. data/spec/support/vcr_cassettes/Ratis_ClosestStop/_where/parses_out_the_stop_fields_correctly.yml +9 -9
  52. data/spec/support/vcr_cassettes/Ratis_ClosestStop/_where/returns_multiple_locations.yml +9 -9
  53. data/spec/support/vcr_cassettes/Ratis_ClosestStop/_where/should_return_a_collection_of_Ratis_Stop_s_.yml +9 -9
  54. data/spec/support/vcr_cassettes/Ratis_FleetLocation/_current/only_makes_one_request.yml +661 -563
  55. data/spec/support/vcr_cassettes/Ratis_FleetLocation/_current/parses_out_the_vehicle_fields_correctly.yml +661 -584
  56. data/spec/support/vcr_cassettes/Ratis_FleetLocation/_current/returns_multiple_vehicles.yml +661 -575
  57. data/spec/support/vcr_cassettes/Ratis_FleetLocation/_current/should_return_a_collection_of_Ratis_Vehicle_s_.yml +661 -575
  58. data/spec/support/vcr_cassettes/Ratis_Landmark/_where/only_makes_one_request.yml +67 -1444
  59. data/spec/support/vcr_cassettes/Ratis_Landmark/_where/parses_out_the_landmark_fields_correctly.yml +67 -1444
  60. data/spec/support/vcr_cassettes/Ratis_Landmark/_where/returns_multiple_landmarks.yml +67 -1444
  61. data/spec/support/vcr_cassettes/Ratis_Landmark/_where/should_return_a_collection_of_Ratis_Landmark_s_.yml +67 -1444
  62. data/spec/support/vcr_cassettes/Ratis_LandmarkCategory/_all/only_makes_one_request.yml +9 -9
  63. data/spec/support/vcr_cassettes/Ratis_LandmarkCategory/_all/should_return_a_collection_of_Ratis_LandmarkCategory_s_.yml +9 -9
  64. data/spec/support/vcr_cassettes/Ratis_LandmarkCategory/_all/should_return_all_landmark_categories.yml +9 -9
  65. data/spec/support/vcr_cassettes/Ratis_LandmarkCategory/_web_categories/does_something.yml +9 -9
  66. data/spec/support/vcr_cassettes/Ratis_Location/_where/only_makes_one_request.yml +11 -11
  67. data/spec/support/vcr_cassettes/Ratis_Location/_where/parses_out_fields_correctly.yml +11 -11
  68. data/spec/support/vcr_cassettes/Ratis_Location/_where/should_return_a_collection_of_Ratis_Location_s_.yml +11 -11
  69. data/spec/support/vcr_cassettes/Ratis_LocationTypeAhead/_where/only_makes_one_request.yml +10 -10
  70. data/spec/support/vcr_cassettes/Ratis_LocationTypeAhead/_where/parses_out_fields_correctly.yml +10 -10
  71. data/spec/support/vcr_cassettes/Ratis_LocationTypeAhead/_where/should_return_a_collection_of_Ratis_LocationTypeAheadItem_s_.yml +10 -10
  72. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/multiple_services_returned/only_makes_one_request.yml +29 -28
  73. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/multiple_services_returned/returns_the_next_4_bus_times.yml +29 -28
  74. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/multiple_services_returned/should_map_all_the_services_to_service_openstruct_objects.yml +29 -28
  75. 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
  76. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/single_service_return/only_makes_one_request.yml +18 -17
  77. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/single_service_return/returns_the_next_bus_times.yml +18 -17
  78. 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
  79. data/spec/support/vcr_cassettes/Ratis_NextBus/_where/single_service_return/should_set_all_the_service_values_to_instance_vars.yml +18 -17
  80. data/spec/support/vcr_cassettes/Ratis_NextBus2/_where/runs/should_set_the_run_values_to_instance_vars.yml +125 -0
  81. data/spec/support/vcr_cassettes/Ratis_NextBus2/_where/single_next_bus/only_makes_one_request.yml +125 -0
  82. data/spec/support/vcr_cassettes/Ratis_NextBus2/_where/single_next_bus/requests_the_correct_SOAP_action.yml +125 -0
  83. data/spec/support/vcr_cassettes/Ratis_NextBus2/_where/stops/should_set_the_stop_values_to_instance_vars.yml +125 -0
  84. data/spec/support/vcr_cassettes/Ratis_Pattern/_all/only_makes_one_request.yml +12 -12
  85. data/spec/support/vcr_cassettes/Ratis_Pattern/_all/should_parse_the_route_info_fields.yml +12 -12
  86. data/spec/support/vcr_cassettes/Ratis_Pattern/_all/should_return_a_collection_Pattern_RouteInfo_s_.yml +12 -12
  87. data/spec/support/vcr_cassettes/Ratis_Pattern/_all/should_return_no_data_error_when_date_is_in_the_past.yml +5 -5
  88. data/spec/support/vcr_cassettes/Ratis_Plantrip/_where/creates_Ratis_Itineraries_for_each_trip_itinerary.yml +30 -30
  89. data/spec/support/vcr_cassettes/Ratis_Plantrip/_where/only_makes_one_request.yml +30 -30
  90. data/spec/support/vcr_cassettes/Ratis_Plantrip/_where/returns_a_Plantrip_object.yml +30 -30
  91. data/spec/support/vcr_cassettes/Ratis_Plantrip/_where/should_set_all_the_Plantrip_values_to_instance_vars.yml +30 -30
  92. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/gets_the_groups.yml +68 -74
  93. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/gets_the_trips_within_each_group.yml +68 -74
  94. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/only_makes_one_request.yml +68 -74
  95. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/parses_out_the_off_stop_fields.yml +68 -74
  96. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/parses_out_the_on_stop_fields.yml +68 -74
  97. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/parses_out_the_service.yml +68 -74
  98. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/parses_out_the_trip.yml +68 -74
  99. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/should_only_return_result_groups_for_filtered_route.yml +15 -17
  100. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_N/_where/should_only_return_result_groups_for_filtered_routes.yml +19 -21
  101. 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
  102. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_Y/_where/services_from_origin_to_destination/only_makes_one_request.yml +29 -29
  103. data/spec/support/vcr_cassettes/Ratis_Point2Point/Routesonly_Y/_where/services_from_origin_to_destination/parses_out_service_fields.yml +29 -29
  104. 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
  105. 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
  106. 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
  107. data/spec/support/vcr_cassettes/Ratis_RoutePattern/_where/only_makes_one_request.yml +133 -70
  108. data/spec/support/vcr_cassettes/Ratis_RoutePattern/_where/should_parse_the_stop_fields.yml +133 -70
  109. data/spec/support/vcr_cassettes/Ratis_RoutePattern/_where/should_return_a_collection_Ratis_RoutePattern_Point_s_.yml +132 -69
  110. data/spec/support/vcr_cassettes/Ratis_RoutePattern/_where/should_return_a_collection_Ratis_RoutePattern_Stop_s_.yml +133 -70
  111. data/spec/support/vcr_cassettes/Ratis_RouteStops/_all/only_makes_one_request.yml +50 -50
  112. data/spec/support/vcr_cassettes/Ratis_RouteStops/_all/parses_out_the_stop_fields_correctly.yml +50 -50
  113. data/spec/support/vcr_cassettes/Ratis_RouteStops/_all/should_return_a_collection_of_Ratis_RouteStops_Stop_s_.yml +50 -50
  114. data/spec/support/vcr_cassettes/Ratis_Routes/_all/only_makes_one_request.yml +346 -370
  115. data/spec/support/vcr_cassettes/Ratis_Routes/_all/returns_all_routes.yml +346 -370
  116. data/spec/support/vcr_cassettes/Ratis_Routes/_all/should_set_directions_and_short_name_to_variables.yml +346 -370
  117. data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/only_makes_one_request.yml +42 -41
  118. data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/returns_a_non_nil_ScheduleNearby.yml +42 -41
  119. data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/returns_a_single_service_at_the_stop.yml +42 -41
  120. data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/returns_all_the_stops.yml +42 -41
  121. data/spec/support/vcr_cassettes/Ratis_ScheduleNearby/_where/should_return_no_data_error_when_date_is_in_the_past.yml +5 -5
  122. data/spec/support/vcr_cassettes/Ratis_Timetable/_where/ATIS_call/should_not_throw_a_500.yml +719 -0
  123. data/spec/support/vcr_cassettes/Ratis_Timetable/_where/only_makes_one_request.yml +315 -315
  124. data/spec/support/vcr_cassettes/Ratis_Timetable/_where/should_parse_the_timetable/stop/trip_fields.yml +315 -315
  125. data/spec/support/vcr_cassettes/Ratis_Timetable/_where/should_return_a_collection_Timetable_Stop_s_.yml +315 -315
  126. data/spec/support/vcr_cassettes/Ratis_Walkstop/_where/only_makes_one_request.yml +9 -9
  127. data/spec/support/vcr_cassettes/Ratis_Walkstop/_where/should_set_all_the_walkstop_values_to_instance_vars.yml +9 -9
  128. metadata +9 -9
  129. data/.rvmrc +0 -1
  130. data/spec/support/vcr_cassettes/Ratis_LocationTypeAhead/_where/should_return_a_collection_of_Ratis_Location_s_.yml +0 -54
  131. 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
  132. 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
  133. 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
  134. 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
- 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
- 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 => @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
- action.should eq('Nextbus2')
52
- options["Stopid"].should eq(@stop_id)
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
- expect(response.stops).to_not be_empty
75
- expect(response.runs).to_not be_empty
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
- describe 'stops' do
86
- # TODO: should return Stops not hashes
87
- it 'should set the stop values to instance vars' do
88
- response = Ratis::NextBus2.where(@conditions.dup)
89
- stop = response.stops.first
90
-
91
- expect(response).to be_a(Ratis::NextBus2)
92
- expect(response.stops).to be_a(Array)
93
-
94
- expect(stop[:area]).to eq("Phoenix")
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
- expect(stop[:stopstatustype]).to eq("N")
99
- expect(stop[:lat]).to eq("33.451493")
100
- expect(stop[:long]).to eq("-112.048207")
101
- expect(stop[:side]).to eq("Far")
102
- expect(stop[:stopid]).to eq("10040")
103
- expect(stop[:heading]).to eq("WB")
104
- end
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
- end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running
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
- response = Ratis::NextBus2.where(@conditions.dup)
114
- expect(response).to be_a(Array)
115
- expect(response).to be_empty
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
- describe 'runs' do
120
- # TODO: should return Runs not hashes
121
- it "should set the run values to instance vars" do
122
- response = Ratis::NextBus2.where(@conditions.dup)
123
- run = response.runs.first
124
-
125
- expect(response).to be_a(Ratis::NextBus2)
126
- expect(response.runs).to be_a(Array)
127
-
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
- expect(run[:triptime]).to_not be_nil #eq "12:29 PM"
132
- expect(run[:triptime]).to_not be_empty
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 eq("N")
135
- expect(run[:tripid]).to eq "11221-5"
136
- expect(run[:routetype]).to eq "B"
137
- expect(run[:skedtripid]).to be_nil
138
- expect(run[:stopid]).to eq "10040"
139
- expect(run[:servicetype]).to eq "W"
140
- expect(run[:adherence]).to eq('16')
141
- expect(run[:atisstopid]).to eq "6124"
142
- # expect(run[:block]).to eq "5"
143
- expect(run[:route]).to eq "3"
144
- expect(run[:estimatedtime]).to_not be_nil
145
- expect(run[:estimatedtime]).to_not be_empty
146
- expect(run[:direction]).to eq "W"
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
 
@@ -1,24 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Ratis::NextBus 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
-
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 = {:app_id => 'ratis-specs', # a short string that can be used to separate requests from different applications or different modules with
20
- :type => 'N',
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
- @time = Chronic.parse('tomorrow at 3pm')
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 => @time }
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(@time.strftime("%H%M"))
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 => @time }
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["Appid"].should eq('ratis-specs')
101
- options["Date"].should eq(@time.strftime("%m/%d/%Y"))
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('D')
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["Appid"].should eq('ratis-specs')
151
- options["Date"].should eq(@time.strftime("%m/%d/%Y"))
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
- action.should eq('Nextbus')
252
- options["Time"].should eq(@time.strftime("%H%M") )
253
- options["Type"].should eq("N")
254
- options["Stopid"].should eq(@stop_id)
255
- options["Date"].should eq(@time.strftime("%m/%d/%Y") )
256
- options["Appid"].should eq("ratis-specs")
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
@@ -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('123130')
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("10/28/13")
61
+ expect(routeinfo.effective).to eq("04/28/14")
70
62
  expect(routeinfo.tripcount).to eq('51')
71
63
 
72
64
  end
@@ -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
- :walkdestination => "0.50",
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
- :walkspeed => " 2.00 "
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.013)
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 & 3RD AVE')
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.014)
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
@@ -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