1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
pry--pry/spec/commands/exit_spec.rb
2012-11-15 18:59:51 -06:00

34 lines
981 B
Ruby

require 'helper'
describe "exit" do
it 'should pop a binding with exit' do
pry_tester(:outer).simulate_repl do |t|
t.eval 'cd :inner'
t.eval('self').should == :inner
t.eval 'exit'
t.eval('self').should == :outer
t.eval 'exit-all'
end
end
it 'should break out of the repl loop of Pry instance when binding_stack has only one binding with exit' do
pry_tester(0).simulate_repl do |t|
t.eval 'exit'
end.should == nil
end
it 'should break out of the repl loop of Pry instance when binding_stack has only one binding with exit, and return user-given value' do
pry_tester(0).simulate_repl do |t|
t.eval 'exit :john'
end.should == :john
end
it 'should break out the repl loop of Pry instance even after an exception in user-given value' do
pry_tester(0).simulate_repl do |t|
proc {
t.eval 'exit = 42'
}.should.raise(SyntaxError)
t.eval 'exit'
end.should == nil
end
end