Last active
August 29, 2015 14:27
-
-
Save GE-N/478c5cd16c0acbf49251 to your computer and use it in GitHub Desktop.
bdd#3 stub success
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") { | |
// Result success | |
let successBlock: OHHTTPStubsResponseBlock = { request -> OHHTTPStubsResponse in | |
let success200 = "{\"success\": true}".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) | |
return OHHTTPStubsResponse(data: success200!, statusCode: 200, headers: nil) | |
} | |
let successStub = OHHTTPStubs.stubRequestsPassingTest(apiSendSMSStub, withStubResponse: successBlock) | |
var sendResult: APIResult? | |
SMSAPI.sendSMS("0801112222", text: "Hello, world", callback : { result in | |
result = sendResult | |
} | |
expect(sendResult).toNotEventually(beNil()) | |
expect(sendResult?.isSuccess()).toEventually(beTrue()) | |
OHHTTPStubs.removeStub(successStub) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment