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
9.3k
4
Share
SwiftでHTTP通信のスタブ化 / Stubbing HTTP Requests in Swift
#33testing
Jiro Nagashima
February 28, 2015
More Decks by Jiro Nagashima
See All by Jiro Nagashima
グロースを加速するLooker活用 / Leveraging Looker to accelerate growth
hedjirog
3
3k
プロダクトの成長を支えるKPI / KPIs for growing your product
hedjirog
17
3.9k
UIViewPropertyAnimatorで実現するリッチなアニメーション表現
hedjirog
4
2.5k
ReactorKit at Wantedly
hedjirog
2
1k
ReactorKitを利用した緩やかなアーキテクチャの移行
hedjirog
3
1.5k
限られたリソースで進める段階的なSwit移行
hedjirog
2
5.4k
エンジニア・デザイナーで取り組むグロースハック
hedjirog
6
2.4k
iOS 10 時代のアニメーション / Introduction to UIViewPropertyAnimator
hedjirog
3
3.1k
How we use fastlane at Wantedly
hedjirog
9
11k
Other Decks in Technology
See All in Technology
AIエージェントの権限管理 2: データ基盤の Fine grained access control 編
ren8k
0
120
AI時代 に増える データ活用先
takahal
0
160
AzureのIaC管理からログ調査まで、随所に役立つSkillsとCustom-Instructions / Boosting IaC and Log Analysis with Skills
aeonpeople
0
180
最近の技術系の話題で気になったもの色々(IoT系以外も) / IoTLT 花見予定会(たぶんBBQ) @都立潮風公園バーベキュー広場
you
PRO
1
220
自立を加速させる神器 - EMOasis #11
stanby_inc
0
110
Claude Code を安全に使おう勉強会 / Claude Code Security Basics
masahirokawahara
2
18k
ぼくがかんがえたさいきょうのあうとぷっと
yama3133
0
180
AWS Agent Registry の基礎・概要を理解する/aws-agent-registry-intro
ren8k
2
340
Bill One 開発エンジニア 紹介資料
sansan33
PRO
6
18k
Introduction to Bill One Development Engineer
sansan33
PRO
0
410
みんなで作るAWS Tips 100連発 (FinOps編)
schwrzktz
1
270
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.1k
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
528
40k
How to make the Groovebox
asonas
2
2.1k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
680
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
130
KATA
mclloyd
PRO
35
15k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
180
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
260
[SF Ruby Conf 2025] Rails X
palkan
2
950
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Paper Plane (Part 1)
katiecoart
PRO
0
6.6k
HDC tutorial
michielstock
2
620
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
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