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
390
テストがないRailsプロジェクトにテストを足す話
ginkouno
May 15, 2020
Tweet
Share
More Decks by ginkouno
See All by ginkouno
RubyOnRailsOnDevin+α / DevinMeetupJapan#2
ginkouno
0
1.5k
技術的負債の借り換え on Ruby and Rails update
ginkouno
3
2.2k
Other Decks in Programming
See All in Programming
バイブスあるコーディングで ~PHP~ 便利ツールをつくるプラクティス
uzulla
1
300
Android 16KBページサイズ対応をはじめからていねいに
mine2424
0
750
Quality Gates in the Age of Agentic Coding
helmedeiros
PRO
1
110
The Niche of CDK Grant オブジェクトって何者?/the-niche-of-cdk-what-isgrant-object
hassaku63
1
720
プロダクトという一杯を作る - プロダクトチームが味の責任を持つまでの煮込み奮闘記
hiliteeternal
0
290
The Modern View Layer Rails Deserves: A Vision For 2025 And Beyond @ RailsConf 2025, Philadelphia, PA
marcoroth
2
830
AIのメモリー
watany
11
1.1k
Go製CLIツールをnpmで配布するには
syumai
0
790
なぜあなたのオブザーバビリティ導入は頓挫するのか
ryota_hnk
3
520
AIに安心して任せるためにTypeScriptで一意な型を作ろう
arfes0e2b3c
0
270
コーディングエージェント概観(2025/07)
itsuki_t88
0
440
iOS開発スターターキットの作り方
akidon0000
0
210
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
Six Lessons from altMBA
skipperchong
28
3.9k
Bash Introduction
62gerente
613
210k
GraphQLとの向き合い方2022年版
quramy
49
14k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
For a Future-Friendly Web
brad_frost
179
9.8k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Practical Orchestrator
shlominoach
189
11k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
Art, The Web, and Tiny UX
lynnandtonic
301
21k
Scaling GitHub
holman
461
140k
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 ςετΛॻ͖͍͢ • ϦϦʔεස͕૿͑Δ
·ͱΊ • ςετΛ͢ཧ༝Λ໌Β͔ʹ͠ • Լ४උΛ͔ͯ͠Β • ෆཁͳίʔυΛআ্ͨ͠Ͱ • ͍͖ͭͭͯ͜͜͠·͠ΐ͏