ruby -rpry some_script.rb - the r means require. If there's a binding.pry there, you'll be on it.
Pry gives you a graphical look at your program in progress, lets you cd among objects, ls to see available variables, etc. You can't step, though; just explore a snapshot at that moment.
Must install debugger gem for your version of Ruby (1.9 is 'gem install debugger'). Doesn't play well with Spork.
rspec some_test_spec.rb --debug will stop on a debugger statement.
In a debugging session, set autolist on says "keep showing me graphically where I am."
lshows lines of code forward. Has flags:-backward=current lineX-Ylines X to Y
nis for "next"; "step over"sis for "step"; "step into"e some_statementevaluates that. If you want to do more,irbdrops you into it.- hitting enter re-executes the last command; if you hit
nand want to keep stepping, hit enter. l18displays line 18- Breakpoints
b file:line [if expr]sets a breakpointb class(.|#)method [if expr]sets a breakpointdel [nnn]deletes some or all breakpoints
- Displaying expressions
disp [expression]shows value of expression at every stepundisp [nnn]cancels display options
- Examining the call stack
- May have to call
Debugger.startfirst?where,up,down,framebashd.sourceforge.net/ruby-debug.html#FrameCommands
- May have to call
helpis available
Put a .rdebugrc in the project directory or your home directory with:
set autolist
set autoeval
set autoreload
Cool summary, however you can step with pry if you install the pry-debugger plugin, you can also engage in even more sophisticated types of debugging if you install the pry-rescue plugin. For a fuller look at pry plugins available, check out https://github.com/pry/pry/wiki/Available-plugins and the Pry Ecosystem posts.