-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from joecorkerton/ignore-requests
Add ignore_localhost config option
- Loading branch information
Showing
7 changed files
with
93 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[ | ||
{ | ||
"request": { | ||
"body": "", | ||
"headers": [], | ||
"method": "get", | ||
"options": [], | ||
"request_body": "", | ||
"url": "http://localhost:34006/server" | ||
}, | ||
"response": { | ||
"binary": false, | ||
"body": "test_response_before", | ||
"headers": { | ||
"server": "Cowboy", | ||
"date": "Sun, 08 Apr 2018 12:50:46 GMT", | ||
"content-length": "20" | ||
}, | ||
"status_code": 200, | ||
"type": "ok" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
defmodule ExVCR.IgnoreLocalhostTest do | ||
use ExVCR.Mock | ||
use ExUnit.Case, async: false | ||
|
||
@port 34006 | ||
@url "http://localhost:#{@port}/server" | ||
|
||
setup_all do | ||
HTTPotion.start | ||
:ok | ||
end | ||
|
||
test "it does not record localhost requests when the config has been set" do | ||
use_cassette "ignore_localhost_on", ignore_localhost: true do | ||
HttpServer.start(path: "/server", port: @port, response: "test_response_before") | ||
assert HTTPotion.get(@url, []).body =~ ~r/test_response_before/ | ||
HttpServer.stop(@port) | ||
# this method call should NOT be mocked | ||
HttpServer.start(path: "/server", port: @port, response: "test_response_after") | ||
assert HTTPotion.get(@url, []).body =~ ~r/test_response_after/ | ||
HttpServer.stop(@port) | ||
end | ||
end | ||
|
||
test "it records localhost requests when the config has not been set" do | ||
use_cassette "ignore_localhost_unset" do | ||
HttpServer.start(path: "/server", port: @port, response: "test_response_before") | ||
assert HTTPotion.get(@url, []).body =~ ~r/test_response_before/ | ||
HttpServer.stop(@port) | ||
# this method call should be mocked | ||
HttpServer.start(path: "/server", port: @port, response: "test_response_after") | ||
assert HTTPotion.get(@url, []).body =~ ~r/test_response_before/ | ||
HttpServer.stop(@port) | ||
end | ||
end | ||
end |