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
710
Rack::ClientSpec
Rack::ClientSpec can test your client behavior
社内勉強会用資料
Harukasan
PRO
November 17, 2014
Tweet
Share
More Decks by Harukasan
See All by Harukasan
pixivを支える技術 / 技育CAMPアカデミア
harukasan
PRO
3
360
20240401 新卒研修 - ピクシブにおける技術領域
harukasan
PRO
1
680
ピクシブのコンテンツ配信基盤技術 / pixiv TECH SALON
harukasan
PRO
5
5.3k
Goにおける画像ファイル処理 / golang.tokyo #19
harukasan
PRO
7
6.4k
WebRTC動画をトランスコードする / Transcoding video streams from WebRTC
harukasan
PRO
5
1.5k
ImageFluxを支えるリモート開発 / 20171202
harukasan
PRO
2
1.7k
YAPC::Fukuoka 前夜祭LT / Yet Another Pawoo Commit logs
harukasan
PRO
0
2.9k
YAPC::Fukuoka lunch session
harukasan
PRO
1
3k
マストドン会議: Pawoo / Mastodon Kaigi2
harukasan
PRO
2
430
Other Decks in Technology
See All in Technology
Apple/Google/Amazonの決済システムの違いを踏まえた定期購読課金システムの構築 / abema-billing-system
cyberagentdevelopers
PRO
1
190
独自ツール開発でスタジオ撮影をDX!「VLS(Virtual LED Studio)」 / dx-studio-vls
cyberagentdevelopers
PRO
0
110
[PyCon Korea 2024] Lightning Talk: PyPI패키지를 의심하세요
studioego
PRO
0
130
都市伝説バスターズ「WebアプリのボトルネックはDBだから言語の性能は関係ない」 - Kaigi on Rails 2024
osyoyu
13
4.8k
サイバーエージェントにおける生成AIのリスキリング施策の取り組み / cyber-ai-reskilling
cyberagentdevelopers
PRO
1
130
サイロ化した金融システムを、packwerk を利用して無事故でリファクタリングした話
coincheck_recruit
3
3.2k
現実のRuby/Railsアップグレード
takeyuweb
3
3.1k
Mackerelが取り組むオブザーバビリティ - Mackerel Tech Day
mackerelio
0
330
What's in a Postgres major release? An analysis of contributions in the v17 timeframe | Claire Giordano | PGConf EU 2024
clairegiordano
1
680
初心者に Vue.js を 教えるには
tsukuha
3
210
新卒1年目が挑む!生成AI × マルチエージェントで実現する次世代オンボーディング / operation-ai-onboarding
cyberagentdevelopers
PRO
0
100
話題のGraphRAG、その可能性と課題を理解する
hide212131
0
150
Featured
See All Featured
Building Your Own Lightsaber
phodgson
102
6k
Rails Girls Zürich Keynote
gr2m
93
13k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
KATA
mclloyd
29
13k
GraphQLの誤解/rethinking-graphql
sonatard
66
9.9k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
37
1.8k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
504
140k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
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ςετ͍ͨ͠ • όάϑΟοΫε