Skip to content

Instantly share code, notes, and snippets.

@chrisroos
Created July 26, 2010 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisroos/490352 to your computer and use it in GitHub Desktop.
Save chrisroos/490352 to your computer and use it in GitHub Desktop.
Monkey patching soap4r to force it to use net/http so that we can mock/stub requests with Fakeweb
# HTTPStreamHandler will use httpclient if installed (which it will be if you've installed soap4r as a gem, as httpclient is listed as a dependency) and fall back to net/http if it's not. We want to force net/http so that we can use FakeWeb. This hack is pretty crappy because it relies on the implementation of Soap4r but it works so is good enough for now.
def force_soap4r_to_use_net_http!
require 'soap/netHttpClient'
SOAP::HTTPStreamHandler.send :remove_const, :Client
SOAP::HTTPStreamHandler.const_set(:Client, SOAP::NetHttpClient)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment