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
Ruby2.1のRefinementsで作るSpockライクなテスト構文
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Tomohiro Hashidate
August 23, 2014
Programming
12
1.6k
Ruby2.1のRefinementsで作るSpockライクなテスト構文
RefinementsをRSpecで活用してパラメータライズドテスト用のシンタックスを実現する話。
Tomohiro Hashidate
August 23, 2014
Tweet
Share
More Decks by Tomohiro Hashidate
See All by Tomohiro Hashidate
ReproでのicebergのStreaming Writeの検証と実運用にむけた取り組み
joker1007
0
620
マイクロサービスへの5年間 ぶっちゃけ何をしてどうなったか
joker1007
23
9.4k
Quarkusで作るInteractive Stream Application
joker1007
0
230
今改めてServiceクラスについて考える 〜あるRails開発者の10年〜
joker1007
25
20k
rubygem開発で鍛える設計力
joker1007
4
1.2k
実践Kafka Streams 〜イベント駆動型アーキテクチャを添えて〜
joker1007
3
1.3k
本番のトラフィック量でHudiを検証して見えてきた課題
joker1007
2
1.2k
5分で分かった気になるDebezium
joker1007
1
210
Rustで作るtree-sitterパーサーのRubyバインディング
joker1007
5
1.7k
Other Decks in Programming
See All in Programming
あなたはユーザーではない #PdENight
kajitack
4
300
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
390
エラーログのマスキングの仕組みづくりに役立ったASTの話
kumoichi
0
110
ご飯食べながらエージェントが開発できる。そう、Agentic Engineeringならね。
yokomachi
1
280
日本だけで解禁されているアプリ起動の方法
ryunakayama
0
370
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
4
500
atmaCup #23でAIコーディングを活用した話
ml_bear
4
740
CSC307 Lecture 11
javiergs
PRO
0
590
AIに任せる範囲を安全に広げるためにやっていること
fukucheee
0
110
AIコーディングの理想と現実 2026 | AI Coding: Expectations vs. Reality 2026
tomohisa
0
1k
Go Conference mini in Sendai 2026 : Goに新機能を提案し実装されるまでのフロー徹底解説
yamatoya
0
520
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
240
Featured
See All Featured
Unsuck your backbone
ammeep
672
58k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
850
Un-Boring Meetings
codingconduct
0
220
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Scaling GitHub
holman
464
140k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
A designer walks into a library…
pauljervisheath
210
24k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
120
The Mindset for Success: Future Career Progression
greggifford
PRO
0
270
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
210
The Curse of the Amulet
leimatthew05
1
9.6k
Transcript
Ruby2.1ͷRefinementsͰ࡞Δ SpockϥΠΫͳςετߏจ ڮཱ༑@joker1007
!KPLFS 3VCZ3BJMT4DBMB ! :PLPIBNBSC 4IJCVZBSC "TBLVTBSC 5%%#$
ؔਓͰ͢
None
Refinements
ར༻Λએݴͨ͠ίϯςΩετͰͷΈ ϝιου͕ఆٛ͞ΕΔ
• Ruby 2.0͔ΒՃ (experimental) • Ruby 2.0ͷrefinementsτοϓϨϕϧͷΈ • Ruby 2.1͔Βexperimental͡Όͳ͘ͳͬͨ
• Ruby 2.1͔ΒΫϥεείʔϓͰએݴͰ͖ΔΑ͏ʹͳͬͨ
Ruby 2.1͔Β͜͏ॻ͚Δ
Կ͕خ͍͠ͷ͔
ΈࠐΈΫϥεͷ ϝιουΛ্ॻ͖ͯ͠ ӨڹൣғΛݶఆͰ͖Δ DSLॻ͖์ʂ
࣮ࡍͦΕͳΓʹ੍ݶ͕…
ຊ
RSpec
Spock
Spock Cool !!
RefinementsͰ RSpecΛͦΕͬΆ͘ॻ͘
rspec-parameterized https://github.com/tomykaira/rspec-parameterized
ͦΕͬΆ͍ʂ
None
ԿΛ͍ͬͯΔͷ͔ • binding_of_callerͰݺͼग़͠ݩͷbindingΛऔಘ͢Δ • evalͯ͠ݺͼग़͠ݩͷExampleGroupͷΠϯελϯε Λऔಘ͢Δ • ݺͼग़͠ݩͷΠϯελϯεʹύϥϝʔλʔอ࣋ͷͨ ΊͷΠϯελϯεมΛಈతʹఆٛ͢Δ •
ΦϒδΣΫτΛϥοϓͯ͠Πϯελϯεมʹύϥ ϝʔλʔΛՃ͍ͯ͘͠ • RSpecͷdescribe࣮Ϋϥεͷఆٛͱಉ͡ͳͷͰ using͕ར༻Ͱ͖Δ
ࠇຐज़ͩΒ͚ ͔͠ΈࠐΈϝιουΛ উखʹ࠶ఆٛ ! Ͱusingͯ͠ͳ͍Օॴʹ ҰӨڹແ͠
·ͱΊ
• Ruby 2.1͔ΒRefinementsͷ੍ݶ͕গ͠؇͘ ͳͬͨ • Refinementsϝιουఆٛͷࣗ༝Λ͛ͯ ͘ΕΔ • ΈࠐΈϝιου໊લඃΓΛؾʹͤͣDSLΛ ఆٛͰ͖Δ
• ·ͩusingએݴͷ੍͕ଟ͍ͷͰɺࠓޙͷਐԽʹ ظ
Let’s Refine !!