ConradIrwin/pry-rescue — pull request #60 by vincentwoo (2014-02-10 00:23:01+00:00)
Title: Add -i options to pry-rescue

Addresses https://github.com/ConradIrwin/pry-rescue/issues/56 and https://github.com/ConradIrwin/pry-rescue/issues/57.

@robgleeson @ConradIrwin I'd love for you guys to take a look at this.

What I've done:

* Move from Kernel.load to Kernel.eval
* Compensate for losing script-level locals by evalling everything in TOPLEVEL_BINDING (perhaps dangerous? Can we make a sandbox binding?)
* Address syntax errors by just printing them when we see them. As we can't give a meaningful stack trace, don't trying to open a binding at the call site (there really isn't one).
* Hook `Kernel#at_exit` et al when the `-i` flag is specified. Enables some userful behavior:

`rescue -i test.rb` yields:

Run options: --seed 42032

# Running:

.

Finished in 0.001498s, 667.4204 runs/s, 667.4204 assertions/s.

1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
[1] 2.0.0 > Foo.new.bar
"whee"

`test.rb`:

require 'minitest/autorun'

class Foo
def bar
"whee"
end
end

class TestFoo < MiniTest::Test
def setup
@foo = Foo.new
end

def test_that_foo_can_bar
assert_equal "whee", @foo.bar
end
end