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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Harukasan
PRO
November 17, 2014
Technology
1
780
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
220
Write your own mrbgem, Create your own device
harukasan
PRO
1
240
PicoRabbit: a Tiny Presentation Device Powered by Ruby
harukasan
PRO
2
630
pixivを支える技術 / 技育CAMPアカデミア
harukasan
PRO
3
560
20240401 新卒研修 - ピクシブにおける技術領域
harukasan
PRO
1
900
ピクシブのコンテンツ配信基盤技術 / 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.6k
ImageFluxを支えるリモート開発 / 20171202
harukasan
PRO
2
1.9k
Other Decks in Technology
See All in Technology
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
1.4k
セキュリティについて学ぶ会 / 2026 01 25 Takamatsu WordPress Meetup
rocketmartue
1
300
Azure Durable Functions で作った NL2SQL Agent の精度向上に取り組んだ話/jat08
thara0402
0
190
顧客の言葉を、そのまま信じない勇気
yamatai1212
1
350
AI駆動PjMの理想像 と現在地 -実践例を添えて-
masahiro_okamura
1
110
茨城の思い出を振り返る ~CDKのセキュリティを添えて~ / 20260201 Mitsutoshi Matsuo
shift_evolve
PRO
1
280
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
10k
OCI Database Management サービス詳細
oracle4engineer
PRO
1
7.4k
StrandsとNeptuneを使ってナレッジグラフを構築する
yakumo
1
120
小さく始めるBCP ― 多プロダクト環境で始める最初の一歩
kekke_n
1
420
Agile Leadership Summit Keynote 2026
m_seki
1
620
Featured
See All Featured
Building Adaptive Systems
keathley
44
2.9k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
730
Done Done
chrislema
186
16k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
0
1.1k
KATA
mclloyd
PRO
34
15k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
170
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
Thoughts on Productivity
jonyablonski
74
5k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.2k
Bash Introduction
62gerente
615
210k
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ςετ͍ͨ͠ • όάϑΟοΫε