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.5k
個人開発のやっていき方
r7kamura
94
23k
amakanにおける書籍のシリーズ判定方法について 2016-08-21
r7kamura
10
6k
Tenkaichi Bot Butoukai
r7kamura
11
5.2k
Paging in API
r7kamura
3
8.6k
Chanko Hacking Guide
r7kamura
5
1.3k
Making things with something small
r7kamura
1
460
Hidden
r7kamura
0
76
Butsukari Geiko
r7kamura
10
36k
Other Decks in Programming
See All in Programming
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
1.4k
DMMオンラインサロンアプリのSwift化
hayatan
0
180
Внедряем бюджетирование, или Как сделать хорошо?
lamodatech
0
940
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
170
QA環境で誰でも自由自在に現在時刻を操って検証できるようにした話
kalibora
1
140
ErdMap: Thinking about a map for Rails applications
makicamel
1
610
『改訂新版 良いコード/悪いコードで学ぶ設計入門』活用方法−爆速でスキルアップする!効果的な学習アプローチ / effective-learning-of-good-code
minodriven
28
4.1k
週次リリースを実現するための グローバルアプリ開発
tera_ny
1
1.2k
VisionProで部屋の明るさを反映させるシェーダーを作った話
segur
0
100
Amazon Nova Reelの可能性
hideg
0
200
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
1.3k
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
1.3k
Featured
See All Featured
Six Lessons from altMBA
skipperchong
27
3.6k
The Pragmatic Product Professional
lauravandoore
32
6.4k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
What's in a price? How to price your products and services
michaelherold
244
12k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
230
52k
GitHub's CSS Performance
jonrohan
1030
460k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.2k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7.1k
jQuery: Nuts, Bolts and Bling
dougneiner
62
7.6k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
240
Thoughts on Productivity
jonyablonski
68
4.4k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
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