Pry::Method.from_str() can no longer raise an exception

/cc @ryanf the following used to cause exceptions: Pry::Method.from_str("NonexistentClass#method", binding)
I just wrapped from_str in a rescue Pry::RescuableException
This commit is contained in:
John Mair 2012-12-22 22:45:33 +01:00
parent 7ecb425fba
commit 5f3129f44b
2 changed files with 7 additions and 1 deletions

View File

@ -54,6 +54,9 @@ class Pry
from_str(name, target, :instance => true) or
from_str(name, target, :methods => true)
end
rescue Pry::RescuableException
nil
end
# Given a `Binding`, try to extract the `::Method` it originated from and

View File

@ -79,6 +79,10 @@ describe Pry::Method do
meth = Pry::Method.from_str("klass::meth", Pry.binding_for(binding))
meth.name.should == "meth"
end
it 'should not raise an exception if receiver does not exist' do
lambda { Pry::Method.from_str("random_klass.meth", Pry.binding_for(binding)) }.should.not.raise
end
end
describe '.from_binding' do
@ -459,4 +463,3 @@ describe Pry::Method do
end
end