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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Tomohiro Hashidate
August 23, 2014
Programming
1.6k
12
Share
Ruby2.1のRefinementsで作るSpockライクなテスト構文
RefinementsをRSpecで活用してパラメータライズドテスト用のシンタックスを実現する話。
Tomohiro Hashidate
August 23, 2014
More Decks by Tomohiro Hashidate
See All by Tomohiro Hashidate
Do Ruby::Box dream of Modular Monolith?
joker1007
1
380
ReproでのicebergのStreaming Writeの検証と実運用にむけた取り組み
joker1007
0
700
マイクロサービスへの5年間 ぶっちゃけ何をしてどうなったか
joker1007
23
10k
Quarkusで作るInteractive Stream Application
joker1007
0
260
今改めてServiceクラスについて考える 〜あるRails開発者の10年〜
joker1007
25
22k
rubygem開発で鍛える設計力
joker1007
5
1.4k
実践Kafka Streams 〜イベント駆動型アーキテクチャを添えて〜
joker1007
3
1.4k
本番のトラフィック量でHudiを検証して見えてきた課題
joker1007
2
1.3k
5分で分かった気になるDebezium
joker1007
1
230
Other Decks in Programming
See All in Programming
Kingdom of the Machine
yui_knk
2
1.3k
ソースコード→AST→オペコード、の旅を覗いてみる
o0h
PRO
1
110
Cache-moi si tu peux : patterns et pièges du cache en production - Devoxx France 2026 - Conférence
slecache
0
330
Structured Concurrency, Scoped Values and Joiners in the JDK 25 26 27
josepaumard
1
130
PHPer、Cloudflare に引っ越す
suguruooki
1
130
Terraform言語の静的解析 / static analysis of Terraform language
wata727
1
130
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
Running Swift without an OS
kishikawakatsumi
0
870
2026_04_15_量子計算をパズルとして解く
hideakitakechi
0
130
実用!Hono RPC2026
yodaka
2
290
Spec-driven Development: How AI Changes Everything (And Nothing)
simas
PRO
0
580
KMP × Kotlin 2.3 - How Android Got Slower While iOS Builds Improved by 47%
rio432
0
100
Featured
See All Featured
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
160
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.9k
Code Review Best Practice
trishagee
74
20k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2.9k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
380
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
The Limits of Empathy - UXLibs8
cassininazir
1
320
Navigating Weather and Climate Data
rabernat
0
180
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Optimising Largest Contentful Paint
csswizardry
37
3.7k
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 !!