Skip to content

Commit

Permalink
Merge pull request #74 from goodgravy/master
Browse files Browse the repository at this point in the history
Include request info when NotMatchError occurs
  • Loading branch information
parroty committed Oct 23, 2016
2 parents aa8d09d + 412aeae commit 4a631ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/exvcr/handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ defmodule ExVCR.Handler do
end

defp get_response_from_server(request, recorder) do
raise_error_if_cassette_already_exists(recorder)
raise_error_if_cassette_already_exists(recorder, inspect(request))
adapter = ExVCR.Recorder.options(recorder)[:adapter]
response = :meck.passthrough(request)
|> adapter.hook_response_from_server
Expand All @@ -139,12 +139,14 @@ defmodule ExVCR.Handler do
response
end

defp raise_error_if_cassette_already_exists(recorder) do
defp raise_error_if_cassette_already_exists(recorder, request_description) do
file_path = ExVCR.Recorder.get_file_path(recorder)
if File.exists?(file_path) do
message = """
Request did not match with any one in the current cassette: #{file_path}.
Delete the current cassette with [mix vcr.delete] and re-record.
Request: #{request_description}
"""
raise ExVCR.RequestNotMatchError, message: message
end
Expand Down
2 changes: 1 addition & 1 deletion test/adapter_ibrowse_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ defmodule ExVCR.Adapter.IBrowseTest do
end

use_cassette "example_ibrowse_different" do
assert_raise ExVCR.RequestNotMatchError, fn ->
assert_raise ExVCR.RequestNotMatchError, ~r/different_from_original/, fn ->
:ibrowse.send_req('http://example.com/different_from_original', [], :get)
end
end
Expand Down

0 comments on commit 4a631ed

Please sign in to comment.