Sha256: 808ff25d14a1225f52ff89ee1199e6962bd37758edd29b1fe2e4e8e133cd7103

Contents?: true

Size: 1.24 KB

Versions: 11

Compression:

Stored size: 1.24 KB

Contents

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
        instance = nil
        redirect_pry_io(InputTester.new(@control_d)) do
          instance = Pry.new
          instance.repl
        end

        instance.binding_stack.should.be.empty
      end
    end

    describe 'in a nested session' do
      it 'should pop last binding from the binding stack' do
        base = OpenStruct.new
        base.obj = OpenStruct.new

        redirect_pry_io(InputTester.new("cd obj", "self.stack_size = _pry_.binding_stack.size",
                                        @control_d, "self.stack_size = _pry_.binding_stack.size", "exit-all")) do
          Pry.start(base)
        end

        base.obj.stack_size.should == 2
        base.stack_size.should == 1
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pry-0.9.10 test/test_control_d_handler.rb
pry-0.9.10-i386-mswin32 test/test_control_d_handler.rb
pry-0.9.10-i386-mingw32 test/test_control_d_handler.rb
pry-0.9.10-java test/test_control_d_handler.rb
pry-0.9.10pre1 test/test_control_d_handler.rb
pry-0.9.10pre1-i386-mswin32 test/test_control_d_handler.rb
pry-0.9.10pre1-i386-mingw32 test/test_control_d_handler.rb
pry-0.9.10pre1-java test/test_control_d_handler.rb
pry-0.10.pre.1-i386-mingw32 test/test_control_d_handler.rb
pry-0.10.pre.1-java test/test_control_d_handler.rb
pry-0.10.pre.1-i386-mswin32 test/test_control_d_handler.rb