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
柏.rb #5 マインスイーパーのテストを書いてみた
Search
hana-da
November 18, 2024
Programming
0
11
柏.rb #5 マインスイーパーのテストを書いてみた
hana-da
November 18, 2024
Tweet
Share
More Decks by hana-da
See All by hana-da
柏.rb #1 hana-daのご紹介
hana_da
0
15
Other Decks in Programming
See All in Programming
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
1
110
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
250
CSC509 Lecture 12
javiergs
PRO
0
160
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
880
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
24k
みんなでプロポーザルを書いてみた
yuriko1211
0
260
Remix on Hono on Cloudflare Workers
yusukebe
1
280
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
133
8.9k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Embracing the Ebb and Flow
colly
84
4.5k
Producing Creativity
orderedlist
PRO
341
39k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Code Reviewing Like a Champion
maltzj
520
39k
Transcript
2024-11-18 ദ.rb #5 hana-da ϚΠϯεΠʔύʔͷςετΛॻ͍ͯΈͨ
ദ.rb #3 ͱ #4 ϚΠϯεΠύʔΛ࡞ͬͯΈΑ͏ • ദ.rb #3 ʮΦϒδΣΫτࢦΛཧղ͢ΔͨΊʹϚΠϯεΠύʔΛϞϒϓϩͯ͠ΈΔʯ •
ͳΜͱͳ͘ΞτϥΠϯͰ͖͚ͨͲશવະ • ͦͷޙɺݸਓͰͪΐͪ͜ΐ࣮ͯ͜͠ͱΓ͋͑ͣ༡Δͱ͜Ζ·Ͱ • ϝΠϯϧʔϓτοϓϨϕϧͰ࣮͠ɺBoard ͱ Cell ͷ2ΫϥεͰߏ • લճ ദ.rb #4 Ͱ͝հ https://github.com/hana-da/minesweeper • ࠓճɺςετॻ͍ͯͳ͔͔ͬͨΒςετΛॻ͍͍ͯ͘ 🦁
ͲΜͳ࣮͔ʁ ήʔϜͷॳظԽ • https://github.com/hana-da/minesweeper/blob/before_board_test/ minesweeper.rb
ͲΜͳ࣮͔ʁ CellʹضΛཱͯΔ • https://github.com/hana-da/minesweeper/blob/before_board_test/ minesweeper.rb
ͲΜͳ࣮͔ʁ CellΛ։͘ • https://github.com/hana-da/minesweeper/blob/before_board_test/ minesweeper.rb
ςετΛॻ͍͍ͯ͘ ͍ͭRSpecͳͷͰminitestʹॳઓ • https://github.com/hana-da/minesweeper/blob/before_board_test/ minesweeper.rb
ςετΛॻ͍͍ͯ͘ Boardͷςετ • https://github.com/hana-da/minesweeper/blob/before_board_test/ minesweeper.rb
mineΛຒΊΔϩδοΫΛผΫϥεʹ͢Δ MinePlanter::Random ര • https://github.com/hana-da/minesweeper/compare/ before_board_test...test_with_mine_planter
mineΛຒΊΔϩδοΫΛผΫϥεʹ͢Δ MinePlanter::Random ര • https://github.com/hana-da/minesweeper/compare/ before_board_test...test_with_mine_planter
mineΛຒΊΔϩδοΫΛผΫϥεʹ͢Δ ςετMinePlanter::PresetΛ͏ • https://github.com/hana-da/minesweeper/compare/ before_board_test...test_with_mine_planter
mineΛຒΊΔϩδοΫΛผΫϥεʹ͢Δ ͢Δͱ͜Μͳςετ͕ॻ͚ΔΑ͏ʹͳΔ • https://github.com/hana-da/minesweeper/ compare/ before_board_test...test_with_mine_planter
͕͔ͩ͠͠ɺμϝͩͬͨ • ௨ৗϥϯμϜʹஔ͞ΕΔmineΛɺςετͰࢦఆҐஔʹஔ͢Δࣄ͕Մೳ ʹͳͬͨͷͰɺmineΛͯͨΓɺmineΛආ͚ͨΓ͢ΔςετՄೳʹͳͬͨ • ͔͠͠ɺBoardͷதͷCell͕Ͳ͏ͳ͍ͬͯΔ͔֎͔ΒΘ͔Βͳ͍ • ضΛཱͯͯຊʹཱ͍ͬͯΔ͔assertͰ͖ͳ͍ • ۙྡʹmine͕ͳ͍
0 ͷ Cell Λ open ͨ࣌͠ʹपΓ࿈త(࠶ؼత)ʹ։͚ͨ ͔assertͰ͖ͳ͍
खͬऔΓૣ͘ivarΛ৮Δ ॻ͚ͨɺ͔͠͠ෛ͚ͨؾ͕͢Δ • https://github.com/hana-da/minesweeper/compare/ before_board_test...test_with_ivar
खͬऔΓૣ͘ivarΛ৮Δ ͜ͷϔϧύʔͬͯBoard#initializeͱ΄΅Ұॹ͡Όͳ͍ʁ • https://github.com/hana-da/minesweeper/compare/ before_board_test...test_with_ivar
CellΛ֎Ͱ࡞Δ ඞཁͳͷCellGenerator͔ͬͯͭʁ • mineΛຒΊࠐΉ෦͚ͩͷ֎ग़͠ͰෆेɺͱࢥͬͯivarΛ͍͕ͬͨ͡ɺ ivarஔ͖͑Ͱ݁ہͦ͜Λมߋͯ͠Δ͚ͩʹͳͬͨ • ͔͠͠ivarஔ͖͑खݩ(ςετίʔυ)ʹgrid͕ΔͷͰɺςετ͕ॻ͚Δ!! • ސ٬(ςετίʔυ)͕ຊʹཉ͔ͬͨ͠ͷʮ͖ͳҐஔʹmineΛຒΊΔ ࣄʯͰͳ͘ʮ͖ͳҐஔʹmine͕ຒΊࠐ·ΕͨCellͷgridʯ
• grid֎Ͱ࡞ͬͯBoard.new͢Δ࣌ʹ͢ͷ͕ਖ਼ղ?
CellΛ֎Ͱ࡞Δ ઌʹςετ͔Βॻ͍ͯΈΔ • https://github.com/hana-da/minesweeper/compare/ before_board_test...test_with_cell_generator
CellΛ֎Ͱ࡞Δ ͋ͱςετ͕pass͢ΔΑ͏ʹ࣮Λมߋ • https://github.com/hana-da/minesweeper/compare/ before_board_test...test_with_cell_generator
·ͱΊ Δޠኮྗ͕ͳ͍ɻɻɻ • ࠷ॳmineΛຒΊΔϩδοΫ͚ͩΛΓग़͍ͯͨ͠ͷͰɺϩδοΫͷΓସ ͑Ͱ͖͕ͨɺςετʹͦΕͰෆेͩͬͨ • ෦Ͱੜ͞ΕΔΦϒδΣΫτΛ֎Ͱ࡞ΔࣄͰɺ͖ͳͱ͜ΖʹmineΛຒΊ ΒΕΔ͠ɺςετରͷΦϒδΣΫτʹ৮ΕΒΕΔ͠Ͱͤͩͬͨ • ͬͯɻɻ͜ͱ???
• ͜ΕͰ͍͍ͷ͔ࣗ৴͕ͳ͍ͷͰɺͥͻ͝ҙݟ͍͖ͨͩͨ͘