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
How we test our projects
Search
Terry
November 18, 2012
Programming
1.9k
29
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
How we test our projects
Rubyconf China 2012
Terry
November 18, 2012
More Decks by Terry
See All by Terry
Building API For The REST of Us
poshboytl
8
750
RubyConf China Welcome Slides
poshboytl
1
96
Rails Girls Chengdu 2014
poshboytl
2
340
Refactoring Re-education
poshboytl
5
990
Other Decks in Programming
See All in Programming
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
160
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
440
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
260
My Marp Sample
sinoue0108
0
120
Go 1.27 における memory allocation の高速化
andpad
0
320
ALB ログから Trace を気合で繋げる技術
fohte
5
560
仕様駆動開発の消費期限
watany
20
9k
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
110
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
230
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
580
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
2
1.2k
PyConJP2026_wat_Python × Signal Processing: How to Draw Pictures with Sound Using Spectrogram Art
wat
0
360
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
KATA
mclloyd
PRO
35
15k
Music & Morning Musume
bryan
47
7.3k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
How to build a perfect <img>
jonoalderson
1
5.9k
Google's AI Overviews - The New Search
badams
0
1.1k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
300
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Building Applications with DynamoDB
mza
96
7.2k
Optimising Largest Contentful Paint
csswizardry
37
3.9k
Transcript
None
whoami
None
太檑
Terry
@poshboytl
Co-founder of Pragmatic.ly
None
Creator of Railscasts-china.com
None
Survey
How many people write tests?
How many people use RSpec?
Tools we use
None
I love RSpec!
None
None
Bad boy!
None
x.should == y
None
None
Straightforward!
asset_equal y, x
None
None
This is just right!
Pillow War!
Peace! Choose what you like!
Try it, instead of following anybody.
Syntax
Syntax Sugar
Syntax Sugar DSL
Is syntax important?
None
None
None
Syntax is important, that’s the most important reason why we
love Ruby! It also can be the reason we love RSepc!
Syntax is important, that’s the most important reason why we
love Ruby! It also can be the reason we love RSepc! Terry Tai
Let’s talk about RSpec!
Our practices
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
Setup phase contains two parts use ‘let’ to initialize data
‘before’ block to do some actions
None
None
None
None
None
None
None
None
Why straightforward is important for us?
None
None
None
The sugar we don’t like very much
None
None
None
RSpec done
None
Problem of Fixtures
Hard to read Hard to write Hard to maintain
None
None
What’s the password?
What’s the password?
What’s the password? Add new records?
Fixtures separate the data and the tests
None
None
Bullshit!
None
What’s the advantage of fixtures?
It’s really fast!!
Some practices for Factory Girl
None
None
None
None
None
None
None
None
Random data is a advantage of factory to fixtures
None
Update: If you wanna use LoremIpsum class still need the
gems like forgery or lorem-ipsum.
None
None
None
None
None
None
How we run tests?
You might see this
But...... I really don’t use it
Tell you a secret
I run my tests manually
Why?
probably, I type :w so frequently and quickly. LOL
probably, I type :w so frequently and quickly. LOL
None
None
None
Your APM should be high
Slayers Boxer Your APM should be high
Manually run ‘bundle exec rspec spec’ ?
No. It depends.
None
None
bundle exec rspec spec ruby -S rspec spec
Bundler still need time to load
When I can not use ‘bundle exec’ ?
None
None
no spec_helper
Two ways to run tests?
None
None
ruby -S rspec spec ?
bundle exec rspec spec ? ruby -S rspec spec ?
by Gray Bernhardt
None
About integration test
RSpec + Capybara(webkit)
Poltergeist looks nice will give it a try
I don’t love it so far Also don’t hate it
Still keep looking
Stub as little as possible only do for Current time
HTTP visiting ...
VCR
None
Use different fixture data in integration and unit tests
Integration tests are not for driving development
No mock or stub means slow You can use a
CI server run it for you
if project.open_source?
A hosted continuous integration service for the open source community.
else
None
integrity • light weight • It built by ruby (Means
you can hack!!!) • Works pretty well with git • Hook and API is weak
None
Hudson and Jenkins • They built by JAVA • Heavy
weight and powerful • a lot of plugins(git, github, emails, hipchat...) • Have nice API
We really did some interesting things with Hudson by HUBOT
http://terrytai.com/
JS tests
None
None
jasminerice gem for work with Rails asset pipeline
jasmine-sinon
None
By Ian: https://gist.github.com/4059889
None
None
None
None
None
Look at me, Terry. It’s not a JS conf, ok?
I’d better stop here
Oh, BTW
DHH is the hero in my heart
Thank you!