Sha256: a5abc262d70c57d63244260b59638df5545ee1dae14c1cd8acf2beb991de6313

Contents?: true

Size: 957 Bytes

Versions: 8

Compression:

Stored size: 957 Bytes

Contents

require 'pty'
require 'expect'

class IRubyTest::IntegrationTest < IRubyTest::TestBase
  def setup
    $expect_verbose = false # make true if you want to dump the output of iruby console

    @in, @out, pid = PTY.spawn('bin/iruby --simple-prompt')
    @waiter = Thread.start { Process.waitpid(pid) }
    expect 'In [', 30
    expect '1'
    expect ']:'
  end

  def teardown
    @in.close
    @out.close
    @waiter.join
  end

  def write(input)
    @out.puts input
  end

  def expect(pattern, timeout = 10)
    assert @in.expect(pattern, timeout), "#{pattern} expected, but timeout"
  end

  def wait_prompt
    expect 'In ['
    expect ']:'
  end

  def test_interaction
    omit("This test too much unstable")

    write '"Hello, world!"'
    expect '"Hello, world!"'

    wait_prompt
    write 'puts "Hello!"'
    expect 'Hello!'

    wait_prompt
    write '12 + 12'
    expect '24'

    wait_prompt
    write 'ls'
    expect 'self.methods'
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
iruby-0.7.4 test/integration_test.rb
iruby-0.7.3 test/integration_test.rb
iruby-0.7.2 test/integration_test.rb
iruby-0.7.1 test/integration_test.rb
iruby-0.7.0 test/integration_test.rb
iruby-0.6.1 test/integration_test.rb
iruby-0.6.0 test/integration_test.rb
iruby-0.5.0 test/integration_test.rb