Skip to content

Instantly share code, notes, and snippets.

@seanhandley
Created February 9, 2011 14:22
Show Gist options
  • Save seanhandley/818547 to your computer and use it in GitHub Desktop.
Save seanhandley/818547 to your computer and use it in GitHub Desktop.
request_string = %w(<?xml version="1.0" encoding="utf-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><TaxiSearch xmlns="http://resorttaxis.cmhosts.net/services/TaxiBookingAPI"><agent_guid>6a6d416d-d219-4005-87bc-515ee36becae</agent_guid><res_id>1</res_id><travel_date>09/02/2011 13:42</travel_date></TaxiSearch></env:Body></env:Envelope>)
receive_string = %w(<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><TaxiSearchResponse xmlns="http://resorttaxis.cmhosts.net/services/TaxiBookingAPI"><TaxiSearchResult><xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"><xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:Locale="en-GB"><xs:complexType><xs:choice maxOccurs="unbounded"><xs:element name="Table"><xs:complexType><xs:sequence><xs:element name="taxi_id" type="xs:int" minOccurs="0" /><xs:element name="taxi_min_pass" type="xs:int" minOccurs="0" /><xs:element name="taxi_max_pass" type="xs:int" minOccurs="0" /><xs:element name="taxi_description" type="xs:string" minOccurs="0" /><xs:element name="Column1" type="xs:string" minOccurs="0" /><xs:element name="taxpr_price" type="xs:string" minOccurs="0" /><xs:element name="res_name" type="xs:string" minOccurs="0" /><xs:element name="res_transfer_time_hours" type="xs:int" minOccurs="0" /><xs:element name="res_transfer_time_mins" type="xs:int" minOccurs="0" /><xs:element name="taxtyp_name" type="xs:string" minOccurs="0" /><xs:element name="price_single" type="xs:double" minOccurs="0" /><xs:element name="price_return" type="xs:double" minOccurs="0" /><xs:element name="taxpr_return_sale_override" type="xs:double" minOccurs="0" /><xs:element name="taxpr_single_sale_override" type="xs:double" minOccurs="0" /></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema><diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><NewDataSet xmlns=""><Table diffgr:id="Table1" msdata:rowOrder="0"><taxi_id>1</taxi_id><taxi_min_pass>1</taxi_min_pass><taxi_max_pass>45</taxi_max_pass><taxi_description /><Column1>http://resorttaxis.cmhosts.net/images/taxis/coach.gif</Column1><taxpr_price>P</taxpr_price><res_name>Antigua</res_name><res_transfer_time_hours>0</res_transfer_time_hours><res_transfer_time_mins>15</res_transfer_time_mins><taxtyp_name>Shuttle Service</taxtyp_name><price_single>6.57</price_single><price_return>13.12</price_return></Table><Table diffgr:id="Table2" msdata:rowOrder="1"><taxi_id>305</taxi_id><taxi_min_pass>1</taxi_min_pass><taxi_max_pass>4</taxi_max_pass><taxi_description /><Column1>http://resorttaxis.cmhosts.net/images/taxis/private_taxi.gif</Column1><taxpr_price>V</taxpr_price><res_name>Antigua</res_name><res_transfer_time_hours>0</res_transfer_time_hours><res_transfer_time_mins>15</res_transfer_time_mins><taxtyp_name>Private Taxi</taxtyp_name><price_single>18.44</price_single><price_return>36.89</price_return></Table><Table diffgr:id="Table3" msdata:rowOrder="2"><taxi_id>1387</taxi_id><taxi_min_pass>1</taxi_min_pass><taxi_max_pass>45</taxi_max_pass><taxi_description /><Column1>http://resorttaxis.cmhosts.net/images/taxis/coach.gif</Column1><taxpr_price>P</taxpr_price><res_name>Antigua</res_name><res_transfer_time_hours>0</res_transfer_time_hours><res_transfer_time_mins>15</res_transfer_time_mins><taxtyp_name>Shuttle Service</taxtyp_name><price_single>5.59</price_single><price_return>11.18</price_return></Table></NewDataSet></diffgr:diffgram></TaxiSearchResult></TaxiSearchResponse></soap:Body></soap:Envelope>)
@data = SOAP::StreamHandler::ConnectionData.new
@data.should_receive(:receive_string).and_return(receive_string)
@data.should_receive(:request_string).and_return(request_string)
SOAP::StreamHandler::ConnectionData.stub(:new).and_return(@data)
@soap_property = SOAP::Property.new
SOAP::Property.stub(:new).and_return(@soap_property)
@soap_stream = SOAP::HTTPStreamHandler.new(@soap_property)
SOAP::HTTPStreamHandler.stub(:new).with(@soap_property).and_return(@soap_stream)
@soap_stream.should_receive(:send).with(any_args()).and_return(@data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment