Skip to content

Commit

Permalink
Fixed JSON atom parsing spec
Browse files Browse the repository at this point in the history
  • Loading branch information
pcantrell committed Mar 19, 2019
1 parent 96207ed commit 896dd4a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Tests/Functional/ResponseDataHandlingSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,17 @@ class ResponseDataHandlingSpec: ResourceSpecBase
service().configureTransformer("**", atStage: .parsing)
{ try JSONSerialization.jsonObject(with: $0.content as Data, options: [.allowFragments]) }

for atom in ["17", "\"foo\"", "null"]
func expectJson<T: Equatable>(_ atom: String, toParseAs expectedValue: T)
{
_ = stubRequest(resource, "GET").andReturn(200)
.withHeader("Content-Type", "application/json")
.withBody(atom as NSString)
awaitNewData(resource().load())
print(resource().latestData?.content)
expect(resource().latestData?.content as? T) == expectedValue
}
expectJson("17", toParseAs: 17)
expectJson("\"foo\"", toParseAs: "foo")
expectJson("null", toParseAs: NSNull())
}

it("transforms error responses")
Expand Down

0 comments on commit 896dd4a

Please sign in to comment.