Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rack::ClientSpec
Search
Harukasan
PRO
November 17, 2014
Technology
810
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rack::ClientSpec
Rack::ClientSpec can test your client behavior
社内勉強会用資料
Harukasan
PRO
November 17, 2014
Transcript
14 slides
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ςετ͍ͨ͠ • όάϑΟοΫε
More Decks by Harukasan
See All by Harukasan
Harucom Follow-up
harukasan
PRO
1
66
Building a Standalone Programming Environment
harukasan
PRO
1
2.2k
Successor to PicoRabbit: Ruby Programming Envorinment / RubyKaigi 2025 follow up
harukasan
PRO
1
1.4k
Write your own mrbgem, Create your own device
harukasan
PRO
1
540
PicoRabbit: a Tiny Presentation Device Powered by Ruby
harukasan
PRO
2
2k
pixivを支える技術 / 技育CAMPアカデミア
harukasan
PRO
3
670
20240401 新卒研修 - ピクシブにおける技術領域
harukasan
PRO
1
1k
ピクシブのコンテンツ配信基盤技術 / pixiv TECH SALON
harukasan
PRO
5
6k
Goにおける画像ファイル処理 / golang.tokyo #19
harukasan
PRO
7
6.9k
Other Decks in Technology
See All in Technology
Libérez Firefox et Thunderbird avec nos astuces
hellosct1
0
200
サーバーラックは作る時代! 3Dプリンターで作る10インチラックのススメ
jacopen
2
520
Fukurou Labo_Engineer_Deck
fukuroulabo
0
100
業務の傍らで進める改善ループエンジニアリング
bengo4com
1
250
フルTypeScript × AI駆動開発で開発量が数倍に (JSConf JP 2026 スポンサーLT:NCDC株式会社)
keitaibaraki
0
220
メディアアートを〈拡張〉する——器官学と個体化論を手がかりに
_kotobuki_
0
350
VTuberになってみた話
yoshimura_datam
0
100
Go でトランザクション、どう書いてますか?
knwoop
2
640
New Relicのアラート対応をClaude Codeで自動修正するワークフローを作った話
manabuseki
3
690
成長するID管理基盤における運用もコストも犠牲にしないオブザーバビリティ向上の実践 / Improving Observability for a Growing Identity Platform Without Adding Operational Burden or Cost
kaminashi
1
140
デザインシステムのフィードバックループをほぼ自動化した話
tongari07
0
730
Amazon EFS のマルウェアスキャンをClamAV で自前実装したら苦労した話
mtmtfactory01
0
130
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
The Curious Case for Waylosing
cassininazir
1
630
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
620
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
320
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.8k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
850
Believing is Seeing
oripsolob
1
290
Between Models and Reality
mayunak
4
610
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
290
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Accessibility Awareness
sabderemane
1
310
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
690