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
99
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
170
git - the stupid content tracker
seenmyfate
2
130
Give
seenmyfate
1
120
4 Steps to Faster Rails Tests
seenmyfate
5
610
Other Decks in Programming
See All in Programming
Pythonスレッドとは結局何なのか? CPython実装から見るNoGIL時代の変化
curekoshimizu
5
1.4k
Goで実践するドメイン駆動開発 AIと歩み始めた新規プロダクト開発の現在地
imkaoru
4
680
Go Conference 2025: Goで体感するMultipath TCP ― Go 1.24 時代の MPTCP Listener を理解する
takehaya
7
1.6k
猫と暮らすネットワークカメラ生活🐈 ~Vision frameworkでペットを愛でよう~ / iOSDC Japan 2025
yutailang0119
0
220
dynamic!
moro
9
6.7k
LLMとPlaywright/reg-suitを活用した jQueryリファクタリングの実際
kinocoboy2
4
670
CSC509 Lecture 01
javiergs
PRO
1
430
GitHub Actions × AWS OIDC連携の仕組みと経緯を理解する
ota1022
0
240
プログラミングどうやる? ~テスト駆動開発から学ぶ達人の型~
a_okui
0
190
GraphQL×Railsアプリのデータベース負荷分散 - 月間3,000万人利用サービスを無停止で
koxya
1
1.2k
詳しくない分野でのVibe Codingで困ったことと学び/vibe-coding-in-unfamiliar-area
shibayu36
3
4.5k
ИИ-Агенты в каждый дом – Алексей Порядин, PythoNN
sobolevn
0
150
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
232
18k
Automating Front-end Workflow
addyosmani
1371
200k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
32
2.2k
The Straight Up "How To Draw Better" Workshop
denniskardys
237
140k
Making Projects Easy
brettharned
119
6.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Gamification - CAS2011
davidbonilla
81
5.5k
How to train your dragon (web standard)
notwaldorf
96
6.3k
Embracing the Ebb and Flow
colly
88
4.8k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6.1k
Scaling GitHub
holman
463
140k
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