Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unregister single URIs #51

Open
exchgr opened this issue Aug 27, 2014 · 0 comments
Open

Unregister single URIs #51

exchgr opened this issue Aug 27, 2014 · 0 comments

Comments

@exchgr
Copy link

exchgr commented Aug 27, 2014

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant