Fakeweb + soap4r + RSpec

74 views
Skip to first unread message

zilkey

unread,
May 31, 2009, 4:37:37 PM5/31/09
to FakeWeb
I'm trying to get Fakeweb to intercept all of my soap4r calls in
rspec. I've got a spec that looks like this (pseudo code):

require File.expand_path(File.dirname(__FILE__) + '/../../
spec_helper')
require 'fakeweb'

describe MySoap4RClass do
before do
@credentials = SomeCredentials.new(:username =>
"foo", :password => "bar")
end

it "should intercept all calls to soap4r" do
FakeWeb.allow_net_connect = false
VerticalResponseProvider.vr_login(@credentials)
end
end

I would expect to get a NetConnectNotAllowed error, but instead it
does the network call and gives me the actual web service error.

Is there a way to intercept all HTTP calls from within soap4r? I'm
using the soap4r gem, v 1.5.8 and the fakeweb gem, v 1.2.3

Thanks,

Jeff

Matt Patterson

unread,
May 31, 2009, 6:18:15 PM5/31/09
to fakewe...@googlegroups.com
On 31 May 2009, at 21:37, zilkey wrote:

> I would expect to get a NetConnectNotAllowed error, but instead it
> does the network call and gives me the actual web service error.
>
> Is there a way to intercept all HTTP calls from within soap4r? I'm
> using the soap4r gem, v 1.5.8 and the fakeweb gem, v 1.2.3

If soap4r uses Net::HTTP then it should Just Work. I haven't looked at
soap4r's internals in a long time, but the last time I did it was
painful. I wouldn't be at all surprised if it just makes socket calls,
but I also wouldn't be surprised if some require arcana is going on
which breaks fakeweb - a version of soap4r is in the standard library,
and installing the gem broke Irb.

I guess I'm saying you'll need to dig into the internals, but I'd try
it without the soap4r gem too.

Matt

--
Matt Patterson | Design & Code
<ma...@reprocessed.org> | http://www.reprocessed.org/


Chris Kampmeier

unread,
May 31, 2009, 6:30:50 PM5/31/09
to FakeWeb
On May 31, 1:37 pm, zilkey <j...@zilkey.com> wrote:
> Is there a way to intercept all HTTP calls from within soap4r?  I'm
> using the soap4r gem, v 1.5.8 and the fakeweb gem, v 1.2.3

I took a look at soap4r's source just now, and it looks like it's
using httpclient, which is an alternative to Net::HTTP. So FakeWeb
won't be able to stub out those requests, since it works by changing
the internals of Net::HTTP.

However! Michael Shapiro has a fork on github that has support for
both Net::HTTP and httpclient. I haven't had time to fully review his
changes, yet, and they're based on an older version of FakeWeb, but
hey -- if you're interested, give it a try and let me know how it
works out. http://github.com/koudelka/fakeweb/commit/f98f40261517a7d80d13b09a13ebd1f796825090

In general, I'd love to get a multi-adapter thing going on. There are
a few really interesting alternatives out there, like curb, typhoeus,
etc.

Chris

Jeff Dean

unread,
Jun 1, 2009, 12:57:09 AM6/1/09
to fakewe...@googlegroups.com
Awesome - I'll check it out. Thanks.

Dr Nic Williams

unread,
Jun 1, 2009, 1:00:03 AM6/1/09
to fakewe...@googlegroups.com
Do we need "One HTTP Adapter To Rule Them All"?
--
Dr Nic Williams
Mocra - Premier iPhone and Ruby on Rails Consultants
w - http://mocra.com
twitter - @drnic
skype - nicwilliams
e - dr...@mocra.com
p - +61 412 002 126 or +61 7 3102 3237

Reply all
Reply to author
Forward
0 new messages