Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Using gem blocks all external HTTP requests #64

Closed
jdbann opened this issue Oct 12, 2016 · 2 comments
Closed

Using gem blocks all external HTTP requests #64

jdbann opened this issue Oct 12, 2016 · 2 comments

Comments

@jdbann
Copy link

jdbann commented Oct 12, 2016

Added FakeStripe to a test suite not currently using WebMock and it blocked a number of calls to third-party services. Whilst I eventually want to mock all those calls, I didn't expect this gem to block anything beyond Stripe. Looks like the problem line is this in the WebMock initialiser.

WebMock.disable_net_connect!(allow_localhost: true)

I can put in a PR to remove that line but wanted to check if there was a reason it was in there? My assumption is that so the gem would catch any requests to Stripe that didn't match the two stubbed requests:

# fake_stripe/fake_stripe.rb:35
    stub_request(:any, /api.stripe.com/).to_rack(FakeStripe::StubApp)
    stub_request(:any, /js.stripe.com/).to_rack(FakeStripe::StubApp)
@bopm
Copy link

bopm commented Apr 17, 2017

Still, it can be easily fixed by something like that:

# spec/support/fake_stripe.rb
require 'webmock/rspec'
require 'fake_stripe'

RSpec.configure do |config|
  config.before(:each) do
    FakeStripe.stub_stripe
    WebMock.disable!
    WebMock.enable!
    WebMock.disable_net_connect!(allow_localhost: true, allow: ['cloud.typography.com', 'cloud.typenetwork.com'])
  end
end

@stefannibrasil
Copy link
Contributor

Closing this because fake_stripe has been deprecated: #154

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants