2012-06-16 14:12:10 -04:00
|
|
|
require 'helper'
|
|
|
|
|
|
|
|
describe Pry::DEFAULT_CONTROL_D_HANDLER do
|
|
|
|
describe 'control-d press' do
|
|
|
|
before do
|
|
|
|
@control_d = "Pry::DEFAULT_CONTROL_D_HANDLER.call('', _pry_)"
|
|
|
|
@binding_stack = "self.binding_stack = _pry_.binding_stack.dup"
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'in an expression' do
|
|
|
|
it 'should clear out passed string' do
|
|
|
|
str = "hello world"
|
|
|
|
Pry::DEFAULT_CONTROL_D_HANDLER.call(str, nil)
|
|
|
|
str.should == ""
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'at top-level session' do
|
|
|
|
it 'should break out of a REPL loop' do
|
2012-12-20 04:28:04 -05:00
|
|
|
instance = Pry.new
|
|
|
|
instance.binding_stack.should.not.be.empty
|
2012-12-21 03:40:21 -05:00
|
|
|
instance.accept_line(nil).should.be.false
|
2012-06-16 14:12:10 -04:00
|
|
|
instance.binding_stack.should.be.empty
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'in a nested session' do
|
|
|
|
it 'should pop last binding from the binding stack' do
|
2012-12-20 04:28:04 -05:00
|
|
|
t = pry_tester
|
|
|
|
t.eval "cd Object.new"
|
|
|
|
t.eval("_pry_.binding_stack.size").should == 2
|
2012-12-21 03:40:21 -05:00
|
|
|
t.eval("_pry_.accept_line(nil)").should.be.true
|
2012-12-20 04:28:04 -05:00
|
|
|
t.eval("_pry_.binding_stack.size").should == 1
|
2012-06-16 14:12:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|