adding webmock gem without require disables http #205

Closed
bfetler opened this Issue Aug 16, 2012 · 1 comment

Comments

Projects
None yet
2 participants
@bfetler

bfetler commented Aug 16, 2012

I'd like to have some tests that do a real http request, and some that stub/mock http. I have several working rspec tests using http without webmock. If I add the webmock gem, even without require 'webmock/rspec', all the tests fail. Adding WebMock.allow_net_connect! fixes it, of course.

This seems non-intuitive. I'd think allow_net_connect would be the default, and would only be disabled if you require 'webmock/rspec' or add a line Webmock.disable_net_connect! Seems a little inconvenient, not a huge issue.

webmock version 1.8.9
ruby version 1.9.3
rails version 3.2.3

@bblimke

This comment has been minimized.

Show comment Hide comment
@bblimke

bblimke Aug 17, 2012

Owner

That's correct, WebMock when required disabled all connections by default, and this is by design.
This may seem non-intuitive but it helps to prevent making real requests from your tests if you don't
expect them (and in most cases people don't want tests to make any real requests).

I suggest you either use WebMock.allow_net_connect! or WebMock.disable! in your rspec before hooks.

Owner

bblimke commented Aug 17, 2012

That's correct, WebMock when required disabled all connections by default, and this is by design.
This may seem non-intuitive but it helps to prevent making real requests from your tests if you don't
expect them (and in most cases people don't want tests to make any real requests).

I suggest you either use WebMock.allow_net_connect! or WebMock.disable! in your rspec before hooks.

@bblimke bblimke closed this Aug 17, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment