Sha256: cf9c52be4710bb27b7a0de1618d039b2c7c143b75ed296832ce136d181c801c1

Contents?: true

Size: 1.5 KB

Versions: 77

Compression:

Stored size: 1.5 KB

Contents

require 'helper'

describe Pry::DEFAULT_CONTROL_D_HANDLER do

  describe "control-d press" do

    before do
      # Simulates a ^D press.
      @control_d = "Pry::DEFAULT_CONTROL_D_HANDLER.call('', _pry_)"
    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 "breaks out of a REPL" do
        pry_tester(0).simulate_repl do |t|
          t.eval @control_d
        end.should == nil
      end
    end

    describe "in a nested session" do
      it "pops last binding from the binding stack" do
        pry_tester(0).simulate_repl { |t|
          t.eval 'cd :foo'
          t.eval('_pry_.binding_stack.size').should == 2
          t.eval(@control_d)
          t.eval('_pry_.binding_stack.size').should == 1
          t.eval 'exit-all'
        }
      end

      it "breaks out of the parent session" do
        pry_tester(:outer).simulate_repl do |o|
          o.context = :inner
          o.simulate_repl { |i|
            i.eval('_pry_.current_context.eval("self")').should == :inner
            i.eval('_pry_.binding_stack.size').should == 2
            i.eval @control_d
            i.eval('_pry_.binding_stack.size').should == 1
            i.eval('_pry_.current_context.eval("self")').should == :outer
            i.eval 'throw :breakout'
          }
          o.eval 'exit-all'
        end
      end
    end

  end

end

Version data entries

77 entries across 77 versions & 5 rubygems

Version Path
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/pry-0.9.12.6/spec/control_d_handler_spec.rb
pry-0.9.12.6 spec/control_d_handler_spec.rb
pry-0.9.12.6-i386-mswin32 spec/control_d_handler_spec.rb
pry-0.9.12.6-i386-mingw32 spec/control_d_handler_spec.rb
pry-0.9.12.6-java spec/control_d_handler_spec.rb
pry-0.9.12.5 spec/control_d_handler_spec.rb
pry-0.9.12.5-i386-mswin32 spec/control_d_handler_spec.rb
pry-0.9.12.5-i386-mingw32 spec/control_d_handler_spec.rb
pry-0.9.12.5-java spec/control_d_handler_spec.rb
pry-0.9.12.4 spec/control_d_handler_spec.rb
pry-0.9.12.4-i386-mswin32 spec/control_d_handler_spec.rb
pry-0.9.12.4-i386-mingw32 spec/control_d_handler_spec.rb
pry-0.9.12.4-java spec/control_d_handler_spec.rb
pry-0.9.12.3 spec/control_d_handler_spec.rb
pry-0.9.12.3-i386-mswin32 spec/control_d_handler_spec.rb
pry-0.9.12.3-i386-mingw32 spec/control_d_handler_spec.rb
pry-0.9.12.3-java spec/control_d_handler_spec.rb
torquebox-console-0.3.0 vendor/bundle/jruby/1.9/gems/pry-0.9.12-java/spec/control_d_handler_spec.rb
sshp-0.0.2 vendor/ruby/1.9.1/gems/pry-0.9.12.2/spec/control_d_handler_spec.rb
sshp-0.0.1 vendor/ruby/1.9.1/gems/pry-0.9.12.2/spec/control_d_handler_spec.rb