Created
August 16, 2015 09:51
-
-
Save GE-N/508b17a3dfddac091153 to your computer and use it in GitHub Desktop.
BDD#3 stub fail
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
context("Send SMS") { | |
// Specify API to Stub | |
let apiSendSMSStub = OHHTTPStubsTestBlock = { request -> Bool in | |
return request.URL!.path == "/api/sendsms" | |
} | |
it("should success") { | |
... | |
} | |
it("should failed") { | |
let failBlock: OHHTTPStubsResponseBlock = { request -> OHHTTPStubsResponse in | |
return OHHTTPStubsResponse(fileAtPath: OHPathForFile("sendsms-err400.json", self.dynamicType)!, statusCode: 400, headers: nil) | |
} | |
let failStub = OHHTTPStubs.stubRequestsPassingTest(apiSendSMSStub, withStubResponse: failBlock) | |
var sendResult: APIResult? | |
SMSAPI.sendSMS("08011122229991123", text: "Hello, fail world", callback : { result in | |
result = sendResult | |
} | |
expect(sendResult).toNotEventually(beNil()) | |
expect(sendResult?.isSuccess()).toEventually(beFalse()) | |
OHHTTPStubs.removeStub(failStub) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment