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
420
テストがない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
Ruby x Terminal
a_matsuda
7
590
Fundamentals of Software Engineering In the Age of AI
therealdanvega
1
250
モックわからないマン卒業記 ~振る舞いを起点に見直した、フロントエンドテストにおけるモックの使いどころ~
tasukuwatanabe
2
120
RubyとGoでゼロから作る証券システム: 高信頼性が求められるシステムのコードの外側にある設計と運用のリアル
free_world21
0
270
Vuetify 3 → 4 何が変わった?差分と移行ポイント10分まとめ
koukimiura
0
130
ポーリング処理廃止によるイベント駆動アーキテクチャへの移行
seitarof
3
1k
Claude Code の Skill で複雑な既存仕様をすっきり整理しよう
yuichirokato
1
370
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
260
技術検証結果の整理と解析をAIに任せよう!
keisukeikeda
0
120
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
13
8k
文字コードの話
qnighy
44
17k
オブザーバビリティ駆動開発って実際どうなの?
yohfee
3
830
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
760
Paper Plane
katiecoart
PRO
0
48k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
150
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
120
How STYLIGHT went responsive
nonsquared
100
6k
Being A Developer After 40
akosma
91
590k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
Building AI with AI
inesmontani
PRO
1
790
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 ςετΛॻ͖͍͢ • ϦϦʔεස͕૿͑Δ
·ͱΊ • ςετΛ͢ཧ༝Λ໌Β͔ʹ͠ • Լ४උΛ͔ͯ͠Β • ෆཁͳίʔυΛআ্ͨ͠Ͱ • ͍͖ͭͭͯ͜͜͠·͠ΐ͏