Sha256: 3b2a0d6edb80956de3bc5acf74085f12e46c7c764081487eed0e3d2165d76170

Contents?: true

Size: 894 Bytes

Versions: 2

Compression:

Stored size: 894 Bytes

Contents

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'childprocess'
require 'spec'
require 'spec/autorun'
require 'tempfile'

module ChildProcessSpecHelper

  def ruby_process(*args)
    @process = ChildProcess.build("ruby" , *args)
  end

  def sleeping_ruby
    ruby_process("-e", "sleep")
  end

  def ignored(signal)
    code = <<-RUBY
      trap(#{signal.inspect}, "IGNORE")
      sleep
    RUBY

    ruby_process tmp_script(code)
  end

  def exit_with(exit_code)
    ruby_process(tmp_script("exit(#{exit_code})"))
  end

  def tmp_script(code)
    tf = Tempfile.new("childprocess-temp")
    tf << code
    tf.close

    puts code if $DEBUG

    tf.path
  end
end


Spec::Runner.configure do |config|
  config.include(ChildProcessSpecHelper)
  config.after(:each) {
    @process && @process.alive? && @process.stop
  }
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
childprocess-0.0.2 spec/spec_helper.rb
childprocess-0.0.1 spec/spec_helper.rb