Bug in WebMock#net_connect_allowed? #173

aindustries opened this Issue Apr 3, 2012 · 1 comment

2 participants


in webmock/lib/webmock/webmock.rb

Lines 64 and 65 are missing parentheses after the &&

(Config.instance.allow.respond_to?(:include?) &&
Config.instance.allow.include?(uri.host) || Config.instance.allow.include?("#{uri.host}:#{uri.port}")))

When instance.allow is a regex, instance.allow does not respond to include? and so the first condition is false. Next the expression to the right of the || is tested. This causes an exception since instance.allow doesn't respond to include?

I haven't looked at the project in enough detail to see how you handle patch requests but the code fix is quick:

    (Config.instance.allow.respond_to?(:include?) &&
     (Config.instance.allow.include?(uri.host) || Config.instance.allow.include?("#{uri.host}:#{uri.port}"))))

Thanks for finding that bug. I'll fix it.

@bblimke bblimke closed this Apr 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment