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
320
テストがないRailsプロジェクトにテストを足す話
ginkouno
May 15, 2020
Tweet
Share
More Decks by ginkouno
See All by ginkouno
技術的負債の借り換え on Ruby and Rails update
ginkouno
3
1.9k
Other Decks in Programming
See All in Programming
Server Driven Compose With Firebase
skydoves
0
380
デプロイを任されたので、教わった通りにデプロイしたら障害になった件 ~俺のやらかしを越えてゆけ~
techouse
51
31k
Golang と Erlang
taiyow
8
1.8k
Nuxt UI Pro、NuxtHub、Nuxt Scripts、Nuxtエコシステムをふんだんに利用して開発するコーポレートサイト@Vue Fes Japan 2024
shingangan
3
870
Java ジェネリクス入門 2024
nagise
0
570
Vaporモードを大規模サービスに最速導入して学びを共有する
kazukishimamoto
4
4.3k
Amazon Neptuneで始めてみるグラフDB-OpenSearchによるグラフの全文検索-
satoshi256kbyte
4
310
Mastering Dependencies in Kotlin Multiplatform
tomifabian
0
100
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism- An Example
philipschwarz
PRO
0
140
Synchronizationを支える技術
s_shimotori
1
150
hotwire_or_react
harunatsujita
8
3.8k
Vue.js学習の振り返り
hiro_xre
2
130
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
A Tale of Four Properties
chriscoyier
156
23k
Building Your Own Lightsaber
phodgson
102
6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Why You Should Never Use an ORM
jnunemaker
PRO
53
9k
Learning to Love Humans: Emotional Interface Design
aarron
272
40k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.8k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
9
670
Side Projects
sachag
452
42k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
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 ςετΛॻ͖͍͢ • ϦϦʔεස͕૿͑Δ
·ͱΊ • ςετΛ͢ཧ༝Λ໌Β͔ʹ͠ • Լ४උΛ͔ͯ͠Β • ෆཁͳίʔυΛআ্ͨ͠Ͱ • ͍͖ͭͭͯ͜͜͠·͠ΐ͏