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 on Rails ✘╹◡╹✘
Search
r7kamura
September 19, 2012
Programming
10
3.9k
Test on Rails ✘╹◡╹✘
r7kamura
September 19, 2012
Tweet
Share
More Decks by r7kamura
See All by r7kamura
Railsアップグレード百景
r7kamura
11
6.7k
個人開発のやっていき方
r7kamura
94
23k
amakanにおける書籍のシリーズ判定方法について 2016-08-21
r7kamura
10
6.1k
Tenkaichi Bot Butoukai
r7kamura
11
5.2k
Paging in API
r7kamura
3
8.7k
Chanko Hacking Guide
r7kamura
5
1.3k
Making things with something small
r7kamura
1
480
Hidden
r7kamura
0
92
Butsukari Geiko
r7kamura
10
36k
Other Decks in Programming
See All in Programming
XSLTで作るBrainfuck処理系
makki_d
0
140
推論された型の移植性エラーTS2742に挑む
teamlab
PRO
0
180
The Evolution of Enterprise Java with Jakarta EE 11 and Beyond
ivargrimstad
0
400
OpenNext + Hono on Cloudflare でイマドキWeb開発スタックを実現する
rokuosan
0
110
💎 My RubyKaigi Effect in 2025: Top Ruby Companies 🌐
yasulab
PRO
1
130
MLOps Japan 勉強会 #52 - 特徴量を言語を越えて一貫して管理する, 『特徴量ドリブン』な MLOps の実現への試み
taniiicom
2
630
20250528 AWS Startupイベント登壇資料:AIコーディングの取り組み
procrustes5
0
150
ワイがおすすめする新潟の食 / 20250530phpconf-niigata-eve
kasacchiful
0
290
RubyKaigi Hack Space in Tokyo & 函館最速 "予習" 会 / RubyKaigi Hack Space in Tokyo & The Fastest Briefing of RubyKaigi 2026 in Hakodate
moznion
1
130
Perlで痩せる
yuukis
1
670
List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfold' relates to 'iterate'"
philipschwarz
PRO
0
180
コードに語らせよう――自己ドキュメント化が内包する楽しさについて / Let the Code Speak
nrslib
6
1.4k
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
180
53k
Designing for Performance
lara
609
69k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.4k
It's Worth the Effort
3n
184
28k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
How GitHub (no longer) Works
holman
314
140k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
870
RailsConf 2023
tenderlove
30
1.1k
BBQ
matthewcrist
89
9.7k
Transcript
Test on Rails based on “Rails Test Prescriptions” by Noel
Rappin Ryo Nakamura (@r7kamura) ✘ ╹◡╹ ✘
1. Why test? 2. Unit 3. Model 4. Functional 5.
View 6. Integration
Why test?
* to speed up validation * to design architectures *
to assure its quality ... Why test?
to speed up validation automating test * open browser... *
type the URL “h..tt..p://...” * check the contents...
to design architecture * write clean and independent code (test
behaves like a third-party code) * think the correct behavior of code (this would be an example of test)
to assure its quality * prevent code from enbugging *
maybe forced to write test ... ;(
For more details why you... Please ask Mohicans around you
Unit Test
Forms of writing unit test - ✘╹◡╹ ✘ http://r7kamura.hatenablog.com/ entry/2012/09/19/113239
Unit Test
Model Test
Unit Test of Model. It's easy to write Model Test.
"Skinny Controller, Fat Model" Model Test
Functional Test
Functional tests Verify the system satisfies requested features of user.
In Rails, it tests Controller & View by 1 request
Targets 1. normal 2. invalid 3. security
1. normal A normal request should pass expected data to
the view. @foo, sessions, cookies, flash
2. invalid An invalid request should be handled properly. redirect_to
:root
3. security User’s and system’s security should be protected. get(others_entry_path).
should_not be_success
Non targets * many redirections * user interaction * HTTP
methods (in Rails)
View Test
View Test Verify: * logic * structure (semantic mean) Used
in Controller & Integration Test on Rails
Good targets * logic in a view (necessary evil...;) *
security problem * way to render structures
Bad targets * text in HTML tag * look and
feel verify only “semantic meanings”
Integration Test
Integration Test verify the interactions(I/F) of multiple components Acceptance test
might see to this. Capybara, Cucumber, ...
When to use Integration Test? To validate the interactions of
the modules that are well-tested.
Good targets * interactions in multiple steps * dependency with
prev state * legacy code (black-box) * with JavaScript
Bad targets * only 1 request * only for view
testing
1. Why test? 2. Unit 3. Model 4. Functional 5.
View 6. Integration
thanks ✘ ╹◡╹ ✘ @r7kamura