Add Homebrew.install_gem_setup_path! function.

This uses the logic from tests.rb in man.rb too so that this can be
shared in a few places.
This commit is contained in:
Mike McQuaid 2015-01-02 12:42:02 +00:00
parent 81986ee7a7
commit 9e8103cf38
3 changed files with 12 additions and 8 deletions

View File

@ -13,7 +13,7 @@ module Homebrew
end
end
which("ronn") || odie("You need to \"gem install ronn\" and put it in your path.")
Homebrew.install_gem_setup_path! "ronn"
if ARGV.include?("--server") || ARGV.include?("-s")
puts "Man page test server: http://localhost:1207/"

View File

@ -1,12 +1,8 @@
module Homebrew
def tests
(HOMEBREW_LIBRARY/'Homebrew/test').cd do
ENV['TESTOPTS'] = '-v' if ARGV.verbose?
quiet_system("gem", "list", "--installed", "bundler") || \
system("gem", "install", "--no-ri", "--no-rdoc",
"--user-install", "bundler")
require 'rubygems'
ENV["PATH"] = "#{Gem.user_dir}/bin:#{ENV["PATH"]}"
(HOMEBREW_LIBRARY/"Homebrew/test").cd do
ENV["TESTOPTS"] = "-v" if ARGV.verbose?
Homebrew.install_gem_setup_path! "bundler"
quiet_system("bundle", "check") || \
system("bundle", "install", "--path", "vendor/bundle")
system "bundle", "exec", "rake", "test"

View File

@ -119,6 +119,14 @@ module Homebrew
def self.git_last_commit
HOMEBREW_REPOSITORY.cd { `git show -s --format="%cr" HEAD 2>/dev/null`.chuzzle }
end
def self.install_gem_setup_path! gem
return if quiet_system "gem", "list", "--installed", gem
system "gem", "install", "--no-ri", "--no-rdoc",
"--user-install", gem
require "rubygems"
ENV["PATH"] = "#{Gem.user_dir}/bin:#{ENV["PATH"]}"
end
end
def with_system_path