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
テストがないRailsプロジェクトにテストを足す話
Search
ginkouno
May 15, 2020
Programming
1
330
テストがないRailsプロジェクトにテストを足す話
ginkouno
May 15, 2020
Tweet
Share
More Decks by ginkouno
See All by ginkouno
技術的負債の借り換え on Ruby and Rails update
ginkouno
3
2k
Other Decks in Programming
See All in Programming
Jakarta EE meets AI
ivargrimstad
0
200
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
みんなでプロポーザルを書いてみた
yuriko1211
0
260
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.1k
Realtime API 入門
riofujimon
0
150
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
RubyLSPのマルチバイト文字対応
notfounds
0
120
Arm移行タイムアタック
qnighy
0
330
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
180
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
540
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
Designing the Hi-DPI Web
ddemaree
280
34k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
The Pragmatic Product Professional
lauravandoore
31
6.3k
We Have a Design System, Now What?
morganepeng
50
7.2k
Designing Experiences People Love
moore
138
23k
Docker and Python
trallard
40
3.1k
What's in a price? How to price your products and services
michaelherold
243
12k
Transcript
ςετ͕ͳ͍ Rails ϓϩδΣΫτ ʹ ςετΛ͢ Տ @ۜ࠲ Rails
ࣗݾհ Տ (@ginkouno) • ϑϦʔϥϯε(2013ʙ)ɺΫηϥΩגࣜձࣾද • Ruby on RailsɺswiftɺGoɺReactɺઙ͘Πϯϑϥ ܦྺ
• 1996ʙ C++ͰΞϧόΠτ(Windows3.1) • 1998 ߴઐଔۀ(ػցֶՊ) • 1998ʙ ৽ଔͰೖͬͨϝʔΧʔͰΞηϯϒϦݴޠͰΈࠐΈ։ൃͱ͔ • 2000ʙ ৭ʑͳॴͰ C++ɺΈࠐΈ / Windows / Linux • 2008ʙ ٸʹ Web ܥɻRuby on Rails1.2 ܥ͔Β 6.0.2.2 ·Ͱ
લఏ • ςετ RSpec Λ͍ͬͯ·͢ • ͱ͍ͬͯɺࡉ͔͍ॻ͖ํͱ͔͋·Γग़͖ͯ·ͤΜ • ݹ͍ϓϩδΣΫτʹςετΛ͍ͯ͘͠ɺͱ͍͏Ͱ͢
ಋೖ ςετ͕ແ͍ϓϩδΣΫτʹɺ(݁Ռతʹ)ςετΛ͢Ҋ݅Λड͚ͨͱ͖ • Ruby Rails ͷ Version UP Λ͍ͨ͠
• ςετ͕ཁΔΑͶ • ςετ͕ແ͍ͷͰɺͯ͠ཉ͍͠ • OK ؤுΔɻཧղ͕͋ͬͯॿ͔Δ
৺ߏ͑ ςετ͕ແ͍ͱ͜Ζେɺcontroller ͱ͔ fat ͩͬͨΓ͢Δ͕... ʮίʔυΛΜͰਓΛ·ͣʯ
ަব ςετΛ࣌ؒ͢Λ࡞Δަব • վम / ػೳՃͷʹɺखಈͷಈ࡞֬ೝ͕ඞཁͰίετ͔͔ΔΑ • ࣌ؒʹͯ͠ຖճ͜Ε͘Β͍͔͔ΔΑ • ՈిϝʔΧʔ
20 ਓҐͷςετઐ༻ਓһΛςετͷͨΊʹ༻ҙͯͨ͠Α • ͦΕ͚ͩͷ͓ۚ༻ҙͰ͖ͳ͍ΑͶʁ
ྫ:Rails ͷ Version up ςετΛॻ࣌ؒ͘ΛऔΔ͔औΒͳ͍͔ɺҎԼͷίετͱରൺͯ͠Β͏ • όοναʔό • staging ڥ͕ಈ͍ͯΔͳΒɺVersionUP
݄ͯ̍͠์ஔ • Web UI ଆ • ςετ༷ॻΛ SpreadSheet Ͱॻ͍ͯɺઐଐςετཁһΛ֬อ • VersionUP ຖʹશ෦ςετ
Լ४උ 1 ࣗಈςετͷ४උ • CircleCI Ͱ Travis Ͱ Jenkins Ͱྑ͍
• ޙड़ͷ simle_cov ͷ݁Ռද͕ࣔͰ͖Δͷ͕ྑ͍
Լ४උ 2 ਐḿͷݟ͑ΔԽ • simple_cov ͷಋೖ • ςετΛ୶ʑͱ͢ͷർΕΔͷͰ৺ͷࢧ͑
Լ४උ 3 ෆཁͳίʔυআ ݩʑͷίʔυྔΛݮΒ͢ Okuribito Rails https://texta.pixta.jp/entry/2017/05/25/123845 • Ґίʔυ͕ݮͬͨΓ͢Δ͜ͱ͋Δ •
Ruby2.6 Ҏ߱Ͱ͋Εɺoneshot coverage ͑ͦ͏
ςετͷՃͷ։࢝ Ͳ͔͜Β͢ͷ͔ • ςετ͕ແ͍ϓϩδΣΫτɺʮϏδωεϩδοΫ͕ model ʹʯͱ͔͞Εͯͳ͍ • model ʹରͯ͠ͷ Unit
test ͱ͔͕ॻ͖ʹ͍͘ • ݱঢ়ͷ༷Λςετʹམͱ͠ࠐΉ͜ͱ͔Β • api ͩͬͨΒ request spec • UI ͕͋ΔϓϩδΣΫτͩͬͨΒ feature spec
ಛʹ͕͔͔࣌ؒΔͱ͜Ζ factory bot ͷඋ association ͕ଟஈͰෳࡶʹͳ͍ͬͯΔ߹ಛʹେม • ཧղ͕ਂ͍ϝϯόʔʹϖΞϓϩͷ࣌ؒΛ͑ΔͱεϜʔζʹਐΉ
ԣల։ ҎԼͷ͕݅ἧ͏ͱɺςετʹ׳Ε͍ͯͳ͍ਓͰςετΛॻ͖࢝ΊΔ͜ͱ͕Ͱ͖Δ • factory bot ͷ factory ͕͋Δఔἧ͍࢝ΊΔ • CRUD
ͷςετͷαϯϓϧ͕ἧ͏ ࠷ॳίϐϖ͔ΒͷվมͰྑ͍
ςετՃʹ͔͔Δ࣌ؒ • ϓϩδΣΫτͷنͱ༷ͷෳࡶ͞ʹґଘ͢ΔͷͰɺͳΜͱݴ͑ͳ͍ • simple_cov ͷ method line Λɺ1ʙ2
िؒͰՃͰ͖ͨςετͷͰׂͬͯਪଌ • ࠷ॳͷࠒͷํ͕ factory bot ͷඋͳͲͰ͕͔͔࣌ؒΔͷͰɺޙՃ͢Δͣ
ςετ͕͋ΔఔՃͰ͖ͨޙͷੈք • Rails ͷ VersionUP ͕ḿΔ • ϦϑΝΫλϦϯά͕͘͢͠ͳΔ • model
ͷΓ͚ͱ͔ɺunit ςετ͕ॻ͖͍͢ model ͷॻ͖ํͷֶͼ͕ੜ·ΕΔ • ߴڽूͰ݁߹ͳ Class ςετΛॻ͖͍͢ • ϦϦʔεස͕૿͑Δ
·ͱΊ • ςετΛ͢ཧ༝Λ໌Β͔ʹ͠ • Լ४උΛ͔ͯ͠Β • ෆཁͳίʔυΛআ্ͨ͠Ͱ • ͍͖ͭͭͯ͜͜͠·͠ΐ͏