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
Test Driving Goliath
Search
Tom Clements
April 20, 2012
Programming
1
100
Test Driving Goliath
Introduction to testing Goliath, demo code available here
https://github.com/seenmyfate/read_later
Tom Clements
April 20, 2012
Tweet
Share
More Decks by Tom Clements
See All by Tom Clements
Cucumber - Doing it Right
seenmyfate
3
180
git - the stupid content tracker
seenmyfate
2
130
Give
seenmyfate
1
130
4 Steps to Faster Rails Tests
seenmyfate
5
630
Other Decks in Programming
See All in Programming
ELYZA_Findy AI Engineering Summit登壇資料_AIコーディング時代に「ちゃんと」やること_toB LLMプロダクト開発舞台裏_20251216
elyza
2
950
re:Invent 2025 トレンドからみる製品開発への AI Agent 活用
yoskoh
0
580
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
600
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
240
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
2k
Combinatorial Interview Problems with Backtracking Solutions - From Imperative Procedural Programming to Declarative Functional Programming - Part 2
philipschwarz
PRO
0
130
大規模Cloud Native環境におけるFalcoの運用
owlinux1000
0
240
脳の「省エネモード」をデバッグする ~System 1(直感)と System 2(論理)の切り替え~
panda728
PRO
0
130
[AI Engineering Summit Tokyo 2025] LLMは計画業務のゲームチェンジャーか? 最適化業務における活⽤の可能性と限界
terryu16
2
240
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
340
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
150
Cap'n Webについて
yusukebe
0
160
Featured
See All Featured
[SF Ruby Conf 2025] Rails X
palkan
0
680
Game over? The fight for quality and originality in the time of robots
wayneb77
1
74
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
140
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
We Have a Design System, Now What?
morganepeng
54
8k
Getting science done with accelerated Python computing platforms
jacobtomlinson
0
89
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Amusing Abliteration
ianozsvald
0
84
Why Our Code Smells
bkeepers
PRO
340
58k
Designing for Timeless Needs
cassininazir
0
110
YesSQL, Process and Tooling at Scale
rocio
174
15k
Transcript
Test Driving Goliath Tom Clements Senior Developer, On The Beach
tom-clements.com | github.com/seenmyfate @Seenmyfate
Goliath is an open source non-blocking asynchronous Ruby web server
framework
powered by an EventMachine reactor a high-performance HTTP parser Rack
Ruby 1.9 runtime (MRI, JRuby Rubinius)
High fibers Each HTTP request within Goliath is executed in
its own Ruby fiber all asynchronous I/O operations can suspend and resume without additional code
Hello, world $ gem install goliath
class HelloWorld < Goliath::API def response(env) [200, {}, "Hello, world"]
end end
Start the server $ ruby hello_world.rb -sv
Read Later A demo Single Endpoint Fire and forget Validate
params are correct Store a url
Tree $ . ├── Gemfile ├── config │ └── read_later.rb
├── read_later.rb └── spec ├── read_later_spec.rb └── spec_helper.rb
spec_helper.rb Goliath.env = :test RSpec.configure do |c| c.include Goliath::TestHelper, example_group:
{ file_path: /spec/ } end
spec/read_later_spec.rb it 'returns OK' do with_api ReadLater do get_request(query: {url:
'/test'}) do |request| response = Yajl::Parser.parse(request.response) response.should eq 'OK' end end end
config/read_later.rb config['db'] = EM::Synchrony::ConnectionPool.new(size: 20) do Mysql2::EM::Client.new(ENV['DB_CONFIG']) end
read_later.rb class ReadLater < Goliath::API use Goliath::Rack::Params use Goliath::Rack::DefaultMimeType use
Goliath::Rack::Render, 'json' def response(env) db.aquery("INSERT INTO `articles`(`url`) VALUES ('#{params[:url]}")) [200, {}, 'OK'] end end
spec/read_later.rb it "returns an error" do with_api ReadLater do get_request(query:
{}) do |request| response = Yajl::Parser.parse(request.response) response['error'].should eq 'Url identifier missing' end end end
read_later.rb use Goliath::Rack::Validation::RequiredParam, {key: 'url', type: 'Url'}
and that's it! github.com/postrank-labs/goliath igvita.com/ github.com/seenmyfate/read_later
gem install goliath tom-clements.com | github.com/seenmyfate @Seenmyfate