How to get object reference from inspection-string

Suppose there is a test failing and only an inspection string is shown in the error message.

#<Class:0x007ff706e7eb68>

It would be very convenient to retrieve a reference to the object for further inspection. The following snippet will give you the object if it isn't garbage-collected yet.

ObjectSpace._id2ref '0x007ff706e7eb68'.to_i(16) >> 1

If you are asking about the strange bit shift >> 1 as I am, I'll humbly point you to http://stackoverflow.com/questions/2818602/in-ruby-why-does-inspect-print-out-some-kind-of-object-id-which-is-different where you can find some explanation.