Fakeweb + soap4r + RSpec

74 vues
Accéder directement au premier message non lu

zilkey

non lue,
31 mai 2009, 16:37:3731/05/2009
à 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

non lue,
31 mai 2009, 18:18:1531/05/2009
à 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

non lue,
31 mai 2009, 18:30:5031/05/2009
à 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

non lue,
1 juin 2009, 00:57:0901/06/2009
à fakewe...@googlegroups.com
Awesome - I'll check it out. Thanks.

Dr Nic Williams

non lue,
1 juin 2009, 01:00:0301/06/2009
à 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

Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message