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
730
RubyConf China Welcome Slides
poshboytl
1
88
Rails Girls Chengdu 2014
poshboytl
2
320
Refactoring Re-education
poshboytl
5
980
Other Decks in Programming
See All in Programming
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
150
Railsの気持ちを考えながらコントローラとビューを整頓する/tidying-rails-controllers-and-views-as-rails-think
moro
4
340
AI時代でも変わらない技術コミュニティの力~10年続く“ゆるい”つながりが生み出す価値
n_takehata
2
450
Rails Girls Tokyo 18th GMO Pepabo Sponsor Talk
yutokyokutyo
0
170
kintone + ローカルLLM = ?
akit37
0
120
Raku Raku Notion 20260128
hareyakayuruyaka
0
420
Geminiの機能を調べ尽くしてみた
naruyoshimi
0
170
今更考える「単一責任原則」 / Thinking about the Single Responsibility Principle
tooppoo
2
950
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
150
日本だけで解禁されているアプリ起動の方法
ryunakayama
0
360
CopilotKit + AG-UIを学ぶ
nearme_tech
PRO
1
110
AIコーディングの理想と現実 2026 | AI Coding: Expectations vs. Reality 2026
tomohisa
0
570
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
Balancing Empowerment & Direction
lara
5
920
GraphQLとの向き合い方2022年版
quramy
50
14k
Six Lessons from altMBA
skipperchong
29
4.2k
30 Presentation Tips
portentint
PRO
1
240
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
130
Are puppies a ranking factor?
jonoalderson
1
3k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
190
Color Theory Basics | Prateek | Gurzu
gurzu
0
210
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
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!