Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SwiftでHTTP通信のスタブ化 / Stubbing HTTP Requests in S...

Jiro Nagashima
February 28, 2015

SwiftでHTTP通信のスタブ化 / Stubbing HTTP Requests in Swift

#33testing

Jiro Nagashima

February 28, 2015
Tweet

More Decks by Jiro Nagashima

Other Decks in Technology

Transcript

  1. extension QiitaAPI : MoyaPath { var path: String { switch

    self { case .Items: return "/api/v2/items" case .TagItems(let tagID): return "/api/v2/tags/\(tagID)/items" } } } ύεࢦఆ
  2. extension QiitaAPI : MoyaTarget { var baseURL: NSURL { return

    NSURL(string: "https://qiita.com")! } var sampleData: NSData { switch self { case .Items, .TagItems: return stubbedResponse("Items") } } } B63-ࢦఆ
  3. extension QiitaAPI : MoyaTarget { var baseURL: NSURL { return

    NSURL(string: "https://qiita.com")! } var sampleData: NSData { switch self { case .Items, .TagItems: return stubbedResponse("Items") } } } CελϒԽͨ͠ϨεϙϯεΛࢦఆ
  4. static func DefaultProvider() -> ReactiveMoyaProvider<QiitaAPI> { return ReactiveMoyaProvider(endpointsClosure: endpointsClosure) }

    static func StubbingProvider() -> ReactiveMoyaProvider<QiitaAPI> { return ReactiveMoyaProvider(endpointsClosure: endpointsClosure, stubResponses: true) } ϓϩόΠμఆٛ