-
Notifications
You must be signed in to change notification settings - Fork 43
/
PactSSLSpecs.swift
47 lines (41 loc) · 1.56 KB
/
PactSSLSpecs.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import Quick
import Nimble
import PactConsumerSwift
class PactSwiftSSLSpec: QuickSpec {
override func spec() {
var animalMockService: MockService?
var animalServiceClient: AnimalServiceClient?
describe("tests fulfilling all expected interactions over HTTPS") {
beforeEach {
let pactVerificationService = PactVerificationService(
url: "https://localhost",
port: 2345,
allowInsecureCertificates: true
)
animalMockService = MockService(
provider: "Animal Service",
consumer: "Animal Consumer Swift",
pactVerificationService: pactVerificationService
)
animalServiceClient = AnimalServiceClient(baseUrl: animalMockService!.baseUrl)
}
it("gets an alligator") {
animalMockService!.given("an alligator exists")
.uponReceiving("a request for all alligators")
.withRequest(method:.GET, path: "/alligators")
.willRespondWith(status: 200,
headers: ["Content-Type": "application/json"],
body: [ ["name": "Mary", "type": "alligator"] ])
//Run the tests
animalMockService!.run(timeout: 10000) { (testComplete) -> Void in
animalServiceClient!.getAlligators( { (alligators) in
expect(alligators[0].name).to(equal("Mary"))
testComplete()
}, failure: { (error) in
testComplete()
})
}
}
}
}
}