mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
d5e810dbd2
* lib/rubygems/basic_specification.rb (class Gem): * lib/rubygems/commands/contents_command.rb (prefix or only the files that are requir): * lib/rubygems/commands/install_command.rb (to write the specification by hand): * lib/rubygems/commands/setup_command.rb (class Gem): * lib/rubygems/commands/setup_command.rb (TEXT): * lib/rubygems/compatibility.rb (module Gem): * lib/rubygems/defaults.rb (module Gem): * lib/rubygems/deprecate.rb (module Gem): * lib/rubygems/installer.rb (class Gem): * lib/rubygems/platform.rb (class Gem): * lib/rubygems/rdoc.rb (class Gem): * lib/rubygems/request_set/lockfile.rb (class Gem): * lib/rubygems/resolver/installer_set.rb (class Gem): * lib/rubygems/resolver.rb (class Gem): * lib/rubygems/specification.rb (class Gem): * lib/rubygems/test_case.rb (class Gem): * lib/rubygems/test_case.rb (Also): * lib/rubygems/uninstaller.rb (class Gem): * lib/rubygems.rb (module Gem): * test/rubygems/test_gem.rb (class TestGem): * test/rubygems/test_gem_commands_contents_command.rb (lib): * test/rubygems/test_gem_commands_environment_command.rb (class TestGemCommandsEnvironmentCommand): * test/rubygems/test_gem_commands_install_command.rb (ERROR): * test/rubygems/test_gem_commands_update_command.rb (class TestGemCommandsUpdateCommand): * test/rubygems/test_gem_dependency_installer.rb (class TestGemDependencyInstaller): * test/rubygems/test_gem_installer.rb (load Gem): * test/rubygems/test_gem_installer.rb (gem): * test/rubygems/test_gem_request_set_lockfile.rb (GEM): * test/rubygems/test_gem_request_set_lockfile.rb (DEPENDENCIES): * test/rubygems/test_gem_specification.rb (dependencies): * test/rubygems/test_gem_specification.rb (duplicate dependency on b): * test/rubygems/test_gem_uninstaller.rb (class TestGemUninstaller): git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
196 lines
4.1 KiB
Ruby
196 lines
4.1 KiB
Ruby
require 'rubygems/test_case'
|
|
require 'rubygems/commands/contents_command'
|
|
|
|
class TestGemCommandsContentsCommand < Gem::TestCase
|
|
|
|
def setup
|
|
super
|
|
|
|
@cmd = Gem::Commands::ContentsCommand.new
|
|
end
|
|
|
|
def gem name
|
|
spec = quick_gem name do |gem|
|
|
gem.files = %W[lib/#{name}.rb Rakefile]
|
|
end
|
|
write_file File.join(*%W[gems #{spec.full_name} lib #{name}.rb])
|
|
write_file File.join(*%W[gems #{spec.full_name} Rakefile])
|
|
end
|
|
|
|
def test_execute
|
|
@cmd.options[:args] = %w[foo]
|
|
|
|
gem 'foo'
|
|
|
|
use_ui @ui do
|
|
@cmd.execute
|
|
end
|
|
|
|
assert_match %r|lib/foo\.rb|, @ui.output
|
|
assert_match %r|Rakefile|, @ui.output
|
|
assert_equal "", @ui.error
|
|
end
|
|
|
|
def test_execute_all
|
|
@cmd.options[:all] = true
|
|
|
|
gem 'foo'
|
|
gem 'bar'
|
|
|
|
use_ui @ui do
|
|
@cmd.execute
|
|
end
|
|
|
|
assert_match %r|lib/foo\.rb|, @ui.output
|
|
assert_match %r|lib/bar\.rb|, @ui.output
|
|
assert_match %r|Rakefile|, @ui.output
|
|
assert_equal "", @ui.error
|
|
end
|
|
|
|
def test_execute_bad_gem
|
|
@cmd.options[:args] = %w[foo]
|
|
|
|
assert_raises Gem::MockGemUi::TermError do
|
|
use_ui @ui do
|
|
@cmd.execute
|
|
end
|
|
end
|
|
|
|
assert_match %r|Unable to find gem 'foo' in default gem paths|, @ui.output
|
|
assert_match %r|Directories searched:|, @ui.output
|
|
assert_equal "", @ui.error
|
|
end
|
|
|
|
def test_execute_exact_match
|
|
@cmd.options[:args] = %w[foo]
|
|
gem 'foo'
|
|
gem 'bar'
|
|
|
|
use_ui @ui do
|
|
@cmd.execute
|
|
end
|
|
|
|
assert_match %r|lib/foo\.rb|, @ui.output
|
|
assert_match %r|Rakefile|, @ui.output
|
|
assert_equal "", @ui.error
|
|
end
|
|
|
|
def test_execute_lib_only
|
|
@cmd.options[:args] = %w[foo]
|
|
@cmd.options[:lib_only] = true
|
|
|
|
gem 'foo'
|
|
|
|
use_ui @ui do
|
|
@cmd.execute
|
|
end
|
|
|
|
assert_match %r|lib/foo\.rb|, @ui.output
|
|
refute_match %r|Rakefile|, @ui.output
|
|
|
|
assert_equal "", @ui.error
|
|
end
|
|
|
|
def test_execute_missing_single
|
|
@cmd.options[:args] = %w[foo]
|
|
|
|
assert_raises Gem::MockGemUi::TermError do
|
|
use_ui @ui do
|
|
@cmd.execute
|
|
end
|
|
end
|
|
|
|
assert_match "Unable to find gem 'foo'", @ui.output
|
|
assert_empty @ui.error
|
|
end
|
|
|
|
def test_execute_missing_multiple
|
|
@cmd.options[:args] = %w[foo bar]
|
|
|
|
gem 'foo'
|
|
|
|
use_ui @ui do
|
|
@cmd.execute
|
|
end
|
|
|
|
assert_match "lib/foo.rb", @ui.output
|
|
assert_match "Unable to find gem 'bar'", @ui.output
|
|
|
|
assert_empty @ui.error
|
|
end
|
|
|
|
def test_execute_multiple
|
|
@cmd.options[:args] = %w[foo bar]
|
|
|
|
gem 'foo'
|
|
gem 'bar'
|
|
|
|
use_ui @ui do
|
|
@cmd.execute
|
|
end
|
|
|
|
assert_match %r|lib/foo\.rb|, @ui.output
|
|
assert_match %r|lib/bar\.rb|, @ui.output
|
|
assert_match %r|Rakefile|, @ui.output
|
|
assert_equal "", @ui.error
|
|
end
|
|
|
|
def test_execute_no_prefix
|
|
@cmd.options[:args] = %w[foo]
|
|
@cmd.options[:prefix] = false
|
|
|
|
gem 'foo'
|
|
|
|
use_ui @ui do
|
|
@cmd.execute
|
|
end
|
|
|
|
expected = <<-EOF
|
|
Rakefile
|
|
lib/foo.rb
|
|
EOF
|
|
|
|
assert_equal expected, @ui.output
|
|
|
|
assert_equal "", @ui.error
|
|
end
|
|
|
|
def test_execute_default_gem
|
|
default_gem_spec = new_default_spec("default", "2.0.0.0",
|
|
nil, "default/gem.rb")
|
|
default_gem_spec.executables = ["default_command"]
|
|
default_gem_spec.files += ["default_gem.so"]
|
|
install_default_specs(default_gem_spec)
|
|
|
|
@cmd.options[:args] = %w[default]
|
|
|
|
use_ui @ui do
|
|
@cmd.execute
|
|
end
|
|
|
|
expected = [
|
|
File.join(RbConfig::CONFIG['bindir'], 'default_command'),
|
|
File.join(RbConfig::CONFIG['rubylibdir'], 'default/gem.rb'),
|
|
File.join(RbConfig::CONFIG['archdir'], 'default_gem.so')
|
|
].sort.join "\n"
|
|
|
|
assert_equal expected, @ui.output.chomp
|
|
assert_equal "", @ui.error
|
|
end
|
|
|
|
def test_handle_options
|
|
refute @cmd.options[:lib_only]
|
|
assert @cmd.options[:prefix]
|
|
assert_empty @cmd.options[:specdirs]
|
|
assert_nil @cmd.options[:version]
|
|
|
|
@cmd.send :handle_options, %w[-l -s foo --version 0.0.2 --no-prefix]
|
|
|
|
assert @cmd.options[:lib_only]
|
|
refute @cmd.options[:prefix]
|
|
assert_equal %w[foo], @cmd.options[:specdirs]
|
|
assert_equal Gem::Requirement.new('0.0.2'), @cmd.options[:version]
|
|
end
|
|
|
|
end
|
|
|