Globally allowed addresses

11 views
Skip to first unread message

Dylan Lacey

unread,
Jun 30, 2014, 7:36:02 AM6/30/14
to webmoc...@googlegroups.com
It would be great to have the ability to add addresses to a list that should be always allowed, even when disable_net_access is called without the :allow option (or when you toggle between disabling and enabling allowing addresses).

I've got a working fork here: https://github.com/DylanLacey/webmock/tree/ae3a21d4ea8d7b79ff1836eaa74e5b10ddbb5d0d with a proposed model.

`WebMock.always_allow address` will add an address to the list
`WebMock.clear_always_allowed_list` will erase the list
`WebMock.disable_net_access!(:ignore_global_allow_list)` will over-ride that list for a specific disabling.

The reason I'd like this feature, is that I maintain a library (http://www.github.com/saucelabs/sauce_ruby) which requires access to the 'net in order to work.  There's a webmock helper included which copies all the user's existing WebMock configuration and calls `disable_net_access` again with all the existing options, as well as the address the library needs to be able to hit.

Sometimes users will include the helper before configuring WebMock, so it doesn't work.  We included it to help users get up and running faster, and it would be great if we could add an address to a global allow list, so that it doesn't matter how users configure WebMock, the Sauce gem will still play nicely.  I can imagine this being useful for other purposes as well;  Other gems that need to access specific addresses, or toggling net access on and off multiple times with a partially similar exclusion list.

Happy to turn the link above into a PR, just wanted to open things up for suggestion first.

Cheers,
Dylan.

Bartosz Blimke

unread,
Jul 30, 2014, 4:27:01 PM7/30/14
to webmoc...@googlegroups.com
Hi Dylan,

I understand your requirements and I the solution you proposed makes sense in order to solve it.

I think it would make WebMock api unnecessarily complex and confusing for rather rare cases of being useful though.
I can't think of any good solution, so I'm not rejecting this solution yet, but I'll think about it or possibly better solution.

I think enabling and disabling net connect should be redesigned in version 2.0 of webmock anyway. I'm not sure when that happens though.

Bartosz


--

---
You received this message because you are subscribed to the Google Groups "webmock-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webmock-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages