Permalink
Browse files

breaking out of the repl loop after skipping

  • Loading branch information...
1 parent 6e55495 commit e0fea8ea51edd5ed494c352e03d1e4bda0e90f0d Bruno Pinto committed May 6, 2012
Showing with 13 additions and 4 deletions.
  1. +2 −1 lib/pry/default_commands/navigating_pry.rb
  2. +11 −3 test/test_default_commands/test_context.rb
View
3 lib/pry/default_commands/navigating_pry.rb
@@ -105,11 +105,12 @@ def process_pop_and_return
target.pry
end
- command "skip", "Skip the next pry Session(s) and ends the current one." do |amount|
+ command 'skip', 'Skip the next pry Session(s) and ends the current one.' do |amount|
amount = amount.nil? ? 1 : amount.to_i
if amount >= 1
(1..amount).each { |number| _pry_.skip_stack.push number }
+ _pry_.run_command('exit-all')
else
output.puts "Invalid skip amount. Must be higher than 0. Got #{amount}."
end
View
14 test/test_default_commands/test_context.rb
@@ -338,13 +338,13 @@ def o.hello(x, y, z)
describe "skip" do
it 'should skip next session' do
$skipped = true
- redirect_pry_io(InputTester.new("$skipped = false", "skip", "exit-all"), StringIO.new) do
+ redirect_pry_io(InputTester.new("$skipped = false", "skip"), StringIO.new) do
Pry.start(0)
end
$skipped.should == false
$skipped = true
- redirect_pry_io(InputTester.new("$skipped = false", "skip", "exit-all"), StringIO.new) do
+ redirect_pry_io(InputTester.new("$skipped = false", "skip"), StringIO.new) do
Pry.start(0)
end
$skipped.should == true
@@ -358,7 +358,7 @@ def o.hello(x, y, z)
it 'should skip next sessions' do
$skipped = true
- redirect_pry_io(InputTester.new("$skipped = false", "skip 2", "exit-all"), StringIO.new) do
+ redirect_pry_io(InputTester.new("$skipped = false", "skip 2"), StringIO.new) do
Pry.start(0)
end
$skipped.should == false
@@ -375,5 +375,13 @@ def o.hello(x, y, z)
end
$skipped.should == true
end
+
+ it 'should break out of the repl loop of Pry instance' do
+ $break = true
+ redirect_pry_io(InputTester.new("skip", "$break = false"), StringIO.new) do
+ Pry.start(0)
+ end
+ $break.should == true
+ end
end
end

0 comments on commit e0fea8e

Please sign in to comment.