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
Automated testing in Ruby 101
Search
Masafumi Okura
March 04, 2023
Programming
1
1.3k
Automated testing in Ruby 101
https://k-ruby.com/kagoshima-rubykaigi02/
Masafumi Okura
March 04, 2023
Tweet
Share
More Decks by Masafumi Okura
See All by Masafumi Okura
A suggestion for the future of RDoc
okuramasafumi
1
51
15 JSON serializers for Ruby
okuramasafumi
2
100
Tech Events, Should We See Them from the Outside or the Inside?
okuramasafumi
1
34
Creating gems 101
okuramasafumi
1
65
How NOT to make your DSL terrible
okuramasafumi
0
260
オブジェクトしこう
okuramasafumi
2
200
Debugging Alba
okuramasafumi
1
180
Learning Ruby
okuramasafumi
5
540
How to build a conference for both newbies and seasoned devs
okuramasafumi
1
1.7k
Other Decks in Programming
See All in Programming
Новый уровень ML-персонализации Lamoda: Как мы усилили ее в каталоге и перенесли на другие продукты
lamodatech
0
130
Kubernetes上でOracle_Databaseの運用を楽にするOraOperatorの紹介
nnaka2992
0
150
Iteratorでページネーションを実現する
sonatard
3
710
(Deep|Web) Link support with expo-router
mrtry
0
170
GitHub Copilot Workspace で我々のアプリ開発がどう変わるのか?
shuyakinjo
0
940
データサイエンスのフルサイクル開発を実現する機械学習パイプライン
xcnkx
2
500
CDKを活用した 大規模コンテナ移行 プロジェクトの紹介
yoyoyopg
0
300
Kotlin Multiplatform at Stable and Beyond (Kotlin Vienna, October 2024)
zsmb
2
350
MLOps in Mercari Group’s Trust and Safety ML Team
cjhj
1
120
複数プロダクトの技術改善・クラウド移行に向き合うチームのフレキシブルなペア・モブプログラミングの実践 / Flexible Pair Programming And Mob Programming
honyanya
0
220
WEBアプリケーションにおけるAWS Lambdaを用いた大規模な非同期処理の実践
delhi09
PRO
7
4.1k
perl for shell, awk and sed programmers
mackee
1
690
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Scaling GitHub
holman
458
140k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
26
4.1k
Practical Orchestrator
shlominoach
186
10k
Debugging Ruby Performance
tmm1
73
12k
We Have a Design System, Now What?
morganepeng
49
7.2k
Adopting Sorbet at Scale
ufuk
73
9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
46
4.9k
YesSQL, Process and Tooling at Scale
rocio
167
14k
WebSockets: Embracing the real-time Web
robhawkes
59
7.3k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Building Adaptive Systems
keathley
38
2.2k
Transcript
RubyͰ͡ΊΔࣗಈςετ ࣛࣇౡRubyձٞ02 େխ࢙ʢOKURA Masafumiʣ 2022-03-04, mark MEIZAN
ࣗಈςετ
ॻ͍͍ͯΔਓ—
ࠓͷඪ
ࣗಈςετ ʹ͍ͭͯͷ ֓ཁͷཧղ
ࠓͷ͓ 1. ࣗಈςετʹ͍ͭͯ 2. Rubyʹ͓͚Δࣗಈςετ 3. ྑ͍ࣗಈςετͱ 4. ࣮ԋʂςετϑΝʔετ
ͦͷલʹ
ࣗݾհ
Okura.introduce(self) • ໊લɿେխ࢙ • ॴଐɿϑϦʔϥϯε • ՝֎׆ಈɿKaigi on RailsɺGrow.rbɺRubygems Code
Reading෦ɺ֤छొஃɺOSS׆ಈɺRails GirlsίʔνɺϑΟ ϤϧυϒʔτΩϟϯϓͷΞυόΠβʔ • ॳࣛࣇౡ
1. ࣗಈςετ ʹ͍ͭͯ
ࣗಈςετͱ
ϓϩάϥϜͱͯ͠ ࣮͞Εͨςετ
ϓϩάϥϜͳͷͰ ࣗಈԽ͕؆୯
ςετͳͷͰ ͋ΔछͷݕূΛ ߦ͏
ࣗಈςετʹ͍ͭͯ 1. ࣗಈςετͷԸܙ 2. ࣗಈςετͷछྨ 3. ࣗಈςετͷҙ
1.1 ࣗಈςετͷ Ըܙ
ࣗಈςετԿ͕خ͍͠ͷ͔ʁ • ίʔυʹର͢ΔυΩϡϝϯτʹͳΔ • ίʔυͷWhatΛઆ໌͢Δ • όάͷ࠶ൃʢϦάϨογϣϯʣΛ͙ • ϦϑΝΫλϦϯάͷॿ͚ʹͳΔʢ΄΅ඞਢʣ •
ʢςετΛઌʹॻ͘߹ʣίʔυͷ্࣭͕͕Δ • ʮςετϑΝʔετʯ
1.2 ࣗಈςετͷ छྨ
ࣗಈςετͷछྨ • ୯ମςετʢϢχοτςετʣ • ଞͷίϯϙʔωϯτ͔ΒΓͯ͠ςετ • ݁߹ςετ • ͍͔ͭ͘ͷίϯϙʔωϯτΛΈ߹Θͤͯςετ
1.3 ࣗಈςετͷ ҙ
ࣗಈςετͰҙ͖͢͜ͱ • ʮόά͕ͳ͍ʯ͜ͱͷূ໌ʹͳΒͳ͍ • ʮςετ͕௨ͬͨʂˠόάͬͯͨorzʯΈ͍ͨͳ͜ͱ Α͋͘Δ • ίʔυΛॻ͍͔ͯΒςετΛॻ͘ͱେมʹͳΓ͕ͪ • ςετϑΝʔετͷํָ͕ʢݸਓͷҙݟͰ͢ʣ
͜ͷ࣌Ͱ ͑ͯ ͓͖͍ͨ͜ͱ
ࣗಈςετ ॻ͘ͷ
ࣗಈςετجຊతʹॻ͘ • ʮςετϑΝʔετʯ͔ʮςετϥετʯ͔ͲͪΒͰ Α͍ • MiniTest͔RSpec͔ͲͪΒͰΑ͍ • ࡉ͔͍͜ͱׂͱؾʹ͠ͳ͍ͰΑ͍ • ͱʹ͔͘ॻ͘
ॻ͔ͳ͍ޙչ ΑΓ ॻ͘ޙչ
2. Rubyʹ͓͚Δ ࣗಈςετ
Rubyͷੈքʹ ͨ͘͞Μͷςετ gem͕͋Γ·͢
ςετgemͷখྨ 1. ςετϑϨʔϜϫʔΫ 2. ಛఆ༻్͚DSL 3. αϙʔτϥΠϒϥϦ
2.1 ςετ ϑϨʔϜϫʔΫ
RubyͷςετϑϨʔϜϫʔΫ • RSpec • μϯϩʔυ͕࠷ଟɺ൚༻ςετDSLͰ͋Δ • MiniTest • xUnitܥ౷ɺεϐʔυͱγϯϓϧ͕͞Ϧ •
Test::Unit • ࠷ݹͷςετϑϨʔϜϫʔΫɺxUnitܥ౷
2.2 ಛఆ༻్͚ DSL
ಛఆ༻్͚DSL • Capybara • ϒϥβૢ࡞ͷͨΊͷDSL • Cucumber • ड͚ೖΕςετͷͨΊͷDSLɺຊޠ͕ॻ͚Δ
2.3 αϙʔτ ϥΠϒϥϦ
αϙʔτϥΠϒϥϦ • FactoryBot • ςετσʔλʢߏԽ͞Εͨσʔλʣͷੜ • Faker • ϥϯμϜσʔλʢϝʔϧΞυϨε໊લͳͲʣ •
Timecop • ࣌ؒΛૢ࡞͢Δ
3. ྑ͍ࣗಈςετ ͱ
ྑ͍ࣗಈςετͷϙΠϯτ • ࣗಈςετίʔυͳͷͰɺྑ͍ίʔυͷݪଇΛద༻͢Δ • Մಡੑʢ໋໊ɺཻͷখ͞͞ͳͲʣ • దͳߏԽ • ࣮ߦ࣌ؒͷ͞ •
ແବͳσʔλੜΛආ͚ΔʢಛʹσʔλϕʔεΞΫηε͍ʣ • ୯ମςετʹدͤΔʢ݁߹ςετ͍ʣ
• RSpecͩͱྑ͍ςετʹ͍ͭͯٞʹͳΓ͕ͪ • letͱlet!ͱbeforeͷ͍͚ • contextͱitʹຊޠΛ͑Δ͔ʁ • etc… •
ϩʔΧϧͳ׳शʹै͏ͷ͕٢
4. ࣮ԋʂ ςετϑΝʔετ