-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unit tests so that they build and run with SPM, add instructions for
SPM to README.md.
- Loading branch information
Showing
39 changed files
with
1,123 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"object": { | ||
"pins": [ | ||
{ | ||
"package": "CwlCatchException", | ||
"repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "682841464136f8c66e04afe5dbd01ab51a3a56f2", | ||
"version": "2.1.0" | ||
} | ||
}, | ||
{ | ||
"package": "CwlPreconditionTesting", | ||
"repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "02b7a39a99c4da27abe03cab2053a9034379639f", | ||
"version": "2.0.0" | ||
} | ||
}, | ||
{ | ||
"package": "Nimble", | ||
"repositoryURL": "https://github.com/Quick/Nimble.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "e491a6731307bb23783bf664d003be9b2fa59ab5", | ||
"version": "9.0.0" | ||
} | ||
}, | ||
{ | ||
"package": "OHHTTPStubs", | ||
"repositoryURL": "https://github.com/AliSoftware/OHHTTPStubs.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "12f19662426d0434d6c330c6974d53e2eb10ecd9", | ||
"version": "9.1.0" | ||
} | ||
}, | ||
{ | ||
"package": "Quick", | ||
"repositoryURL": "https://github.com/Quick/Quick.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "0038bcbab4292f3b028632556507c124e5ba69f3", | ||
"version": "3.0.0" | ||
} | ||
} | ||
] | ||
}, | ||
"version": 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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions
45
ResponseDetective/Tests/Additions/TestBodyDeserializer.swift
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,45 @@ | ||
// | ||
// TestBodyDeserializer.swift | ||
// | ||
// Copyright © 2016-2020 Netguru S.A. All rights reserved. | ||
// Licensed under the MIT License. | ||
// | ||
|
||
import ResponseDetective | ||
#if SWIFT_PACKAGE | ||
import ResponseDetectiveObjC | ||
#endif | ||
|
||
/// A test body deserializer. | ||
internal final class TestBodyDeserializer: NSObject, BodyDeserializer { | ||
|
||
/// The closure for deserializing bodies. | ||
let deserializationClosure: @convention(block) (Data) -> String? | ||
|
||
/// Creates a general deserializer with given deserialization closure. | ||
/// | ||
/// - Parameter deserializationClosure: Implementation of `deserializeBody`. | ||
internal init(deserializationClosure: @escaping @convention(block) (Data) -> String?) { | ||
self.deserializationClosure = deserializationClosure | ||
} | ||
|
||
/// Creates a deserializer with fixed deserialized body. | ||
/// | ||
/// - Parameter fixedDeserializedBody: A fixed deserialized body. | ||
internal convenience init(fixedDeserializedBody: String?) { | ||
self.init { _ in fixedDeserializedBody } | ||
} | ||
|
||
/// Creates a deserializer which deserializes data into plaintext. | ||
internal convenience override init() { | ||
self.init { String(data: $0, encoding: .utf8) as String? } | ||
} | ||
|
||
// MARK: Implementation | ||
|
||
/// - SeeAlso: BodyDeserializer.deserializeBody(_:) | ||
internal func deserialize(body data: Data) -> String? { | ||
return deserializationClosure(data) | ||
} | ||
|
||
} |
73 changes: 73 additions & 0 deletions
73
ResponseDetective/Tests/Specs/BufferOutputFacilitySpec.swift
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,73 @@ | ||
// | ||
// BufferOutputFacilitySpec.swift | ||
// | ||
// Copyright © 2016-2020 Netguru S.A. All rights reserved. | ||
// Licensed under the MIT License. | ||
// | ||
|
||
import Foundation | ||
import Nimble | ||
import ResponseDetective | ||
import Quick | ||
|
||
internal final class BufferOutputFacilitySpec: QuickSpec { | ||
|
||
override func spec() { | ||
|
||
describe("BufferOutputFacility") { | ||
|
||
let sut = BufferOutputFacility() | ||
|
||
it("should buffer request representations") { | ||
let request = RequestRepresentation( | ||
identifier: "0", | ||
method: "GET", | ||
urlString: "http://foo.bar", | ||
headers: [ | ||
"X-Foo": "bar", | ||
"X-Baz": "qux", | ||
], | ||
body: nil, | ||
deserializedBody: "lorem ipsum" | ||
) | ||
sut.output(requestRepresentation: request) | ||
expect(sut.requestRepresentations.count).to(beGreaterThanOrEqualTo(1)) | ||
} | ||
|
||
it("should buffer response representation") { | ||
let response = ResponseRepresentation( | ||
requestIdentifier: "0", | ||
statusCode: 200, | ||
urlString: "http://foo.bar", | ||
headers: [ | ||
"X-Bar": "foo", | ||
"X-Qux": "baz", | ||
], | ||
body: nil, | ||
deserializedBody: "dolor sit amet" | ||
) | ||
sut.output(responseRepresentation: response) | ||
expect(sut.responseRepresentations.count).to(beGreaterThanOrEqualTo(1)) | ||
} | ||
|
||
it("should buffer error representations") { | ||
let error = ErrorRepresentation( | ||
requestIdentifier: "0", | ||
response: nil, | ||
domain: "foo.bar.error", | ||
code: 1234, | ||
reason: "just because", | ||
userInfo: [ | ||
"foo": "bar", | ||
"baz": "qux", | ||
] | ||
) | ||
sut.output(errorRepresentation: error) | ||
expect(sut.errorRepresentations.count).to(beGreaterThanOrEqualTo(1)) | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.