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
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
Quarkusで作るInteractive Stream Application
joker1007
0
120
今改めてServiceクラスについて考える 〜あるRails開発者の10年〜
joker1007
22
15k
rubygem開発で鍛える設計力
joker1007
4
1.1k
実践Kafka Streams 〜イベント駆動型アーキテクチャを添えて〜
joker1007
3
1.2k
本番のトラフィック量でHudiを検証して見えてきた課題
joker1007
2
1.1k
5分で分かった気になるDebezium
joker1007
1
150
Rustで作るtree-sitterパーサーのRubyバインディング
joker1007
5
1.4k
tree-sitter-rbsで作って学ぶRBSとパーサージェネレーター
joker1007
3
310
Kafka Streamsで作る10万rpsを支えるイベント駆動マイクロサービス
joker1007
7
4.9k
Other Decks in Programming
See All in Programming
Web エンジニアが JavaScript で AI Agent を作る / JSConf JP 2025 sponsor session
izumin5210
3
880
What’s Fair is FAIR: A Decentralised Future for WordPress Distribution
rmccue
0
160
SUZURIの規約違反チェックにおけるクリエイタフィードバックの試⾏錯誤/Trial and Error in Creator Feedback for SUZURI's Terms of Service Violation Checks
ae14watanabe
1
140
Agentに至る道 〜なぜLLMは自動でコードを書けるようになったのか〜
mackee
4
650
「10分以内に機能を消せる状態」 の実現のためにやっていること
togishima
1
270
The Missing Link in Angular's Signal Story: Resource API and httpResource
manfredsteyer
PRO
0
110
Nitro v3
kazupon
2
280
詳細の決定を遅らせつつ実装を早くする
shimabox
1
1k
Dive into Triton Internals
appleparan
0
480
自動テストを活かすためのテスト分析・テスト設計の進め方/JaSST25 Shikoku
goyoki
2
590
Functional Calisthenics in Kotlin: Kotlinで「関数型エクササイズ」を実践しよう
lagenorhynque
0
120
Rails Girls Sapporo 2ndの裏側―準備の日々から見えた、私が得たもの / SAPPORO ENGINEER BASE #11
lemonade_37
2
110
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Done Done
chrislema
186
16k
Balancing Empowerment & Direction
lara
5
740
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.3k
4 Signs Your Business is Dying
shpigford
186
22k
Practical Orchestrator
shlominoach
190
11k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1k
Designing Experiences People Love
moore
142
24k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
660
Visualization
eitanlees
150
16k
GraphQLとの向き合い方2022年版
quramy
49
14k
Producing Creativity
orderedlist
PRO
348
40k
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 !!