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
29
1.9k
How we test our projects
Rubyconf China 2012
Terry
November 18, 2012
Tweet
Share
More Decks by Terry
See All by Terry
Building API For The REST of Us
poshboytl
8
710
RubyConf China Welcome Slides
poshboytl
1
76
Rails Girls Chengdu 2014
poshboytl
2
320
Refactoring Re-education
poshboytl
5
960
Other Decks in Programming
See All in Programming
Model Pollution
hschwentner
1
160
テスト駆動Kaggle
isax1015
1
620
AI コーディングエージェントの時代へ:JetBrains が描く開発の未来
masaruhr
1
200
AI駆動のマルチエージェントによる業務フロー自動化の設計と実践
h_okkah
0
230
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
300
PHPでWebSocketサーバーを実装しよう2025
kubotak
0
320
Git Sync を超える!OSS で実現する CDK Pull 型デプロイ / Deploying CDK with PipeCD in Pull-style
tkikuc
4
350
初学者でも今すぐできる、Claude Codeの生産性を10倍上げるTips
s4yuba
16
13k
NPOでのDevinの活用
codeforeveryone
0
900
マッチングアプリにおけるフリックUIで苦労したこと
yuheiito
0
190
Deep Dive into ~/.claude/projects
hiragram
14
14k
Python型ヒント完全ガイド 初心者でも分かる、現代的で実践的な使い方
mickey_kubo
1
240
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.6k
Building Adaptive Systems
keathley
43
2.7k
Into the Great Unknown - MozCon
thekraken
40
1.9k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.9k
Site-Speed That Sticks
csswizardry
10
700
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
830
Navigating Team Friction
lara
187
15k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
282
13k
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!