features/support/env.rb in spork-0.8.5 vs features/support/env.rb in spork-0.9.0.rc

- old
+ new

@@ -1,19 +1,22 @@ require 'rubygems' +require 'pathname' require 'fileutils' require 'forwardable' require 'tempfile' require 'spec/expectations' require 'timeout' -require 'spork' require(File.dirname(__FILE__) + '/background_job.rb') +SPORK_ROOT = Pathname.new(File.expand_path('../../', File.dirname(__FILE__))) class SporkWorld - BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/spork') RUBY_BINARY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) - SANDBOX_DIR = File.expand_path(File.join(File.dirname(__FILE__), '../../tmp/sandbox')) + BINARY = SPORK_ROOT + 'bin/spork' + SANDBOX_DIR = SPORK_ROOT + "tmp/sandbox" + GEMFILES_ROOT = SPORK_ROOT + "features/gemfiles" + SPORK_LIBDIR = SPORK_ROOT + "lib" extend Forwardable def_delegators SporkWorld, :sandbox_dir, :spork_lib_dir def spork_lib_dir @@ -68,19 +71,19 @@ def run(command) stderr_file = Tempfile.new('spork') stderr_file.close in_current_dir do - @last_stdout = `#{command} 2> #{stderr_file.path}` + @last_stdout = `env RUBYOPT= bundle exec #{command} 2> #{stderr_file.path}` @last_exit_status = $?.exitstatus end @last_stderr = IO.read(stderr_file.path) end def run_in_background(command) in_current_dir do - @background_job = BackgroundJob.run(command) + @background_job = BackgroundJob.run("env RUBYOPT= bundle exec " + command) end @background_jobs << @background_job @background_job end @@ -91,11 +94,14 @@ end end @background_jobs.clear @background_job = nil end - end + +require(SPORK_ROOT + "features/support/bundler_helpers.rb") +BundlerHelpers.set_gemfile(ENV["GEMFILE"]) + World do SporkWorld.new end