Fail with an error on Ruby 1.8 when posix-spawn is not present.
This commit is contained in:
@@ -34,6 +34,7 @@ class Foreman::CLI < Thor
|
||||
end
|
||||
|
||||
def start(process=nil)
|
||||
require_posix_spawn_for_ruby_18!
|
||||
check_procfile!
|
||||
load_environment!
|
||||
engine.load_procfile(procfile)
|
||||
@@ -137,6 +138,14 @@ private ######################################################################
|
||||
end
|
||||
end
|
||||
|
||||
def require_posix_spawn_for_ruby_18!
|
||||
begin
|
||||
Kernel.require 'posix/spawn' # Use Kernel explicitly so we can mock the require call in the spec
|
||||
rescue LoadError
|
||||
error "foreman requires gem `posix-spawn` on Ruby #{RUBY_VERSION}. Please `gem install posix-spawn`."
|
||||
end if Foreman.ruby_18?
|
||||
end
|
||||
|
||||
def procfile
|
||||
case
|
||||
when options[:procfile] then options[:procfile]
|
||||
|
||||
@@ -100,4 +100,12 @@ describe "Foreman::CLI", :fakefs do
|
||||
end
|
||||
end
|
||||
|
||||
describe "when posix-spawn is not present on ruby 1.8" do
|
||||
it "should fail with an error" do
|
||||
mock(Kernel).require('posix/spawn') { raise LoadError }
|
||||
output = foreman("start -f #{resource_path("Procfile")}")
|
||||
output.should == "ERROR: foreman requires gem `posix-spawn` on Ruby #{RUBY_VERSION}. Please `gem install posix-spawn`.\n"
|
||||
end
|
||||
end if running_ruby_18?
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user