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
410
テストがないRailsプロジェクトにテストを足す話
ginkouno
May 15, 2020
Tweet
Share
More Decks by ginkouno
See All by ginkouno
RubyOnRailsOnDevin+α / DevinMeetupJapan#2
ginkouno
0
1.7k
技術的負債の借り換え on Ruby and Rails update
ginkouno
3
2.3k
Other Decks in Programming
See All in Programming
Data-Centric Kaggle
isax1015
2
780
Oxlint JS plugins
kazupon
1
1k
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
日本だけで解禁されているアプリ起動の方法
ryunakayama
0
280
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
7.5k
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
5
800
CSC307 Lecture 07
javiergs
PRO
1
560
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
390
Gemini for developers
meteatamel
0
100
生成AIを活用したソフトウェア開発ライフサイクル変革の現在値
hiroyukimori
PRO
0
110
CSC307 Lecture 06
javiergs
PRO
0
690
Oxlintはいいぞ
yug1224
5
1.4k
Featured
See All Featured
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
80
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
110
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.1k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
96
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Testing 201, or: Great Expectations
jmmastey
46
8.1k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
120
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 ςετΛॻ͖͍͢ • ϦϦʔεස͕૿͑Δ
·ͱΊ • ςετΛ͢ཧ༝Λ໌Β͔ʹ͠ • Լ४උΛ͔ͯ͠Β • ෆཁͳίʔυΛআ্ͨ͠Ͱ • ͍͖ͭͭͯ͜͜͠·͠ΐ͏