Skip to content

Commit

Permalink
Rely on nil check in Pry.rescued [Closes #31]
Browse files Browse the repository at this point in the history
Post recent refactoring, it should not be possible for
enter_exception_context to be called with an invalid exception.

`rake sintax` now does this: http://showterm.io/b4b797cf4e4676223936e
  • Loading branch information
ConradIrwin committed Mar 21, 2013
1 parent 8158b81 commit aa53c8d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion lib/pry-rescue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def without_bindings_below_raise(bindings)
# @param [Array<Bindings>] bindings The call stack
# @return [Array<Bindings>]
def without_duplicates(bindings)
bindings = Array(bindings)
bindings.zip([nil] + bindings).reject do |b, c|
# The eval('__method__') is there as a shortcut as loading a method
# from a binding is very slow.
Expand Down
9 changes: 4 additions & 5 deletions spec/pry_rescue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@
}.should raise_error(/raiseother_exception/)
end

it "should work if bindings is nil" do
PryRescue.stub(:without_bindings_below_raise).and_return nil
PryRescue.stub(:phantom_load_raise?).and_return false
PryRescue.stub(:with_program_name).and_return nil
PryRescue.enter_exception_context [:hi]
it "should output a warning if the exception was not raised" do
PryRescue.should_not_receive(:enter_exception_context)
Pry.should_receive(:warn).once
Pry.rescued(RuntimeError.new("foo"))
end
else
it "should open at the correct point" do
Expand Down

0 comments on commit aa53c8d

Please sign in to comment.