experience with Webmock and cucumber error

125 views
Skip to first unread message

James

unread,
Mar 13, 2012, 10:55:44 PM3/13/12
to webmock-users
Just to share with the group, (Cucumber 1.1.9, Webmock 1.8.2, Rails
3.2)

I had this error:

/Users/myacct/.rvm/gems/ruby-1.9.2-p290@xyz/gems/webmock-1.8.2/lib/
webmock/rspec.rb:23:in `<top (required)>'

I added these lines to solve the problem. Originally I had the
include code in the test.rb which someone suggested, but I think that
caused my cucumber error. If there is anything I'm missing please let
me know.

spec_helper.rb
require 'webmock/rspec'
include WebMock::API
WebMock.allow_net_connect!

in my cucumber env.rb
require 'webmock/cucumber'
WebMock.allow_net_connect! #to allow external connecting

Bartosz Blimke

unread,
Mar 14, 2012, 1:56:44 PM3/14/12
to webmoc...@googlegroups.com
Does it happen when you run cucumber or rspec?

It's difficult to say what's causing the error, without having a sample failing code.

webmock/rspec already includes WebMock::API, so you don't have to do that.

Bartosz

James

unread,
Mar 15, 2012, 2:25:12 AM3/15/12
to webmock-users
It seems to happen when I run cucumber, I think because I was missing
the require 'webmock/cucumber' in cucumber's env.rb. That's how I
got it to work.

Additionally, I have a rake task that seeds data from active resource
which requires network access, it seemed that by default outside of a
testing environment the network access was still blocked (by design
via webmock). I found that putting the below along with the includes
in cucumber and rspec environments allowed everything to work
together. Hope this helps someone.

test.rb
require 'webmock/rspec'
include WebMock::API
WebMock.allow_net_connect!



On Mar 14, 10:56 am, Bartosz Blimke <bartosz.bli...@gmail.com> wrote:
> Does it happen when you run cucumber or rspec?
>
> It's difficult to say what's causing the error, without having a sample
> failing code.
>
> webmock/rspec already includes WebMock::API, so you don't have to do that.
>
> Bartosz
>
Reply all
Reply to author
Forward
0 new messages