1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/rubygems/test_gem_commands_environment_command.rb

155 lines
3.8 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'rubygems/test_case'
require 'rubygems/commands/environment_command'
class TestGemCommandsEnvironmentCommand < Gem::TestCase
def setup
super
@cmd = Gem::Commands::EnvironmentCommand.new
end
def test_execute
orig_sources = Gem.sources.dup
orig_path, ENV['PATH'] = ENV['PATH'], %w[/usr/local/bin /usr/bin /bin].join(File::PATH_SEPARATOR)
Gem.sources.replace %w[http://gems.example.com]
Gem.configuration['gemcutter_key'] = 'blah'
@cmd.send :handle_options, %w[]
use_ui @ui do
@cmd.execute
end
assert_match %r|RUBYGEMS VERSION: (\d\.)+\d|, @ui.output
assert_match %r|RUBY VERSION: \d\.\d\.\d \(.*\) \[.*\]|, @ui.output
assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|,
@ui.output
assert_match %r|RUBYGEMS PREFIX: |, @ui.output
* ChangeLog: * 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
2014-01-06 20:19:28 -05:00
assert_match %r|RUBY EXECUTABLE:.*#{RbConfig::CONFIG['ruby_install_name']}|,
@ui.output
assert_match %r|SYSTEM CONFIGURATION DIRECTORY:|, @ui.output
assert_match %r|EXECUTABLE DIRECTORY:|, @ui.output
assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output
assert_match %r|- #{Gem::Platform.local}|, @ui.output
assert_match %r|GEM PATHS:|, @ui.output
assert_match %r|- #{Regexp.escape @gemhome}|, @ui.output
assert_match %r|GEM CONFIGURATION:|, @ui.output
assert_match %r|"gemcutter_key" => "\*\*\*\*"|, @ui.output
assert_match %r|:verbose => |, @ui.output
assert_match %r|REMOTE SOURCES:|, @ui.output
assert_match %r|- SHELL PATH:|, @ui.output
assert_match %r|- /usr/local/bin$|, @ui.output
assert_match %r|- /usr/bin$|, @ui.output
assert_match %r|- /bin$|, @ui.output
assert_empty @ui.error
ensure
Gem.sources.replace orig_sources
ENV['PATH'] = orig_path
end
def test_execute_gemdir
@cmd.send :handle_options, %w[gemdir]
use_ui @ui do
@cmd.execute
end
assert_equal "#{@gemhome}\n", @ui.output
assert_equal '', @ui.error
end
def test_execute_gempath
@cmd.send :handle_options, %w[gempath]
use_ui @ui do
@cmd.execute
end
assert_equal "#{@gemhome}\n", @ui.output
assert_equal '', @ui.error
end
def test_execute_gempath_multiple
Gem.clear_paths
path = [@gemhome, "#{@gemhome}2"].join File::PATH_SEPARATOR
ENV['GEM_PATH'] = path
@cmd.send :handle_options, %w[gempath]
use_ui @ui do
@cmd.execute
end
assert_equal "#{Gem.path.join File::PATH_SEPARATOR}\n", @ui.output
assert_equal '', @ui.error
end
def test_execute_packageversion
@cmd.send :handle_options, %w[packageversion]
use_ui @ui do
@cmd.execute
end
assert_equal "#{Gem::RubyGemsPackageVersion}\n", @ui.output
assert_equal '', @ui.error
end
def test_execute_remotesources
orig_sources = Gem.sources.dup
Gem.sources.replace %w[http://gems.example.com]
@cmd.send :handle_options, %w[remotesources]
use_ui @ui do
@cmd.execute
end
assert_equal "http://gems.example.com\n", @ui.output
assert_equal '', @ui.error
ensure
Gem.sources.replace orig_sources
end
def test_execute_unknown
@cmd.send :handle_options, %w[unknown]
assert_raises Gem::CommandLineError do
use_ui @ui do
@cmd.execute
end
end
assert_equal '', @ui.output
assert_equal '', @ui.error
end
def test_execute_version
@cmd.send :handle_options, %w[version]
use_ui @ui do
@cmd.execute
end
assert_equal "#{Gem::VERSION}\n", @ui.output
assert_equal '', @ui.error
end
def test_execute_platform
@cmd.send :handle_options, %w[platform]
use_ui @ui do
@cmd.execute
end
assert_equal "#{Gem.platforms.join File::PATH_SEPARATOR}\n", @ui.output
assert_equal '', @ui.error
end
end