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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Harukasan
PRO
November 17, 2014
Technology
800
1
Share
Rack::ClientSpec
Rack::ClientSpec can test your client behavior
社内勉強会用資料
Harukasan
PRO
November 17, 2014
More Decks by Harukasan
See All by Harukasan
Building a Standalone Programming Environment
harukasan
PRO
1
1.7k
Successor to PicoRabbit: Ruby Programming Envorinment / RubyKaigi 2025 follow up
harukasan
PRO
1
1.1k
Write your own mrbgem, Create your own device
harukasan
PRO
1
390
PicoRabbit: a Tiny Presentation Device Powered by Ruby
harukasan
PRO
2
1.6k
pixivを支える技術 / 技育CAMPアカデミア
harukasan
PRO
3
600
20240401 新卒研修 - ピクシブにおける技術領域
harukasan
PRO
1
940
ピクシブのコンテンツ配信基盤技術 / pixiv TECH SALON
harukasan
PRO
5
5.9k
Goにおける画像ファイル処理 / golang.tokyo #19
harukasan
PRO
7
6.8k
WebRTC動画をトランスコードする / Transcoding video streams from WebRTC
harukasan
PRO
5
1.7k
Other Decks in Technology
See All in Technology
Diagnosing performance problems without the guesswork
elenatanasoiu
0
160
関西に縁あるMicrosoft MVPsが語るCopilotの未来
kasada
0
1.2k
Dario Amodi『Policy on the AI Exponential』を理解する
nagatsu
0
180
Platform engineering for developers, architects & the rest of us (AI agents)
danielbryantuk
0
180
TypeScript Compiler APIとPHP-Parserを活用し、TypeScriptとPHPで型を共有する
shuta13
0
360
探して_入れて_作って_使う_Agent_Skills___LT.pdf
peintangos
2
160
Claude Codeを組織で使いこなす— サーバサイドAIエージェント運用の実践知
techtekt
PRO
0
200
LLMと共に進化するプロセスを目指して
ymatsuwitter
11
3k
地元にいないローカルオーガナイザーの立ち回り
uvb_76
1
470
先取りMaven4 ~16年ぶりのメジャーアップデート、その進化とは?~
ogiwarat
0
140
SIer20年! 培ったスキルがスタートアップで輝く時
shucho0103
0
340
Databricks 月刊サービスアップデート 2026年05月号
tyosi1212
0
210
Featured
See All Featured
We Are The Robots
honzajavorek
0
240
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
720
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.3k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
420
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
520
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
130
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
Embracing the Ebb and Flow
colly
88
5.1k
The Curious Case for Waylosing
cassininazir
1
370
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ςετ͍ͨ͠ • όάϑΟοΫε