Add test to show failure case for string factories.#53
Open
jalcine wants to merge 1 commit intobernardolins:masterfrom
Open
Add test to show failure case for string factories.#53jalcine wants to merge 1 commit intobernardolins:masterfrom
jalcine wants to merge 1 commit intobernardolins:masterfrom
Conversation
1 similar comment
Owner
|
Hi @jalcine, thanks for your contribution! I think you want to make it clear that response factories only work with maps or strings that are in JSON format, right? This test you added will never pass, unless factories start to support plain text strings. Would you mind to change it to check if an error is raised so the test passes? I think something like this will do the work: test_with_server "basic factory usage with text" do
assert_raise FakeServer.Error, fn ->
route("/plain", MyResponseFactory.build(:plain_text))
end
endBtw you can test plain text responses by using a test_with_server "basic factory usage with text" do
route "/plain", FakeServer.Response.ok!("Hello World", %{"Content-Type" => "text/plain"})
response = HTTPoison.get!(FakeServer.address() <> "/plain")
assert response.body == "Hello World"
endPlease let me know if you have any problem using FakeServer! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a test case to show that using the response factory for non-map types causes a failure when attempting to build them. This makes it difficult to use this library for testing non-JSON like responses.