Copy Kernel#capture helper from Rails

Rails deprecated this helper as it's not threadsafe. However, in our
situation, we're only using it in the test so it doesn't matter.