failure to match api.wunderground.com #73

Closed
nbt opened this Issue Feb 16, 2011 · 2 comments

2 participants

@nbt

I would expect the following to work. Instead, it fails with WebMock::NetConnectNotAllowedError.

require 'webmock/rspec'
include WebMock::API
describe "my_spec" do
  it "example1" do
    stub_request(:get, "api.wunderground.com").to_return(:body => "problem")
    Net::HTTP.get("api.wunderground.com", "/auto/wui/geo/GeoLookupXML/index.xml?query=41.0836882,-96.1343773")
  end
end

However, it does work with the regex form:
stub_request(:get, %r{.api.wunderground.com.}).to_return(:body => "problem")

@bblimke
Owner

WebMock won't match uri without the full path specified.
You either have to specify full uri i.e. stub_request(:get, "api.wunderground.com/auto/wui/geo/GeoLookupXML/index.xml") or use regex.

@bblimke
Owner

If you have any more questions feel free to send a message.

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