Wow. Did i already mention how i love pry?
I like crowbars and hammers and this is the perfect tool to get into the guts of your code – wherever you want to. Follow these simple steps.
Add to your Gemfile (assuming ruby>1.9.2)
group :development do gem 'pry' gem 'pry-debugger' end
Then pry your code open.
Given a method
def rock_an_item(item) do_this(item) do_that(item) end
def rock_an_item(item) binding.pry do_this(item) do_that(item) end
Run again and voilá
From: testit.rb @ line 10 Object#rock_an_item: 10: def rock_an_item(item) => 11: binding.pry 12: do_this(item) 13: do_that(item) 14: end  pry(main)>
you’re dropped right into an irb console at the point of the break. With pry-debugger installed you have
continue methods (and more). Investigate your item, check out your environment, when it’s all done,
continue. Fix the bug, remove
binding.pry and move on. Super simple.
Sadly, the debugger tie-in and 1.8.7 is not quite as seamless. I’m still working on that. But assuming most of your projects have moved into the 1.9.x realm, you should be in good shape.