Finding my current location in Ruby

I have been working on tracking down some elusive issues with some of my rspec tests, and due to the way that those work, and can work in any order, I needed a way to find out what was happening at any given time.

I had forgotten about the way that I had learned about a few years ago that will show you where you are in a call stack without actually causing an Exception or Error to happen:

Kernel.caller

Will return an array of each of the lines in the stack and then I used

Kernel.caller.find_all {|i| i['what_i_am_looking_for]}

to just limit the stack to the items that I needed to see.

Very useful for my current debugging.

Share this post