Reputation: 81
binding.pry
is not catching for me in some situations.
For instance, when I run this code using ruby programtorun.rb
in the terminal, it doesn't open up a Pry session.
require 'pry'
class Foo
def bar
boo = true
binding.pry
end
end
f = Foo.new
f.bar
I tried reinstalling Pry but the problem persisted.
Upvotes: 2
Views: 1999
Reputation: 8826
The problem is that binding.pry
stops on the next line to be executed in your program. Your next line is non-existent. binding.pry
is literally the last thing you call before your script ends.
Changing
class Foo
def bar
boo = true
binding.pry
end
end
to
class Foo
def bar
binding.pry
boo = true
end
end
caused it to stop for me at boo=true
.
Upvotes: 2