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
TDDとVimと
Search
Yuta Totz
October 23, 2015
Programming
1
470
TDDとVimと
RailsまわりのTDDと、Vimについて。
Yuta Totz
October 23, 2015
Tweet
Share
More Decks by Yuta Totz
See All by Yuta Totz
ウガンダでXcodeをアップデートする方法
totzyuta
0
100
Working with UNIX Process 6/7 Chapter
totzyuta
1
60
珈琲と僕
totzyuta
0
83
読んで理解するActiveRecordの設計とActiveSupport::Concern
totzyuta
4
1.5k
モテる!筋肉コンパイラ自作入門 - 草食男子からの卒業
totzyuta
0
420
Git/GitHub入門-GitHubでたのしいチーム開発
totzyuta
0
290
Vimmer幼稚園
totzyuta
2
110
たのしいたーみなる
totzyuta
0
40
Other Decks in Programming
See All in Programming
Kaigi on Rails 2024 - Rails APIモードのためのシンプルで効果的なCSRF対策 / kaigionrails-2024-csrf
corocn
5
3.3k
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
1
290
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.1k
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
480
Importmapを使ったJavaScriptの 読み込みとブラウザアドオンの影響
swamp09
4
1.2k
2万ページのSSG運用における工夫と注意点 / Vue Fes Japan 2024
chinen
3
1.3k
Piniaの現状と今後
waka292
5
1.4k
Golang と Erlang
taiyow
8
1.9k
推し活としてのrails new/oshikatsu_ha_iizo
sakahukamaki
3
1.6k
Dev ContainersとGitHub Codespacesの素敵な関係
ymd65536
1
120
GCCのプラグインを作る / I Made a GCC Plugin
shouth
1
150
Vaporモードを大規模サービスに最速導入して学びを共有する
kazukishimamoto
4
4.3k
Featured
See All Featured
Writing Fast Ruby
sferik
626
61k
How to Ace a Technical Interview
jacobian
275
23k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Statistics for Hackers
jakevdp
796
220k
Facilitating Awesome Meetings
lara
49
6k
4 Signs Your Business is Dying
shpigford
180
21k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
41
2.1k
Adopting Sorbet at Scale
ufuk
73
9k
Typedesign – Prime Four
hannesfritz
39
2.4k
What's new in Ruby 2.0
geeforr
342
31k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Building Adaptive Systems
keathley
38
2.2k
Transcript
TDD ͱ Vim ͱ Red-Green-Refactoring Cycle with Vim
Resume • Introduction • What is “test”? • TDD on
Red-Green-Refactor Cycle • TDD by Vim • Demo • Conclusion • Links and Books
ࣗݾհ
ͱͭ ށ௩ ༎ଠ (@totzyuta) OneBox Inc. ίʔώʔ ݉ WebΤϯδχΞ
ςετɺॻ͍ͯ·͔͢ʁ
What is “test”?
What is test? • ΞϓϦέʔγϣϯ͕ਖ਼͘͠ಈ͘͜ͱΛอূ͢ ΔͨΊͷΞϓϦέʔγϣϯͰͳ͍ίʔυ • ୯ମςετɺػೳςετɺ૯߹ςετ • (ݺͼํͷఆ͍ٛ͋·͍)
• UnitςετͱFeatureςετ
Categories of Tests • Unitςετ • ૄ݁߹తͳUnit͝ͱͷ࠴Λอূ͢Δ • associationͷਖ਼͠͞ͷ୲อ •
Featureςετ • Unitؒͷ݁߹ • => ػೳશମͱͯ͠ͷಈ͖ͷਖ਼͠͞Λอূ͢Δ • Model, Controller, ViewΛ۲͠Ͱ͖Δʂ
Testing Frameworks • Minitest • Railsඪ४ (DHHਞ) • ຊͰ࠷ۙͪΐͬͱ͏ਓ૿͖͑ͯͨ •
RSpec • ͳΜ͔Ή͠Ζඪ४Έ͍ͨʹͳͬͯͨ • ൈຊతͳ༷มߋ͕ಘҙ
3 Principles of Writing Tests • ςετ৴པͰ͖ΔͷͰ͋Δ͜ͱ • ςετ؆୯ʹॻ͚Δ͜ͱ •
ςετ؆୯ʹཧղͰ͖Δ͜ͱ ref. Everyday Rails - RSpecʹΑΔRailsςετೖ - Aaron Sumner, Junichi Ito, AKIMOTO Toshiharu, ৼߐ ڕ
TDD on Red-Green- Refactor Cycle
“TDD is dead.” — David Heinemeier Hansson
What is TDD? • ʮϏδωεϓϩάϥϜΛॻ͘લʹɺςετίʔ υΛॻ͘͜ͱʯ • ςετ͕༷ॻʹͳΔ (!!) •
Red-Green-Refactor Cycle
Flow of TDD on Red-Green-Refactor Cycle 1. ςετͰઃܭॻΛॻ͘ (RED) 2.
࠷͔ͭ࠷؆୯ʹςετΛ௨͢ίʔυΛॻ͘ (GREEN) • ͍ͭ͜ςετίʔυͷςετ 3. ϦϑΝΫλϦϯά (Refactor) • ͜Ε͕ຊؾͷ࣮ • “ϦϑΝΫλϦϯά”ͬͯͭͱͪΐͬͱҧ͏ • Red͕ΘΔ͍ɺGreen͕Α͍Ͱͳ͍ʂ ref. cookpad 2015 summer internship TDD by Yoshiori SHOJI
TDD - ϝϦοτᶃ • ςετίʔυΛઌʹॻ͘͜ͱʹΑͬͯɺࣗ ͕࡞Δ͖ϓϩάϥϜ͕໌֬Խ͢Δɻ • ࣄલʹ࡞͢ΔϓϩάϥϜΠϝʔδ͕ੜ·Ε ΔͨΊ༷ᴥᴪʹؾͮ͘ػձ͕ૣΊʹ๚Ε Δɻ
TDD - ϝϦοτᶅ • ςετίʔυ͕ඞͣશͯ࡞͞ΕΔ • Ϟνϕʔγϣϯ • ෆ҆Λ๊͑ͨ··ͷ։ൃ͞Α͏ͳΒ
Vim
VimͰRailsͳϓϥάΠϯ • jodosha/vim-greenbar • jodosha/vim-devnotes • dbext.vim • tpope/rails.vim •
The-NERD-tree
VimͰRailsͳϓϥάΠϯ • bronson/vim-trailing-whitespace • tpope/vim-endwise • vim-scripts/AnsiEsc.vim
ුؾ૬ख
Demo
Demo $ rails new coedotask $ rails g scaffold Task
name:string time:integer • λεΫཧΞϓϦέʔγϣϯ - coedotask • ͜Εʹ Task.calc_total_time ΛՃ͠·͢ʂ
Flow of TDD on Red-Green-Refactor Cycle 1. ςετͰઃܭॻΛॻ͘ (RED) 2.
࠷͔ͭ࠷؆୯ʹςετΛ௨͢ίʔυΛॻ͘ (GREEN) • ͍ͭ͜ςετίʔυͷςετ 3. ϦϑΝΫλϦϯά (Refactor) • ͜Ε͕ຊؾͷ࣮ • “ϦϑΝΫλϦϯά”ͬͯͭͱͪΐͬͱҧ͏ • Red͕ΘΔ͍ɺGreen͕Α͍Ͱͳ͍ʂ ref. cookpad 2015 summer internship TDD by Yoshiori SHOJI
Conclusion • TDD։ൃऀΛͤʹͯ͘͠ΕΔ (?) • “TDD is dead” ͔͔Βͳ͍͚ͲͻͱΓͻͱ Γͷ࣮ફ͕Web։ൃʹ͓͚ΔςεςΟϯάͷ
ະདྷΛܾΊ͍ͯ͘ • ʹͳͬͯͨͷ͍͠
͋Δͷ͜ͱ
None
*ŋʄƅŋ*:.Ň..Ň.:*ŋ'( ƅ˜ƅ*)'ŋ*:.Ň. .Ň.:*ŋʄƅŋ*
None
*ŋʄƅŋ*:.Ň..Ň.:*ŋ'( ƅ˜ƅ*)'ŋ*:.Ň. .Ň.:*ŋʄƅŋ*
ॻ੶ • Everyday Rails Testing with RSpecTDD • Aaron Sumner
ࢀߟ • BDDʹ͍ͭͯࣗͳΓʹ·ͱΊͯΈͨ • TDD is dead. Long live testing.
• Effective TDD With Ruby: Time & Flow
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ