Skip to content

Commit

Permalink
Merge pull request #10 from chrismccord/patch-1
Browse files Browse the repository at this point in the history
Add httpc stub example which uses status_code list
  • Loading branch information
parroty committed Oct 2, 2014
2 parents e1a1c9a + a496884 commit e6dc85b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -389,6 +389,17 @@ test "stub request works for HTTPoison" do
assert response.status_code == 200
end
end

test "stub request works for httpc" do
use_cassette :stub, [url: "http://www.example.com",
method: "get",
status_code: ["HTTP/1.1", 200, "OK"],
body: "success!"] do

{:ok, result} = :httpc.request('http://example.com')
{{_http_version, _status_code = 200, _reason_phrase}, _headers, body} = result
assert to_string(body) == "success!"
end
```
If the specified `:url` parameter doesn't match requests called inside the `use_cassette` block, it raises `ExVCR.InvalidRequestError`. The `:url` can be regular expression string.
Expand Down

0 comments on commit e6dc85b

Please sign in to comment.