Skip to content

Commit

Permalink
Fix binding.pry at the end of methods/blocks
Browse files Browse the repository at this point in the history
We want it to stop before the method/block actually ends.
  • Loading branch information
David Rodríguez de Dios committed Sep 23, 2014
1 parent 053d949 commit 6e1c9a1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/byebug/processors/pry_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(interface = LocalInterface.new)
def run(initial = false, &_block)
if initial
Byebug.start
Byebug.current_context.step_out(3)
Byebug.current_context.step_out(3, true)
else
return_value = nil

Expand Down
9 changes: 9 additions & 0 deletions test/examples/deep_stepping.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Toy program for testing binding.pry initialization
#

new_str = 'string'.gsub!(/str/) do |match|
binding.pry
end

new_str
13 changes: 13 additions & 0 deletions test/processor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,17 @@ class ProcessorTest < Minitest::Spec
@output.string.must_match(/\=> 6:/)
end
end

describe 'Initialization at the end of block/method call' do
let(:step_file) { test_file('deep_stepping') }

before do
@input, @output = InputTester.new, StringIO.new
redirect_pry_io(@input, @output) { load step_file }
end

it 'stops execution at the first line after binding.pry' do
@output.string.must_match(/\=> 7:/)
end
end
end

0 comments on commit 6e1c9a1

Please sign in to comment.