module RatisHelpers def stub_atis_request stub_request :post, 'http://example.com/soap.cgi' end def an_atis_request a_request :post, 'http://example.com/soap.cgi' end def an_atis_request_for(action, params = {}) an_atis_request.with do |request| request.headers['Soapaction'] == %Q{"TEST_NS##{ action }"} params_body = { action => params.merge( { 'xmlns' => 'TEST_NS' } ) } request_body = Hash.from_xml(request.body)['Envelope']['Body'] HashDiff.diff(params_body, request_body).should eql [] end end def atis_response action, version, action_response_code, action_response_body { :body => <<-BODY } #{ action_response_code } #{ version } #{ action_response_body } XML schema Copyright (c) 2011 Trapeze Software, Inc., all rights reserved. 2.4.4 - 08/31/11 BODY end def atis_error_response fault_code, fault_string { :body => <<-BODY } SOAP-ENV:#{ fault_code } #{ fault_string } #{ fault_code } BODY end def atis_response_timetable params = {} <<-BODY #{params[:route] || '0' } #{ params[:direct] || 'N' } #{ params[:service_type] || 'W' } 0 North to Road St. #{ params[:operator] || 'OP' } #{ params[:effective] || '01/15/2012' } 1337 80085 ALPHA ST & BETA RD Townsville 001-001 999 My trip comment #{ Time.now.strftime '%m/%d/%y' } #{ 120.times.map{['y','n'].sample} } comment_code_trip comment_code_request My request comment BODY end end