Skip to content

Instantly share code, notes, and snippets.

@subdigital
Created January 27, 2011 20:06
Show Gist options
  • Save subdigital/799132 to your computer and use it in GitHub Desktop.
Save subdigital/799132 to your computer and use it in GitHub Desktop.
Trying to get savon working with vcr, however it doesn't record the cassette file
VCR.config do |c|
c.cassette_library_dir = 'fixtures/cassettes'
c.stub_with :webmock
end
class VCRSavonTest < Test::Unit::TestCase
def setup
path = File.expand_path("../fixtures/cassettes", __FILE__)
`rm -rf #{path}`
end
def assert_cassette_exists(cassette_name)
file = "fixtures/cassettes/#{cassette_name}.yml"
assert(File.exists?(file), "Cassette #{file} not found")
end
#THIS SUCCEEDS
def test_it_works_with_basic_http_client
VCR.use_cassette('test_httpclient_request', :record => :new_episodes) do
client = HTTPClient.new
response = client.get("http://flux88.com")
assert_not_nil response
end
assert_cassette_exists('test_httpclient_request')
end
#THIS FAILS
def test_it_should_write_a_cassette_with_savon
VCR.use_cassette('savon_test_cassette', :record => :new_episodes) do
client = Savon::Client.new do
wsdl.document = 'http://www.webservicex.net/MortgageIndex.asmx?wsdl'
end
response = client.request :get_mortgage_index_monthly do |soap, wsdl, http|
http.headers['SOAPAction'] = 'http://www.webserviceX.NET/GetCurrentMortgageIndexByWeekly'
end
assert_not_nil response
end
assert_cassette_exists('savon_test_cassette')
end
end
if __FILE__ == $1
#run from command line
require 'test/unit/ui/console/testrunner'
Test::Unit::UI::Console::TestRunner.run(VCRSavonTest)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment