Skip to content

Commit

Permalink
Merge branch 'handle-syntax-errors'
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Mar 21, 2013
2 parents 2081f5a + e09c381 commit 8158b81
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Rakefile
Expand Up @@ -11,6 +11,12 @@ task :example2 do
sh "ruby -I./lib/ ./examples/example2.rb "
end

desc 'Run syntax-err example'
task :sintax do
ENV['RUBYLIB'] = 'lib'
sh 'bin/rescue examples/syntax-err.rb'
end

desc "Run tests"
task :test do
sh 'rspec spec'
Expand Down
1 change: 1 addition & 0 deletions examples/syntax-err.rb
@@ -0,0 +1 @@
def initely not Ruby
1 change: 1 addition & 0 deletions lib/pry-rescue.rb
Expand Up @@ -165,6 +165,7 @@ 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
7 changes: 7 additions & 0 deletions spec/pry_rescue_spec.rb
Expand Up @@ -95,6 +95,13 @@
PryRescue.load("spec/fixtures/raiseother.rb")
}.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]
end
else
it "should open at the correct point" do
Pry.should_receive(:start).once{ |binding, h|
Expand Down

0 comments on commit 8158b81

Please sign in to comment.