Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SwiftでHTTP通信のスタブ化 / Stubbing HTTP Requests in S...
Search
Jiro Nagashima
February 28, 2015
Technology
4
9.1k
SwiftでHTTP通信のスタブ化 / Stubbing HTTP Requests in Swift
#33testing
Jiro Nagashima
February 28, 2015
Tweet
Share
More Decks by Jiro Nagashima
See All by Jiro Nagashima
グロースを加速するLooker活用 / Leveraging Looker to accelerate growth
hedjirog
3
2.7k
プロダクトの成長を支えるKPI / KPIs for growing your product
hedjirog
17
3.8k
UIViewPropertyAnimatorで実現するリッチなアニメーション表現
hedjirog
4
2.1k
ReactorKit at Wantedly
hedjirog
2
930
ReactorKitを利用した緩やかなアーキテクチャの移行
hedjirog
3
1.4k
限られたリソースで進める段階的なSwit移行
hedjirog
2
5.1k
エンジニア・デザイナーで取り組むグロースハック
hedjirog
6
2.3k
iOS 10 時代のアニメーション / Introduction to UIViewPropertyAnimator
hedjirog
3
3k
How we use fastlane at Wantedly
hedjirog
9
11k
Other Decks in Technology
See All in Technology
.NET 9 のパフォーマンス改善
nenonaninu
0
1k
ずっと昔に Star をつけたはずの思い出せない GitHub リポジトリを見つけたい!
rokuosan
0
150
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
350
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
190
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
250
コンテナセキュリティのためのLandlock入門
nullpo_head
2
320
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
170
AWS re:Invent 2024で発表された コードを書く開発者向け機能について
maruto
0
200
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
540
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
490
なぜCodeceptJSを選んだか
goataka
0
160
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
260
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
A Philosophy of Restraint
colly
203
16k
The Pragmatic Product Professional
lauravandoore
32
6.3k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Bash Introduction
62gerente
608
210k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Transcript
4XJGU Ͱ )551௨৴ͷελϒԽ !IFEKJSPH
ͳ͕͠·͡Ζ͏ !IFEKJSPH 4BOTBOגࣜձࣾ&JHIU
)551௨৴ͷελϒԽ
/-5)5514UVC4FSWFS ैདྷख๏ 0))5514UVCT FUD…
ΞϓϦ෦ͷαʔόʔ ैདྷख๏ /463-1SPUPDPMʹ४ڌͨ͠Ϋϥε .FUIPE4XJ[[MJOH
ʷΞϓϦ෦ͷαʔόʔ ैདྷख๏ ʷ/463-1SPUPDPMʹ४ڌͨ͠Ϋϥε ʷ.FUIPE4XJ[[MJOH
.PZB
None
None
.PZB w ωοτϫʔΫपΓͷநԽϨΠϠʔ w ςετ༻ͷελϒѻ͑Δ
Πϝʔδ͜Μͳײ͡ IUUQEFWFMPQFSIBUFOBTUBGGDPNFOUSZTNBSUBQJDMJFOUXJUITXJGU VTJOHFOVNBOEHFOFSJDT
IFEKJSPH2JJUB'FFE
"1*ͷهड़
enum QiitaAPI { case Items case TagItems(String) } FOVNఆٛ
extension QiitaAPI : MoyaPath { var path: String { switch
self { case .Items: return "/api/v2/items" case .TagItems(let tagID): return "/api/v2/tags/\(tagID)/items" } } } ύεࢦఆ
extension QiitaAPI : MoyaTarget { var baseURL: NSURL { return
NSURL(string: "https://qiita.com")! } var sampleData: NSData { switch self { case .Items, .TagItems: return stubbedResponse("Items") } } } B63-ࢦఆ
extension QiitaAPI : MoyaTarget { var baseURL: NSURL { return
NSURL(string: "https://qiita.com")! } var sampleData: NSData { switch self { case .Items, .TagItems: return stubbedResponse("Items") } } } CελϒԽͨ͠ϨεϙϯεΛࢦఆ
ϓϩόΠμͷΓସ͑
static func DefaultProvider() -> ReactiveMoyaProvider<QiitaAPI> { return ReactiveMoyaProvider(endpointsClosure: endpointsClosure) }
static func StubbingProvider() -> ReactiveMoyaProvider<QiitaAPI> { return ReactiveMoyaProvider(endpointsClosure: endpointsClosure, stubResponses: true) } ϓϩόΠμఆٛ
QiitaProvider.sharedProvider = QiitaProvider.StubbingProvider() Γସ͑
IUUQTHJUIVCDPNBSUTZFJEPMPO ࢀߟ IUUQTHJUIVCDPN"TI'VSSPX.PZB σϞ IUUQTHJUIVCDPNIFEKJSPH2JJUB'FFE