Skip to content

Unregister single URIs #51

@exchgr

Description

@exchgr

It would be great if we had the ability to unregister a single URI. The use case for this would be in specs, where we would ideally want fake URIs to only last the duration of each example, to decrease dependency on the order in which tests are run. For example:

context "with a FakeWeb URI" do
  before do
    FakeWeb.register_uri :any, %r{somerequest.com} # ...
  end

  after do
    FakeWeb.unregister_uri %r{somerequest.com}
  end

  scenario "responds to somerequest.com" do
    expect(Net::HTTP).to receive(:get).with(URI.parse "http://somerequest.com/").and_return(anything)
  end
end

context "without a FakeWeb URI" do
  scenario "doesn't respond to somerequest.com" do
    expect(Net::HTTP).to receive(:get).with(URI.parse "http://somerequest.com/").and_return(nil) # or whatever
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions