mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Import RubyGems trunk revision 1493.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7a4aad7535
commit
fbf59bdbea
144 changed files with 21330 additions and 0 deletions
100
test/rubygems/test_gem_commands_pristine_command.rb
Normal file
100
test/rubygems/test_gem_commands_pristine_command.rb
Normal file
|
@ -0,0 +1,100 @@
|
|||
require 'test/unit'
|
||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||
require 'rubygems/commands/pristine_command'
|
||||
|
||||
class TestGemCommandsPristineCommand < RubyGemTestCase
|
||||
|
||||
def setup
|
||||
super
|
||||
@cmd = Gem::Commands::PristineCommand.new
|
||||
end
|
||||
|
||||
def test_execute
|
||||
a = quick_gem 'a' do |s| s.executables = %w[foo] end
|
||||
FileUtils.mkdir_p File.join(@tempdir, 'bin')
|
||||
File.open File.join(@tempdir, 'bin', 'foo'), 'w' do |fp|
|
||||
fp.puts "#!/usr/bin/ruby"
|
||||
end
|
||||
|
||||
install_gem a
|
||||
|
||||
@cmd.options[:args] = %w[a]
|
||||
|
||||
use_ui @ui do
|
||||
@cmd.execute
|
||||
end
|
||||
|
||||
out = @ui.output.split "\n"
|
||||
|
||||
assert_equal "Restoring gem(s) to pristine condition...", out.shift
|
||||
assert_equal "#{a.full_name} is in pristine condition", out.shift
|
||||
assert out.empty?, out.inspect
|
||||
end
|
||||
|
||||
def test_execute_all
|
||||
a = quick_gem 'a' do |s| s.executables = %w[foo] end
|
||||
FileUtils.mkdir_p File.join(@tempdir, 'bin')
|
||||
File.open File.join(@tempdir, 'bin', 'foo'), 'w' do |fp|
|
||||
fp.puts "#!/usr/bin/ruby"
|
||||
end
|
||||
|
||||
install_gem a
|
||||
|
||||
gem_bin = File.join @gemhome, 'gems', "#{a.full_name}", 'bin', 'foo'
|
||||
|
||||
FileUtils.rm gem_bin
|
||||
|
||||
@cmd.handle_options %w[--all]
|
||||
|
||||
use_ui @ui do
|
||||
@cmd.execute
|
||||
end
|
||||
|
||||
out = @ui.output.split "\n"
|
||||
|
||||
assert_equal "Restoring gem(s) to pristine condition...", out.shift
|
||||
assert_equal "Restoring 1 file to #{a.full_name}...", out.shift
|
||||
assert_equal " #{gem_bin}", out.shift
|
||||
assert out.empty?, out.inspect
|
||||
end
|
||||
|
||||
def test_execute_missing_cache_gem
|
||||
a = quick_gem 'a' do |s| s.executables = %w[foo] end
|
||||
FileUtils.mkdir_p File.join(@tempdir, 'bin')
|
||||
File.open File.join(@tempdir, 'bin', 'foo'), 'w' do |fp|
|
||||
fp.puts "#!/usr/bin/ruby"
|
||||
end
|
||||
|
||||
install_gem a
|
||||
|
||||
FileUtils.rm File.join(@gemhome, 'cache', "#{a.full_name}.gem")
|
||||
|
||||
@cmd.options[:args] = %w[a]
|
||||
|
||||
use_ui @ui do
|
||||
@cmd.execute
|
||||
end
|
||||
|
||||
out = @ui.output.split "\n"
|
||||
|
||||
assert_equal "Restoring gem\(s\) to pristine condition...", out.shift
|
||||
assert out.empty?, out.inspect
|
||||
|
||||
assert_equal "ERROR: Cached gem for #{a.full_name} not found, use `gem install` to restore\n",
|
||||
@ui.error
|
||||
end
|
||||
|
||||
def test_execute_no_gem
|
||||
@cmd.options[:args] = %w[]
|
||||
|
||||
e = assert_raise Gem::CommandLineError do
|
||||
use_ui @ui do
|
||||
@cmd.execute
|
||||
end
|
||||
end
|
||||
|
||||
assert_match %r|specify a gem name|, e.message
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue