Class Gem::InstallerTestCase
In: lib/rubygems/installer_test_case.rb
Parent: Gem::TestCase

A test case for Gem::Installer.

Methods

Public Instance methods

[Source]

    # File lib/rubygems/installer_test_case.rb, line 57
57:   def setup
58:     super
59: 
60:     @spec = quick_gem 'a'
61:     util_make_exec @spec
62: 
63:     @gem = File.join @tempdir, @spec.file_name
64: 
65:     @installer = util_installer @spec, @gem, @gemhome
66: 
67:     @user_spec = quick_gem 'b'
68:     util_make_exec @user_spec
69: 
70:     @user_gem = File.join @tempdir, @user_spec.file_name
71: 
72:     @user_installer = util_installer @user_spec, @user_gem, Gem.user_dir
73:     @user_installer.gem_dir = File.join(Gem.user_dir, 'gems',
74:                                         @user_spec.full_name)
75:   end

[Source]

    # File lib/rubygems/installer_test_case.rb, line 77
77:   def util_gem_bindir spec = @spec
78:     File.join util_gem_dir(spec), "bin"
79:   end

[Source]

    # File lib/rubygems/installer_test_case.rb, line 81
81:   def util_gem_dir spec = @spec
82:     File.join @gemhome, "gems", spec.full_name
83:   end

[Source]

    # File lib/rubygems/installer_test_case.rb, line 85
85:   def util_inst_bindir
86:     File.join @gemhome, "bin"
87:   end

[Source]

     # File lib/rubygems/installer_test_case.rb, line 133
133:   def util_installer(spec, gem_path, gem_home)
134:     util_build_gem spec
135:     FileUtils.mv Gem.cache_gem(spec.file_name), @tempdir
136:     installer = Gem::Installer.new gem_path
137:     installer.gem_dir = util_gem_dir
138:     installer.gem_home = gem_home
139:     installer.spec = spec
140: 
141:     installer
142:   end

[Source]

     # File lib/rubygems/installer_test_case.rb, line 89
 89:   def util_make_exec(spec = @spec, shebang = "#!/usr/bin/ruby")
 90:     spec.executables = %w[executable]
 91:     spec.files << 'bin/executable'
 92: 
 93:     bindir = util_gem_bindir spec
 94:     FileUtils.mkdir_p bindir
 95:     exec_path = File.join bindir, 'executable'
 96:     open exec_path, 'w' do |io|
 97:       io.puts shebang
 98:     end
 99: 
100:     temp_bin = File.join(@tempdir, 'bin')
101:     FileUtils.mkdir_p temp_bin
102:     open File.join(temp_bin, 'executable'), 'w' do |io|
103:       io.puts shebang
104:     end
105:   end

[Source]

     # File lib/rubygems/installer_test_case.rb, line 107
107:   def util_setup_gem(ui = @ui) # HACK fix use_ui to make this automatic
108:     @spec.files << File.join('lib', 'code.rb')
109:     @spec.extensions << File.join('ext', 'a', 'mkrf_conf.rb')
110: 
111:     Dir.chdir @tempdir do
112:       FileUtils.mkdir_p 'bin'
113:       FileUtils.mkdir_p 'lib'
114:       FileUtils.mkdir_p File.join('ext', 'a')
115:       File.open File.join('bin', 'executable'), 'w' do |f| f.puts '1' end
116:       File.open File.join('lib', 'code.rb'), 'w' do |f| f.puts '1' end
117:       File.open File.join('ext', 'a', 'mkrf_conf.rb'), 'w' do |f|
118:         f << "File.open 'Rakefile', 'w' do |rf| rf.puts \"task :default\" end\n"
119:       end
120: 
121:       use_ui ui do
122:         FileUtils.rm @gem
123:         Gem::Builder.new(@spec).build
124:       end
125:     end
126: 
127:     @installer = Gem::Installer.new @gem
128:   end

[Validate]