Skip to content

Commit

Permalink
Merge pull request #1016 from spikeheap/master
Browse files Browse the repository at this point in the history
Add net_http_connect_on_start example with explicit domain
  • Loading branch information
bblimke committed Feb 20, 2024
2 parents 3f4c320 + e5008c6 commit 9a27df8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -606,7 +606,11 @@ which can be passed to `WebMock.allow_net_connect!` and `WebMock.disable_net_con
WebMock.allow_net_connect!(net_http_connect_on_start: true)
```

This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`.
This forces WebMock Net::HTTP adapter to always connect on `Net::HTTP.start`. At the time of connection being made there is no information about the request or URL yet, therefore WebMock is not able to decide whether to stub a request or not and all connections are allowed. To enable connections only to a specific domain (e.g. your test server) use:

```ruby
WebMock.allow_net_connect!(net_http_connect_on_start: "www.example.com")
```

## Setting Expectations

Expand Down

0 comments on commit 9a27df8

Please sign in to comment.