Class: Gem::InstallerTestCase
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
TestCase,
MiniTest::Unit::TestCase
|
|
Instance Chain:
|
|
Inherits: |
Gem::TestCase
|
Defined in: | lib/rubygems/installer_test_case.rb |
Overview
A test case for Installer.
Class Attribute Summary
TestCase - Inherited
.vc_windows? | Returns whether or not we're on a version of Ruby built with VC++ (or Borland) versus Cygwin, Mingw, etc. |
.win_platform? | Is this test being run on a Windows platform? |
Class Method Summary
TestCase - Inherited
.cert_path | Returns the path to the certificate named |
.key_path | Returns the path to the key named |
.load_cert | Loads certificate named |
.load_key | Loads an RSA private key named |
.make_command | Returns the make command for the current platform. |
.process_based_port | Allows tests to use a random (but controlled) port number instead of a hardcoded one. |
.rubybin | Finds the path to the Ruby executable. |
Instance Attribute Summary
TestCase - Inherited
#have_git? | Skips this test unless you have a git executable. |
#nmake_found? | Returns whether or not the nmake command could be found. |
#vc_windows? | Returns whether or not we're on a version of Ruby built with VC++ (or Borland) versus Cygwin, Mingw, etc. |
#win_platform? | Is this test being run on a Windows platform? |
DefaultUserInteraction - Included
Instance Method Summary
-
#setup
- @gem
-
#util_inst_bindir
The path where installed executables live.
-
#util_installer(spec, gem_home, user = false)
Creates an installer for
spec
that will install intogem_home
. -
#util_make_exec(spec = @spec, shebang = "#!/usr/bin/ruby")
Adds an executable named “executable” to
spec
with the givenshebang
. -
#util_setup_gem(ui = @ui)
Builds the @spec gem and returns an installer for it.
TestCase - Inherited
#add_to_fetcher | Add |
#all_spec_names, #assert_activate, #assert_contains_make_command, | |
#assert_path_exists | TODO: move to minitest. |
#build_rake_in | Allows the proper version of |
#common_installer_setup, #common_installer_teardown, | |
#create_tmpdir | creates a temporary directory with hax TODO: deprecate and remove. |
#dep | Construct a new Dependency. |
#dependency_request | Constructs a Resolver::DependencyRequest from a Dependency |
#enable_shared | Sets the ENABLE_SHARED entry in |
#git_gem | A git_gem is used with a gem dependencies file. |
#install_default_gems | Installs the provided default specs including writing the spec file. |
#install_default_specs | Install the provided default specs. |
#install_gem | Builds and installs the Specification |
#install_gem_user | Builds and installs the Specification |
#install_specs | Install the provided specs. |
#loaded_spec_names, | |
#make_command | Returns the make command for the current platform. |
#mu_pp | Enables pretty-print for all tests. |
#new_default_spec, #parse_make_command_line, | |
#process_based_port | See |
#quick_gem | Creates a Specification with a minimum of extra work. |
#read_binary | Reads a binary file at path |
#read_cache | Reads a Marshal file at path |
#refute_path_exists | TODO: move to minitest. |
#req | Constructs a new Requirement. |
#save_gemspec | create_gemspec creates gem specification in given |
#save_loaded_features, #scan_make_command_lines, | |
#setup | #setup prepares a sandboxed location to install gems. |
#spec | Constructs a new Specification. |
#spec_fetcher | Creates a SpecFetcher pre-filled with the gems or specs defined in the block. |
#teardown |
|
#uninstall_gem | Uninstalls the Specification |
#unresolved_names, | |
#util_build_gem | Builds a gem from |
#util_clear_gems | Removes all installed gems from @gemhome. |
#util_gem | Creates a gem with |
#util_gzip | Gzips |
#util_make_gems | Creates several default gems which all have a lib/code.rb file. |
#util_remove_gem, #util_restore_RUBY_VERSION, | |
#util_set_arch | Set the platform to |
#util_set_RUBY_VERSION, | |
#util_setup_fake_fetcher | Sets up a fake fetcher using the gems from |
#util_setup_spec_fetcher | Sets up SpecFetcher to return information from the gems in |
#util_spec | Creates a spec with |
#util_zip | Deflates |
#v | Construct a new Version. |
#vendor_gem | A vendor_gem is used with a gem dependencies file. |
#wait_for_child_process_to_exit | In case we're building docs in a background process, this method waits for that process to exit (or if it's already been reaped, or never happened, swallows the |
#write_file | Writes a binary file to path which is relative to @gemhome. |
DefaultUserInteraction - Included
Text - Included
#clean_text | Remove any non-printable characters and make the text suitable for printing. |
#format_text | Wraps |
#levenshtein_distance | This code is based directly on the Text gem implementation Returns a value representing the “cost” of transforming str1 into str2. |
#truncate_text |
Instance Method Details
#setup
- @gem
-
the path to a built gem from @spec
- @user_spec
-
the path to a built gem from @user_spec
- @installer
-
a Gem::Installer for the @spec that installs into @gemhome
- @user_installer
-
a Gem::Installer for the @user_spec that installs into Gem.user_dir
# File 'lib/rubygems/installer_test_case.rb', line 86
def setup super @spec = quick_gem 'a' do |spec| util_make_exec spec end @user_spec = quick_gem 'b' do |spec| util_make_exec spec end util_build_gem @spec util_build_gem @user_spec @gem = @spec.cache_file @user_gem = @user_spec.cache_file @installer = util_installer @spec, @gemhome @user_installer = util_installer @user_spec, Gem.user_dir, :user Gem::Installer.path_warning = false end
#util_inst_bindir
The path where installed executables live
# File 'lib/rubygems/installer_test_case.rb', line 122
def util_inst_bindir File.join @gemhome, "bin" end
#util_installer(spec, gem_home, user = false)
Creates an installer for spec
that will install into gem_home
. If user
is true a user-install will be performed.
#util_make_exec(spec = @spec, shebang = "#!/usr/bin/ruby")
Adds an executable named “executable” to spec
with the given shebang
.
The executable is also written to the bin dir in @tmpdir and the installed gem directory for spec
.
# File 'lib/rubygems/installer_test_case.rb', line 132
def util_make_exec(spec = @spec, shebang = "#!/usr/bin/ruby") spec.executables = %w[executable] spec.files << 'bin/executable' exec_path = spec.bin_file "executable" write_file exec_path do |io| io.puts shebang end bin_path = File.join @tempdir, "bin", "executable" write_file bin_path do |io| io.puts shebang end end
#util_setup_gem(ui = @ui)
Builds the @spec gem and returns an installer for it. The built gem includes:
bin/executable
lib/code.rb
ext/a/mkrf_conf.rb
# File 'lib/rubygems/installer_test_case.rb', line 155
def util_setup_gem(ui = @ui) # HACK fix use_ui to make this automatic @spec.files << File.join('lib', 'code.rb') @spec.extensions << File.join('ext', 'a', 'mkrf_conf.rb') Dir.chdir @tempdir do FileUtils.mkdir_p 'bin' FileUtils.mkdir_p 'lib' FileUtils.mkdir_p File.join('ext', 'a') File.open File.join('bin', 'executable'), 'w' do |f| f.puts "raise 'ran executable'" end File.open File.join('lib', 'code.rb'), 'w' do |f| f.puts '1' end File.open File.join('ext', 'a', 'mkrf_conf.rb'), 'w' do |f| f << <<-EOF File.open 'Rakefile', 'w' do |rf| rf.puts "task :default" end EOF end yield @spec if block_given? use_ui ui do FileUtils.rm_f @gem @gem = Gem::Package.build @spec end end @installer = Gem::Installer.at @gem end