Sha256: 362f77bc8ccb0f0a13474ba8bbab1a43a87cc9913f65aaef29d27d31da4c4f60

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 KB

Contents

require 'helper'

describe "The whole thing" do
  it "should let you run commands in the middle of multiline expressions" do
    ReplTester.start do
      input  'def a'
      input  '!'
      output /^Input buffer cleared/

      input  '5'
      output '=> 5'
    end
  end

  describe "eval_string and binding_stack" do
    it "shouldn't break if we start a nested REPL" do
      ReplTester.start do
        input  'Pry::REPL.new(_pry_, :target => 10).start'
        output ''
        prompt /10.*> $/

        input  'self'
        output '=> 10'

        input  nil # Ctrl-D
        output ''

        input  'self'
        output '=> main'
      end
    end

    it "shouldn't break if we start a nested instance" do
      ReplTester.start do
        input  'Pry.start(10)'
        output ''
        prompt /10.*> $/

        input  'self'
        output '=> 10'

        input  nil # Ctrl-D
        output '=> nil' # return value of Pry session

        input  'self'
        output '=> main'
      end
    end

    it "shouldn't break if we pop bindings in Ruby" do
      ReplTester.start do
        input  'cd 10'
        output ''
        prompt /10.*> $/

        input  '_pry_.binding_stack.pop'
        output /^=> #<Binding/
        prompt /main.*> $/

        input  '_pry_.binding_stack.pop'
        output /^=> #<Binding/
        assert_exited
      end
    end

    it "should immediately evaluate eval_string after cmd if complete" do
      set = Pry::CommandSet.new do
        import Pry::Commands

        command 'hello!' do
          eval_string.replace('"hello"')
        end
      end

      ReplTester.start(:commands => set) do
        input  'def x'
        output ''
        prompt /\*   $/

        input  'hello!'
        output '=> "hello"'
        prompt /> $/
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pry-1.0.0.pre1-i386-mswin32 spec/pry_repl_spec.rb
pry-1.0.0.pre1-i386-mingw32 spec/pry_repl_spec.rb