Class: Gem::InstallerTestCase
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
Gem::TestCase
|
Defined in: | lib/rubygems/installer_test_case.rb |
Overview
A test case for Installer
.
Constant Summary
TestCase
- Inherited
Class Attribute Summary
TestCase
- Inherited
.java_platform? | Is this test being run on a Java platform? |
.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. |
.escape_path |
Deprecate
- Extended
deprecate | Simple deprecation method that deprecates |
skip_during | Temporarily turn off warnings. |
Instance Attribute Summary
TestCase
- Inherited
#have_git? | Skips this test unless you have a git executable. |
#java_platform? | Is this test being run on a Java platform? |
#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? |
#fetcher, #gem_repo, #uri |
DefaultUserInteraction
- Included
Instance Method Summary
- #setup
-
#setup_base_gem
Creates the following instance variables:
-
#setup_base_installer
Creates the following instance variables:
-
#setup_base_spec
Sets up a generic specification for testing the rubygems installer.
-
#setup_base_user_installer
Creates the following instance variables:
-
#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", bindir = "bin")
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.
-
#util_setup_installer
Sets up the base @gem, builds it and returns an installer for it.
TestCase
- Inherited
#add_to_fetcher | Add |
#all_spec_names, #assert_activate, #assert_contains_make_command, #assert_directory_exists, | |
#assert_path_exists | TODO: move to minitest. |
#bindir | Sets the bindir entry in |
#build_rake_in | Allows the proper version of |
#common_installer_setup, #common_installer_teardown, | |
#dep | Construct a new |
#dependency_request | Constructs a |
#enable_shared | Sets the ENABLE_SHARED entry in |
#exeext | Sets the EXEEXT 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 |
#install_gem_user | Builds and installs the |
#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 |
#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 |
#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 |
#spec_fetcher | Creates a |
#teardown |
|
#uninstall_gem | Uninstalls the |
#unresolved_names, | |
#util_build_gem | Builds a gem from |
#util_clear_gems | Removes all installed gems from @gemhome. |
#util_clear_RUBY_VERSION, | |
#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_spec_fetcher | Sets up |
#util_spec | Creates a spec with |
#util_zip | Deflates |
#v | Construct a new |
#vendor_gem | A vendor_gem is used with a gem dependencies file. |
#vendordir | Sets the vendordir entry in |
#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 |
#with_clean_path_to_ruby, | |
#write_file | Writes a binary file to path which is relative to @gemhome. |
#in_path? |
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 |
#truncate_text, #min3 |
Instance Method Details
#setup
[ GitHub ]# File 'lib/rubygems/installer_test_case.rb', line 69
def setup super Gem::Installer.path_warning = false end
#setup_base_gem
Creates the following instance variables:
- @spec
-
a spec named ‘a’, intended for regular installs
And returns a gem built for the @spec
# File 'lib/rubygems/installer_test_case.rb', line 127
def setup_base_gem @spec = setup_base_spec util_build_gem @spec @spec.cache_file end
#setup_base_installer
Creates the following instance variables:
- @spec
-
a spec named ‘a’, intended for regular installs
- @gem
-
the path to a built gem from @spec
And returns a Installer
for the @spec that installs into @gemhome
# File 'lib/rubygems/installer_test_case.rb', line 114
def setup_base_installer @gem = setup_base_gem util_installer @spec, @gemhome end
#setup_base_spec
Sets up a generic specification for testing the rubygems installer
And returns it
# File 'lib/rubygems/installer_test_case.rb', line 138
def setup_base_spec quick_gem 'a' do |spec| util_make_exec spec end end
#setup_base_user_installer
Creates the following instance variables:
- @spec
-
a spec named ‘a’, intended for regular installs
- @user_spec
-
a spec named ‘b’, intended for user installs
- @gem
-
the path to a built gem from @spec
- @user_gem
-
the path to a built gem from @user_spec
And returns a Installer
for the @user_spec that installs into Gem.user_dir
# File 'lib/rubygems/installer_test_case.rb', line 159
def setup_base_user_installer @user_spec = quick_gem 'b' do |spec| util_make_exec spec end util_build_gem @user_spec @user_gem = @user_spec.cache_file util_installer @user_spec, Gem.user_dir, :user end
#util_inst_bindir
The path where installed executables live
# File 'lib/rubygems/installer_test_case.rb', line 78
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", bindir = "bin")
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 88
def util_make_exec(spec = @spec, shebang = "#!/usr/bin/ruby", bindir = "bin") spec.executables = %w[executable] spec.bindir = bindir 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 188
def util_setup_gem(ui = @ui) @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 Gem::Installer.at @gem end
#util_setup_installer
Sets up the base @gem, builds it and returns an installer for it.
# File 'lib/rubygems/installer_test_case.rb', line 174
def util_setup_installer @gem = setup_base_gem util_setup_gem end