public
Rubygem
Description: Behaviour Driven Development framework for Ruby
Homepage: http://rspec.info
Clone URL: git://github.com/dchelimsky/rspec.git
Click here to lend your support to: rspec and make a donation at www.pledgie.com !
rspec / spec / ruby_forker.rb
100644 13 lines (12 sloc) 0.409 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
require 'rbconfig'
 
module RubyForker
  # Forks a ruby interpreter with same type as ourself.
  # juby will fork jruby, ruby will fork ruby etc.
  def ruby(args, stderr=nil)
    config = ::Config::CONFIG
    interpreter = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
    cmd = "#{interpreter} #{args}"
    cmd << " 2> #{stderr}" unless stderr.nil?
    `#{cmd}`
  end
end