Вопрос

I'd like to stub https call using webmock. Let's assume gateway url as https://some_gateway.com.

After doing:

stub_request(:post, 'https://some_gateway.com').with(body: {})

in specs.

I use Net::HTTP to generate request:

 Net::HTTP.post_form(URI.parse('https://some_gateway.com'), {})

I receive problem because Webmock expects https://some_gateway.com but receives version with added port 433 so: http://www.secure.fake-payment.com:443/gateway_prod so can't see registered stub.

How can I deal with this behavior ?

Это было полезно?

Решение

Take a look at the answer for this question: WebMock: Rspec - Test Facebook Validation by using JSON response

Your code will do http request with port 443 vs doing really https

Net::HTTP.post_form(URI.parse('https://some_gateway.com'), {})

And here you can find the answer how to do https request using Net::HTTP Using Net::HTTP.get for an https url

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top