Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RubyHiroba 2014
Search
yui-knk
September 21, 2014
Programming
400
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RubyHiroba 2014
Power Assert with Pry
yui-knk
September 21, 2014
More Decks by yui-knk
See All by yui-knk
Modding RubyKaigi for Myself
yui_knk
0
1.2k
Kingdom of the Machine
yui_knk
2
3k
Ruby Parser progress report 2025
yui_knk
1
990
Understanding Ruby Grammar Through Conflicts
yui_knk
1
920
Ruby's Line Breaks
yui_knk
4
6.3k
What is Parser
yui_knk
11
5.7k
Ruby Parser progress report 2024
yui_knk
2
560
最高の構文木の設計 2024年版
yui_knk
9
6.9k
Converting AST
yui_knk
4
480
Other Decks in Programming
See All in Programming
APNsからLive Activityを開始する話
yumnumm
0
170
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
470
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
130
R8 の設定見直しでアプリサイズ削減
andpad
0
230
Event is what happens
moro
2
1.4k
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
0
150
S3 TablesのIcebergデータに、AIエージェントからアクセスしてみた / 20261016developersio2026joetsu-accessing-iceberg-in-s3tables-via-agent
kasacchiful
PRO
0
200
オーケストレーション記述言語 Katari
yukikurage
0
190
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
190
Web Framework Benchmark Battle 2026, Any%
a_matsuda
3
2.9k
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
2
110
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
120
Featured
See All Featured
So, you think you're a good person
axbom
PRO
2
2.2k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
360
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Mobile First: as difficult as doing things right
swwweet
225
10k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Designing for Performance
lara
612
70k
A Modern Web Designer's Workflow
chriscoyier
699
190k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
490
How to train your dragon (web standard)
notwaldorf
96
6.9k
Transcript
Yuichiro Kaneko SKIYAKI Inc. Power Assert × Pry
I am … • @yui-knk (github) / @spikeolaf (twitter) •
pry commit (ghosting / ͓͞΅Γ) • Interested in “Binding” (Don’t throw “Masakari”)
Pry ?? • An IRB alternative and runtime developer console
$ pry ! [1] pry(main)> "ruby".capitalize => "Ruby" [2] pry(main)> ls 10 Comparable#methods: between? Numeric#methods: +@ coerce i phase quo rectangular to_c ... Integer#methods: ceil denominator floor vcdlcm ... Fixnum#methods: % * + -@ < ...
Power Assert ?? • Power Assert shows each value of
variables and method calls in the expression. It is useful for testing, providing which value wasn't correct when the condition is not satisfied. (test-unit) ! assert do "0".class == "3".to_i.times.map {|i| i + 1 }.class end
assert do "0".class == "3".to_i.times.map {|i| i + 1 }.class
end ! ! Failure: ! "0".class == "3".to_i.times.map {|i| i + 1 }.class | | | | | | | | | | | Array | | | | [1, 2, 3] | | | #<Enumerator: 3:times> | | 3 | false String test_failed(MyTest)
For more detail of Power Assert • https://speakerdeck.com/k_tsj/power-assert-in-ruby
I think • Power Assert is Cool !! • Power
Assert is Magical !! • Want to Power Assert Easily !! (not only Failure case in test)
So I made pry plug-in!
How to install and use it • Type “pa RUBY_CODE”
in pry $ gem install pry-power_assert $ pry ! [1] pry(main)> pa "0".class == "3".to_i.times.map {|i| i + 1 }.class "0".class == "3".to_i.times.map {|i| i + 1 }.class | | | | | | | | | | | Array | | | | [1, 2, 3] | | | #<Enumerator: 3:times> | | 3 | false String [2] pry(main)>
Edge case 1 ( [], {}, ->) • (Maybe) these
are not treated as method calls (TracePoint) [1] pry(main)> prc = -> x { -> y {x * y}} => #<Proc:0x007fd1360c9130@(pry):59 (lambda)> [2] pry(main)> pa prc[10][2] prc[10][2] | | | | | 20 | #<Proc:0x007fd13609a9c0@(pry):59 (lambda)> #<Proc:0x007fd1360c9130@(pry):59 (lambda)> ! [3] pry(main)> pa -> x { -> y {x * y}}[10][2] -> x { -> y {x * y}}[10][2]
Edge case 2 ( A ? B : C /
if ) • Why? [1] pry(main)> pry(main)> a = 10 => 10 [2] pry(main)> pa (a.to_s == 12) ? 1 : 0 (a.to_s == 12) ? 1 : 0 ! [3] pry(main)> pa 10 if a.to_s == 12 10 if a.to_s == 12
OFF TOPIC (What P.A. needs) • Proc (yield, variables(proc.binding)) •
String (Ripper.sexp(@line) for idents) > Proc.new {"0".class == "3".to_i.times.map {|i| i + 1 }.class} => #<Proc:0x007fd136068b00@(pry):79> ! > %Q["0".class == "3".to_i.times.map {|i| i + 1 }.class] => "\"0\".class == \"3\".to_i.times.map {|i| i + 1 }.class"
OFF TOPIC (What P.A. needs) 1SPD 4USJOH UFTUVOJU BSH PQFO
QBUI NJOJUFTU BSH PQFO QBUI QSZQ@B FWBM1SPDOFX \\TUS^^ BSH STQFD PQFO QBUI • RSpec is not supported
OFF TOPIC (What P.A. needs) • How to get Proc
in RSpec ? (rspec) ! describe “class of string should be String” do “0”.class.should == String end