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
Rack::ClientSpec
Search
Harukasan
PRO
November 17, 2014
Technology
1
770
Rack::ClientSpec
Rack::ClientSpec can test your client behavior
社内勉強会用資料
Harukasan
PRO
November 17, 2014
Tweet
Share
More Decks by Harukasan
See All by Harukasan
PicoRabbit: a Tiny Presentation Device Powered by Ruby
harukasan
PRO
2
380
pixivを支える技術 / 技育CAMPアカデミア
harukasan
PRO
3
500
20240401 新卒研修 - ピクシブにおける技術領域
harukasan
PRO
1
800
ピクシブのコンテンツ配信基盤技術 / pixiv TECH SALON
harukasan
PRO
5
5.6k
Goにおける画像ファイル処理 / golang.tokyo #19
harukasan
PRO
7
6.7k
WebRTC動画をトランスコードする / Transcoding video streams from WebRTC
harukasan
PRO
5
1.6k
ImageFluxを支えるリモート開発 / 20171202
harukasan
PRO
2
1.8k
YAPC::Fukuoka 前夜祭LT / Yet Another Pawoo Commit logs
harukasan
PRO
0
3k
YAPC::Fukuoka lunch session
harukasan
PRO
1
3.1k
Other Decks in Technology
See All in Technology
Microsoft Build 2025 技術/製品動向 for Microsoft Startup Tech Community
torumakabe
2
270
あなたの声を届けよう! 女性エンジニア登壇の意義とアウトプット実践ガイド #wttjp / Call for Your Voice
kondoyuko
4
440
生成AI時代の開発組織・技術・プロセス 〜 ログラスの挑戦と考察 〜
itohiro73
0
150
Node-RED × MCP 勉強会 vol.1
1ftseabass
PRO
0
140
5min GuardDuty Extended Threat Detection EKS
takakuni
0
140
エンジニア向け技術スタック情報
kauche
1
250
AIの最新技術&テーマをつまんで紹介&フリートークするシリーズ #1 量子機械学習の入門
tkhresk
0
140
Amazon S3標準/ S3 Tables/S3 Express One Zoneを使ったログ分析
shigeruoda
4
480
SalesforceArchitectGroupOsaka#20_CNX'25_Report
atomica7sei
0
170
米国国防総省のDevSecOpsライフサイクルをAWSのセキュリティサービスとOSSで実現
syoshie
2
1.1k
AWS アーキテクチャ作図入門/aws-architecture-diagram-101
ma2shita
29
11k
Github Copilot エージェントモードで試してみた
ochtum
0
100
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Making Projects Easy
brettharned
116
6.3k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.4k
Making the Leap to Tech Lead
cromwellryan
134
9.3k
Designing for Performance
lara
609
69k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
The Invisible Side of Design
smashingmag
299
51k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Transcript
Rack::ClientSpec @harukasan / Δ͔͞Μ
ωλͳͷͰਅʹड͚͍͚ͯͳ͍
Web is based on a browser • Web͍͍ͩͨϒϥβ͕ਖ਼͍͜͠ͱ͕લఏʹͳ͍ͬͯΔ • ϒϥβ͕HTTP/HTML/CSS/JSΛ࣮ͯ͘͠ΕͯΔ͓͔͛Ͱ
ΒαʔϏεΛఏڙͰ͖Δ • ϒϥβ੍࡞ऀʹ಄͕͕͋Βͳ͍
Some clients are in the blackbox • ͱ͍͑શͯͷΫϥΠΞϯτͷڍಈ͕Θ͔ͬͯΔΘ͚Ͱͳ͍ • ISUCONͩͱΫϥΠΞϯτͷڍಈṖ
E2E test for server Server Mock send a request get
a response
Capybara it "returns 200" do visit '/' expect(page).to have_content 'Success'
end
Test a client
Test a client Mock Client send a response (if you
need) get a request
Rack::ClientSpec rubygems.org/gems/rack-client_spec
Rack::ClientSpec • ΫϥΠΞϯτͷڍಈΛαʔό͔ΒςετͰ͖Δ • Rack MiddlewareͳͷͰRackΠϯλʔϑΣʔεͳΒ͍͍ͩͨΈࠐΊΔ • Θ͟Θ͟ϞοΫΛͭ͘Βͳͯ͘αʔόʹΈࠐΊͯศར • power_assertศར
github.com/harukasan/rack-client_spec
Insert ClientSpec to your rack Server Client send a response
(if you need) get a request ClientSpec
Insert ClientSpec to your rack app require 'rack' require 'rack/lobster'
require 'rack/client_spec' require 'rack/lobster_spec' use Rack::ClientSpec, LobsterSpec # <- Insert Clientspec run Rack::Lobster.new
Write a test case require 'rack/client_spec' class LobsterSpec < Rack::ClientSpec::TestCase
# <-- test case def test_flip # <-- test method get '/' do |req, res| # <-- expect request assert { res.status == 200 } end get '/?flip=left' do |req, res| # <-- expect request assert { req['HTTP_REFERER'] == 'http://localhost:9292/' } end end end
TODO • ϦΫΤετͷ్தʹ༨ܭͳϦΫΤετ͕དྷΔͱ͚͜ΔͷΛͳ͓͢ • ϦΫΤετ͕དྷͳ͍͜ͱΛςετ͍ͨ͠ • Cache-Controlςετ͍ͨ͠ • όάϑΟοΫε