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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Harukasan
PRO
November 17, 2014
Technology
1
790
Rack::ClientSpec
Rack::ClientSpec can test your client behavior
社内勉強会用資料
Harukasan
PRO
November 17, 2014
Tweet
Share
More Decks by Harukasan
See All by Harukasan
Successor to PicoRabbit: Ruby Programming Envorinment / RubyKaigi 2025 follow up
harukasan
PRO
1
230
Write your own mrbgem, Create your own device
harukasan
PRO
1
300
PicoRabbit: a Tiny Presentation Device Powered by Ruby
harukasan
PRO
2
710
pixivを支える技術 / 技育CAMPアカデミア
harukasan
PRO
3
570
20240401 新卒研修 - ピクシブにおける技術領域
harukasan
PRO
1
910
ピクシブのコンテンツ配信基盤技術 / pixiv TECH SALON
harukasan
PRO
5
5.8k
Goにおける画像ファイル処理 / golang.tokyo #19
harukasan
PRO
7
6.8k
WebRTC動画をトランスコードする / Transcoding video streams from WebRTC
harukasan
PRO
5
1.7k
ImageFluxを支えるリモート開発 / 20171202
harukasan
PRO
2
1.9k
Other Decks in Technology
See All in Technology
The essence of decision-making lies in primary data
kaminashi
0
190
JEDAI認定プログラム JEDAI Order 2026 受賞者一覧 / JEDAI Order 2026 Winners
databricksjapan
0
410
GitHub Actions侵害 — 相次ぐ事例を振り返り、次なる脅威に備える
flatt_security
8
6.8k
Tour of Agent Protocols: MCP, A2A, AG-UI, A2UI with ADK
meteatamel
0
150
QA組織のAI戦略とAIテスト設計システムAITASの実践
sansantech
PRO
1
260
互換性のある(らしい)DBへの移行など考えるにあたってたいへんざっくり
sejima
PRO
0
380
FlutterでPiP再生を実装した話
s9a17
0
240
私がよく使うMCPサーバー3選と社内で安全に活用する方法
kintotechdev
0
140
パワポ作るマンをMCP Apps化してみた
iwamot
PRO
0
240
非同期・イベント駆動処理の分散トレーシングの繋げ方
ichikawaken
1
240
昔話で振り返るAWSの歩み ~S3誕生から20年、クラウドはどう進化したのか~
nrinetcom
PRO
0
120
CREがSLOを握ると 何が変わるのか
nekomaho
0
310
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
420
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
Designing for Performance
lara
611
70k
Testing 201, or: Great Expectations
jmmastey
46
8.1k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
310
Optimising Largest Contentful Paint
csswizardry
37
3.6k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
140
Bash Introduction
62gerente
615
210k
It's Worth the Effort
3n
188
29k
Skip the Path - Find Your Career Trail
mkilby
1
93
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
240
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ςετ͍ͨ͠ • όάϑΟοΫε