require 'spec_helper'
describe Ratis::Itinerary do
describe 'single itinerary, single service' do
before do
stub_atis_request.to_return( atis_response 'Plantrip', '1.27', '0', <<-BODY )
33.452082-112.0743740Origin33.446347-112.0686890Destination07/26/2012TND 2.00 0.40.40.4N00.21WYVAN BUREN/1ST AVE LIGHT RAIL STATION1859VAN BUREN/1ST AVE LIGHT RAIL STATION
PH
33.452252-112.07508107/26/121088010012N11ONBFarNLTRLMetro light rail To Sycamore/MainEMETROW468801707414NLN00.0000000.000000N0001.750.000.850.003RD STREET/JEFFERSON LIGHT RAIL STATION19033RD STREET/JEFFERSON LIGHT RAIL STATION
PH
33.446270-112.06977707/26/121089210014N13ONBFarN0.07EY41.750.851|0|1.75|0.85~W|06:59 PM|07:03 PM|LTRL| |W|E|L|12|0|1956|14|46880|METRO|10880|11|10892|13|BUSFARE|0|0|0|R~1|46880|11|13N 0.63 0.920.2600.881
BODY
@itineraries = Ratis::Itinerary.where(
:date => '07/26/2012', :time => '1843', :minimize => 'T',
:origin_lat => '33.452082', :origin_long => '-112.074374',
:destination_lat => '33.446347', :destination_long => '-112.068689' )
end
describe '#where' do
it 'only makes one request' do
an_atis_request.should have_been_made.times 1
end
it 'requests the correct SOAP action' do
an_atis_request_for('Plantrip',
'Date' => '07/26/2012', 'Time' => '1843', 'Minimize' => 'T',
'Originlat' => '33.452082', 'Originlong' => '-112.074374',
'Destinationlat' => '33.446347', 'Destinationlong' => '-112.068689'
).should have_been_made
end
it 'returns one itinerary' do
@itineraries.should have(1).item
@itineraries.first.should be_a_kind_of Ratis::Itinerary
end
end
describe '#legs' do
it 'returns one leg' do
@itineraries.first.legs.should have(1).item
@itineraries.first.legs.first.should_not be_nil
end
end
it 'marshalls the members to their correct type' do
itinerary = @itineraries.first
itinerary.co2_auto = 0.881
itinerary.co2_transit = 0.260
itinerary.final_walk_dir = 'E'
itinerary.reduced_fare = 0.85
itinerary.regular_fare = 1.75
itinerary.transit_time = 4
end
end
describe 'three itineraries, each with multiple service' do
before do
stub_atis_request.to_return( atis_response 'Plantrip', '1.27', '0', <<-BODY )
33.452082-112.0743747234CENTRAL STATION33.432254-111.9046257542TEMPE MARKETPLACE07/31/2012TND 2.00 0.500.500.50N00.21WYVAN BUREN/1ST AVE LIGHT RAIL STATION0931VAN BUREN/1ST AVE LIGHT RAIL STATION
PH
33.452252-112.07508107/31/121088010012N11ONBFarNLTRLMetro light rail To Sycamore/MainEMETROW46860170273NLN00.0000000.000000N0001.750.000.850.00MCCLINTOCK DR/APACHE LIGHT RAIL STATION1007MCCLINTOCK DR/APACHE LIGHT RAIL STATION
TE
33.414688-111.90888207/31/121088710025N26ONBFarN0NMCCLINTOCK DR & APACHE BLVD1013MCCLINTOCK DR & APACHE BLVD
TE
33.414938-111.90910007/31/12343115090N32ONBFarN8181 Haydn/Mclintk To Raintree/NrthsightNVEOLIA-TEMW3824040824NBN00.0000000.000000N0001.750.000.850.00TEMPE MARKETPLACE1020TEMPE MARKETPLACE
TE
33.432256-111.90466107/31/121045314167N36unknownN0N493.501.702|0|3.50|1.70~W|09:31 AM|10:07 AM|LTRL| |W|E|L|10|0|1944|3|46860|METRO|10880|11|10887|26|BUSFARE|0|0|0|R~T|10:13 AM|10:20 AM|81| |W|N|B|2|0|1609|4|38240|VEOLIA-TEM|3431|32|10453|36|BUSFARE|0|0|0|B~2|46860|11|26|38240|32|36N12.3912.635.43712.1250.21WYVAN BUREN/1ST AVE LIGHT RAIL STATION0931VAN BUREN/1ST AVE LIGHT RAIL STATION
PH
33.452252-112.07508107/31/121088010012N11ONBFarNLTRLMetro light rail To Sycamore/MainEMETROW46860170273NLN00.0000000.000000N0001.750.000.850.00VETERANS WAY/COLLEGE LIGHT RAIL STATION0959VETERANS WAY/COLLEGE LIGHT RAIL STATION
TE
33.426222-111.93647707/31/121089510022N22ONBFarN0NTEMPE TRANSIT CENTER NORTH SIDE1031TEMPE TRANSIT CENTER NORTH SIDE
TE
33.425740-111.93592907/31/121104214163N42unknownN6262 Hardy/Guadalupe To Tempe MarketplaceNVEOLIA-TEMW3714040495NBN00.0000000.000000N0001.750.000.850.00TEMPE MARKETPLACE1044TEMPE MARKETPLACE
TE
33.432256-111.90466107/31/121045314167N51unknownN0N733.501.702|0|3.50|1.70~W|09:31 AM|09:59 AM|LTRL| |W|E|L|10|0|1944|3|46860|METRO|10880|11|10895|22|BUSFARE|0|0|0|R~T|10:31 AM|10:44 AM|62| |W|N|B|1|0|1279|5|37140|VEOLIA-TEM|11042|42|10453|51|BUSFARE|0|0|0|B~2|46860|11|22|37140|42|51N11.8212.085.52011.5970.21WYVAN BUREN/1ST AVE LIGHT RAIL STATION0931VAN BUREN/1ST AVE LIGHT RAIL STATION
PH
33.452252-112.07508107/31/121088010012N11ONBFarNLTRLMetro light rail To Sycamore/MainEMETROW46860170273NLN00.0000000.000000N0001.750.000.850.00MCCLINTOCK DR/APACHE LIGHT RAIL STATION1007MCCLINTOCK DR/APACHE LIGHT RAIL STATION
TE
33.414688-111.90888207/31/121088710025N26ONBFarN0NMCCLINTOCK DR & APACHE BLVD1043MCCLINTOCK DR & APACHE BLVD
TE
33.414938-111.90910007/31/12343115090N32ONBFarN8181 Haydn/Mclintk To Raintree/NrthsightNVEOLIA-TEMW3824140854NBN00.0000000.000000N0001.750.000.850.00TEMPE MARKETPLACE1050TEMPE MARKETPLACE
TE
33.432256-111.90466107/31/121045314167N36unknownN0N793.501.702|0|3.50|1.70~W|09:31 AM|10:07 AM|LTRL| |W|E|L|10|0|1944|3|46860|METRO|10880|11|10887|26|BUSFARE|0|0|0|R~T|10:43 AM|10:50 AM|81| |W|N|B|2|0|1610|4|38241|VEOLIA-TEM|3431|32|10453|36|BUSFARE|0|0|0|B~2|46860|11|26|38241|32|36N12.3912.635.43712.125
BODY
@itineraries = Ratis::Itinerary.where(
:date => '07/31/2012', :time => '0914', :minimize => 'T',
:origin_lat => '33.452082', :origin_long => '-112.074374',
:destination_lat => '33.432254', :destination_long => '-111.904625' )
end
describe '#where' do
it 'only makes one request' do
an_atis_request.should have_been_made.times 1
end
it 'requests the correct SOAP action' do
an_atis_request_for('Plantrip',
'Date' => '07/31/2012', 'Time' => '0914', 'Minimize' => 'T',
'Originlat' => '33.452082', 'Originlong' => '-112.074374',
'Destinationlat' => '33.432254', 'Destinationlong' => '-111.904625'
).should have_been_made
end
it 'returns three itineraries' do
@itineraries.should have(3).item
@itineraries.each { |itin| itin.should be_a_kind_of Ratis::Itinerary }
end
end
end
end