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
1.6k
12
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ruby2.1のRefinementsで作るSpockライクなテスト構文
RefinementsをRSpecで活用してパラメータライズドテスト用のシンタックスを実現する話。
Tomohiro Hashidate
August 23, 2014
More Decks by Tomohiro Hashidate
See All by Tomohiro Hashidate
Ruby::Boxでできること、Refinementsでできること
joker1007
3
460
Do Ruby::Box dream of Modular Monolith?
joker1007
1
1.4k
ReproでのicebergのStreaming Writeの検証と実運用にむけた取り組み
joker1007
0
800
マイクロサービスへの5年間 ぶっちゃけ何をしてどうなったか
joker1007
23
10k
Quarkusで作るInteractive Stream Application
joker1007
0
310
今改めてServiceクラスについて考える 〜あるRails開発者の10年〜
joker1007
25
28k
rubygem開発で鍛える設計力
joker1007
5
1.5k
実践Kafka Streams 〜イベント駆動型アーキテクチャを添えて〜
joker1007
3
1.5k
本番のトラフィック量でHudiを検証して見えてきた課題
joker1007
2
1.3k
Other Decks in Programming
See All in Programming
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
1.8k
初めての模倣学習とVLA
natsutan
0
190
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
170
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
130
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
540
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
580
What's New in Android 2026
veronikapj
0
270
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
220
異なる設計思想のフレームワークを経験して得た学び
amekuhideki
1
180
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
990
リアルな遅延を測る仕様
kota_yata
1
120
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
590
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.4k
For a Future-Friendly Web
brad_frost
183
10k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
490
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
810
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.9k
Abbi's Birthday
coloredviolet
3
9.4k
The Curious Case for Waylosing
cassininazir
1
480
The Curse of the Amulet
leimatthew05
2
14k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.8k
Between Models and Reality
mayunak
4
400
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 !!