rubygems-update 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data/ChangeLog +587 -0
- data/README +0 -1
- data/Rakefile +39 -12
- data/TODO +0 -5
- data/bin/gem +7 -7
- data/bin/update_rubygems +1 -1
- data/examples/application/an-app.gemspec +1 -1
- data/gemspecs/cgikit-1.1.0.gemspec +1 -2
- data/gemspecs/jabber4r.gemspec +1 -1
- data/gemspecs/linguistics.gemspec +1 -1
- data/gemspecs/ook.gemspec +1 -1
- data/gemspecs/progressbar.gemspec +1 -1
- data/gemspecs/redcloth.gemspec +1 -1
- data/gemspecs/rublog.gemspec +1 -1
- data/gemspecs/ruby-doom.gemspec +1 -1
- data/gemspecs/rubyjdwp.gemspec +1 -1
- data/gemspecs/statistics.gemspec +1 -1
- data/lib/rubygems.rb +167 -105
- data/lib/rubygems/builder.rb +12 -10
- data/lib/rubygems/command.rb +177 -60
- data/lib/rubygems/command_manager.rb +30 -38
- data/lib/rubygems/commands/build_command.rb +42 -46
- data/lib/rubygems/commands/cert_command.rb +72 -69
- data/lib/rubygems/commands/check_command.rb +63 -63
- data/lib/rubygems/commands/cleanup_command.rb +25 -7
- data/lib/rubygems/commands/contents_command.rb +70 -62
- data/lib/rubygems/commands/dependency_command.rb +131 -86
- data/lib/rubygems/commands/environment_command.rb +67 -46
- data/lib/rubygems/commands/fetch_command.rb +62 -0
- data/lib/rubygems/commands/generate_index_command.rb +57 -0
- data/lib/rubygems/commands/help_command.rb +163 -73
- data/lib/rubygems/commands/install_command.rb +114 -128
- data/lib/rubygems/commands/list_command.rb +10 -8
- data/lib/rubygems/commands/lock_command.rb +101 -0
- data/lib/rubygems/commands/mirror_command.rb +105 -0
- data/lib/rubygems/commands/outdated_command.rb +24 -15
- data/lib/rubygems/commands/pristine_command.rb +118 -88
- data/lib/rubygems/commands/query_command.rb +109 -77
- data/lib/rubygems/commands/rdoc_command.rb +13 -10
- data/lib/rubygems/commands/search_command.rb +10 -8
- data/lib/rubygems/commands/server_command.rb +48 -0
- data/lib/rubygems/commands/sources_command.rb +104 -83
- data/lib/rubygems/commands/specification_command.rb +65 -51
- data/lib/rubygems/commands/uninstall_command.rb +17 -12
- data/lib/rubygems/commands/unpack_command.rb +68 -68
- data/lib/rubygems/commands/update_command.rb +72 -25
- data/lib/rubygems/commands/which_command.rb +86 -0
- data/lib/rubygems/config_file.rb +202 -78
- data/lib/rubygems/custom_require.rb +7 -88
- data/lib/rubygems/dependency.rb +65 -0
- data/lib/rubygems/dependency_installer.rb +232 -0
- data/lib/rubygems/dependency_list.rb +133 -105
- data/lib/rubygems/digest/md5.rb +4 -1
- data/lib/rubygems/digest/sha2.rb +1 -1
- data/lib/rubygems/doc_manager.rb +41 -19
- data/lib/rubygems/exceptions.rb +63 -0
- data/lib/rubygems/ext.rb +18 -0
- data/lib/rubygems/ext/builder.rb +56 -0
- data/lib/rubygems/ext/configure_builder.rb +24 -0
- data/lib/rubygems/ext/ext_conf_builder.rb +23 -0
- data/lib/rubygems/ext/rake_builder.rb +27 -0
- data/lib/rubygems/format.rb +16 -6
- data/lib/rubygems/gem_openssl.rb +43 -6
- data/lib/rubygems/gem_path_searcher.rb +84 -0
- data/lib/rubygems/gem_runner.rb +20 -5
- data/lib/rubygems/indexer.rb +163 -0
- data/lib/rubygems/indexer/abstract_index_builder.rb +80 -0
- data/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
- data/lib/rubygems/indexer/master_index_builder.rb +53 -0
- data/lib/rubygems/indexer/quick_index_builder.rb +48 -0
- data/lib/rubygems/install_update_options.rb +87 -0
- data/lib/rubygems/installer.rb +316 -562
- data/lib/rubygems/local_remote_options.rb +106 -0
- data/lib/rubygems/old_format.rb +5 -13
- data/lib/rubygems/open-uri.rb +2 -0
- data/lib/rubygems/package.rb +28 -32
- data/lib/rubygems/platform.rb +187 -0
- data/lib/rubygems/remote_fetcher.rb +46 -29
- data/lib/rubygems/remote_installer.rb +11 -18
- data/lib/rubygems/requirement.rb +157 -0
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +715 -457
- data/lib/rubygems/server.rb +77 -59
- data/lib/rubygems/source_index.rb +154 -83
- data/lib/rubygems/source_info_cache.rb +73 -30
- data/lib/rubygems/source_info_cache_entry.rb +12 -3
- data/lib/rubygems/specification.rb +378 -145
- data/lib/rubygems/uninstaller.rb +183 -0
- data/lib/rubygems/user_interaction.rb +38 -9
- data/lib/rubygems/validator.rb +53 -24
- data/lib/rubygems/version.rb +126 -289
- data/lib/rubygems/version_option.rb +49 -0
- data/pkgs/sources/lib/sources.rb +1 -4
- data/pkgs/sources/sources.gemspec +3 -3
- data/scripts/gemdoc.rb +0 -1
- data/setup.rb +166 -1505
- data/test/bogussources.rb +0 -1
- data/test/data/gem-private_key.pem +27 -0
- data/test/data/gem-public_cert.pem +20 -0
- data/test/functional.rb +3 -105
- data/test/gemutilities.rb +145 -24
- data/test/insure_session.rb +0 -1
- data/test/{test_datadir.rb → test_config.rb} +7 -13
- data/test/test_gem.rb +360 -9
- data/test/test_gem_builder.rb +34 -0
- data/test/{test_command.rb → test_gem_command.rb} +119 -62
- data/test/{test_parse_commands.rb → test_gem_command_manager.rb} +64 -40
- data/test/test_gem_commands_build_command.rb +75 -0
- data/test/test_gem_commands_cert_command.rb +122 -0
- data/test/test_gem_commands_check_command.rb +25 -0
- data/test/test_gem_commands_contents_command.rb +92 -0
- data/test/test_gem_commands_dependency_command.rb +108 -0
- data/test/test_gem_commands_environment_command.rb +117 -0
- data/test/test_gem_commands_fetch_command.rb +34 -0
- data/test/test_gem_commands_generate_index_command.rb +32 -0
- data/test/test_gem_commands_install_command.rb +160 -0
- data/test/test_gem_commands_mirror_command.rb +56 -0
- data/test/test_gem_commands_pristine_command.rb +100 -0
- data/test/test_gem_commands_query_command.rb +82 -0
- data/test/test_gem_commands_sources_command.rb +147 -0
- data/test/test_gem_commands_specification_command.rb +93 -0
- data/test/test_gem_commands_unpack_command.rb +55 -0
- data/test/test_gem_config_file.rb +210 -0
- data/test/test_gem_dependency.rb +89 -0
- data/test/test_gem_dependency_installer.rb +542 -0
- data/test/test_gem_dependency_list.rb +212 -0
- data/test/test_gem_doc_manager.rb +32 -0
- data/test/test_gem_ext_configure_builder.rb +13 -17
- data/test/test_gem_ext_ext_conf_builder.rb +9 -9
- data/test/test_gem_ext_rake_builder.rb +23 -11
- data/test/test_gem_format.rb +69 -0
- data/test/test_gem_gem_path_searcher.rb +57 -0
- data/test/test_gem_gem_runner.rb +35 -0
- data/test/test_gem_indexer.rb +119 -0
- data/test/test_gem_install_update_options.rb +40 -0
- data/test/test_gem_installer.rb +796 -0
- data/test/test_gem_local_remote_options.rb +84 -0
- data/test/test_gem_outdated_command.rb +11 -9
- data/test/test_gem_platform.rb +240 -0
- data/test/{test_remote_fetcher.rb → test_gem_remote_fetcher.rb} +124 -55
- data/test/{test_remote_installer.rb → test_gem_remote_installer.rb} +3 -4
- data/test/test_gem_requirement.rb +223 -0
- data/test/test_gem_server.rb +71 -0
- data/test/test_gem_source_index.rb +429 -0
- data/test/test_gem_source_info_cache.rb +79 -17
- data/test/test_gem_source_info_cache_entry.rb +11 -9
- data/test/test_gem_specification.rb +738 -0
- data/test/test_gem_stream_ui.rb +117 -0
- data/test/test_gem_validator.rb +70 -0
- data/test/test_gem_version.rb +191 -0
- data/test/test_gem_version_option.rb +77 -0
- data/test/{test_require_gem.rb → test_kernel.rb} +19 -12
- data/test/test_open_uri.rb +1 -2
- data/test/test_package.rb +45 -34
- metadata +116 -141
- data/Releases +0 -127
- data/bin/gem_mirror +0 -73
- data/bin/gem_server +0 -6
- data/bin/gemlock +0 -127
- data/bin/gemri +0 -24
- data/bin/gemwhich +0 -89
- data/bin/index_gem_repository.rb +0 -302
- data/lib/gemconfigure.rb +0 -24
- data/lib/rubygems/gem_commands.rb +0 -273
- data/pkgs/sources/sources-0.0.1.gem +0 -0
- data/post-install.rb +0 -121
- data/test/brokenbuildgem.rb +0 -35
- data/test/data/PostMessage-0.0.1.gem +0 -0
- data/test/data/a-0.0.1.gem +0 -0
- data/test/data/a-0.0.2.gem +0 -0
- data/test/data/b-0.0.2.gem +0 -0
- data/test/data/broken-1.0.0.gem +0 -0
- data/test/data/broken_build/broken-build.gemspec +0 -20
- data/test/data/broken_build/ext/extconf.rb +0 -3
- data/test/data/broken_build/ext/foo.c +0 -1
- data/test/data/c-1.2.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/c-1.2.gem +0 -0
- data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -1
- data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -1
- data/test/data/gemhome/specifications/a-0.0.1.gemspec +0 -8
- data/test/data/gemhome/specifications/a-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/b-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/c-1.2.gemspec +0 -8
- data/test/data/legacy/keyedlist-0.4.0.ruby +0 -11
- data/test/data/legacy/keyedlist-0.4.0.yaml +0 -16
- data/test/data/lib/code.rb +0 -1
- data/test/data/one/README.one +0 -1
- data/test/data/one/lib/one.rb +0 -9
- data/test/data/one/one-0.0.1.gem +0 -0
- data/test/data/one/one.gemspec +0 -17
- data/test/data/one/one.yaml +0 -40
- data/test/data/post_install.gemspec +0 -19
- data/test/functional_extension_gems.rb +0 -48
- data/test/functional_generate_yaml_index.rb +0 -104
- data/test/gemenvironment.rb +0 -59
- data/test/io_capture.rb +0 -33
- data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +0 -11
- data/test/mock/gems/specifications/sources-0.0.1.gemspec +0 -8
- data/test/onegem.rb +0 -35
- data/test/test_builder.rb +0 -34
- data/test/test_check_command.rb +0 -34
- data/test/test_configfile.rb +0 -42
- data/test/test_dependency_list.rb +0 -169
- data/test/test_file_list.rb +0 -101
- data/test/test_format.rb +0 -49
- data/test/test_gem_sources_command.rb +0 -135
- data/test/test_gemloadpaths.rb +0 -51
- data/test/test_gempaths.rb +0 -170
- data/test/test_installer.rb +0 -369
- data/test/test_loadmanager.rb +0 -48
- data/test/test_process_commands.rb +0 -52
- data/test/test_source_index.rb +0 -231
- data/test/test_specific_extras.rb +0 -46
- data/test/test_specification.rb +0 -565
- data/test/test_user_interaction.rb +0 -48
- data/test/test_validator.rb +0 -59
- data/test/test_version_comparison.rb +0 -321
- data/test/testgem.rc +0 -7
- data/test/user_capture.rb +0 -7
- data/test/yaml_data.rb +0 -63
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/commands/build_command'
|
4
|
+
require 'rubygems/format'
|
5
|
+
|
6
|
+
class TestGemCommandsBuildCommand < RubyGemTestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
|
11
|
+
@cmd = Gem::Commands::BuildCommand.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_execute
|
15
|
+
gem = quick_gem 'some_gem'
|
16
|
+
|
17
|
+
gemspec_file = File.join(@tempdir, "#{gem.full_name}.gemspec")
|
18
|
+
|
19
|
+
File.open gemspec_file, 'w' do |gs|
|
20
|
+
gs.write gem.to_ruby
|
21
|
+
end
|
22
|
+
|
23
|
+
util_test_build_gem gem, gemspec_file
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_execute_yaml
|
27
|
+
gem = quick_gem 'some_gem'
|
28
|
+
|
29
|
+
gemspec_file = File.join(@tempdir, "#{gem.full_name}.gemspec")
|
30
|
+
|
31
|
+
File.open gemspec_file, 'w' do |gs|
|
32
|
+
gs.write gem.to_yaml
|
33
|
+
end
|
34
|
+
|
35
|
+
util_test_build_gem gem, gemspec_file
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_execute_bad_gem
|
39
|
+
@cmd.options[:args] = %w[some_gem]
|
40
|
+
use_ui @ui do
|
41
|
+
@cmd.execute
|
42
|
+
end
|
43
|
+
|
44
|
+
assert_equal '', @ui.output
|
45
|
+
assert_equal "ERROR: Gemspec file not found: some_gem\n", @ui.error
|
46
|
+
end
|
47
|
+
|
48
|
+
def util_test_build_gem(gem, gemspec_file)
|
49
|
+
@cmd.options[:args] = [gemspec_file]
|
50
|
+
|
51
|
+
use_ui @ui do
|
52
|
+
Dir.chdir @tempdir do
|
53
|
+
@cmd.execute
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
output = @ui.output.split "\n"
|
58
|
+
assert_equal " Successfully built RubyGem", output.shift
|
59
|
+
assert_equal " Name: some_gem", output.shift
|
60
|
+
assert_equal " Version: 0.0.2", output.shift
|
61
|
+
assert_equal " File: some_gem-0.0.2.gem", output.shift
|
62
|
+
assert_equal [], output
|
63
|
+
assert_equal '', @ui.error
|
64
|
+
|
65
|
+
gem_file = File.join @tempdir, "#{gem.full_name}.gem"
|
66
|
+
assert File.exist?(gem_file)
|
67
|
+
|
68
|
+
spec = Gem::Format.from_file_by_path(gem_file).spec
|
69
|
+
|
70
|
+
assert_equal "some_gem", spec.name
|
71
|
+
assert_equal "this is a summary", spec.summary
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
|
4
|
+
require 'rubygems/commands/cert_command'
|
5
|
+
|
6
|
+
class TestGemCommandsCertCommand < RubyGemTestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
|
11
|
+
@orig_security_trust_dir = Gem::Security::OPT[:trust_dir]
|
12
|
+
Gem::Security::OPT[:trust_dir] = @tempdir
|
13
|
+
|
14
|
+
@cmd = Gem::Commands::CertCommand.new
|
15
|
+
|
16
|
+
root = File.expand_path(File.dirname(__FILE__))
|
17
|
+
|
18
|
+
FileUtils.cp File.join(root, 'data', 'gem-private_key.pem'), @tempdir
|
19
|
+
FileUtils.cp File.join(root, 'data', 'gem-public_cert.pem'), @tempdir
|
20
|
+
|
21
|
+
@cert_file_name = File.join @tempdir, 'gem-public_cert.pem'
|
22
|
+
@pkey_file_name = File.join @tempdir, 'gem-private_key.pem'
|
23
|
+
end
|
24
|
+
|
25
|
+
def teardown
|
26
|
+
Gem::Security::OPT[:trust_dir] = @orig_security_trust_dir
|
27
|
+
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_execute_add
|
32
|
+
use_ui @ui do
|
33
|
+
@cmd.send :handle_options, %W[--add #{@cert_file_name}]
|
34
|
+
end
|
35
|
+
|
36
|
+
assert_equal "Added '/CN=rubygems/DC=example/DC=com'\n", @ui.output
|
37
|
+
assert_equal '', @ui.error
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_execute_build
|
41
|
+
FileUtils.rm @cert_file_name
|
42
|
+
FileUtils.rm @pkey_file_name
|
43
|
+
|
44
|
+
use_ui @ui do
|
45
|
+
Dir.chdir @tempdir do
|
46
|
+
@cmd.send :handle_options, %W[--build nobody@example.com]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
output = @ui.output.split "\n"
|
51
|
+
|
52
|
+
assert_equal 'Public Cert: gem-public_cert.pem', output.shift
|
53
|
+
assert_equal 'Private Key: gem-private_key.pem', output.shift
|
54
|
+
assert_equal 'Don\'t forget to move the key file to somewhere private...',
|
55
|
+
output.shift
|
56
|
+
assert_equal [], output
|
57
|
+
|
58
|
+
assert_equal '', @ui.error
|
59
|
+
|
60
|
+
assert File.exist?(File.join(@tempdir, 'gem-private_key.pem'))
|
61
|
+
assert File.exist?(File.join(@tempdir, 'gem-public_cert.pem'))
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_execute_certificate
|
65
|
+
use_ui @ui do
|
66
|
+
@cmd.send :handle_options, %W[--certificate #{@cert_file_name}]
|
67
|
+
end
|
68
|
+
|
69
|
+
assert_equal '', @ui.output
|
70
|
+
assert_equal '', @ui.error
|
71
|
+
|
72
|
+
assert_equal File.read(@cert_file_name),
|
73
|
+
Gem::Security::OPT[:issuer_cert].to_s
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_execute_list
|
77
|
+
use_ui @ui do
|
78
|
+
@cmd.send :handle_options, %W[--list]
|
79
|
+
end
|
80
|
+
|
81
|
+
assert_equal "/CN=rubygems/DC=example/DC=com\n", @ui.output
|
82
|
+
assert_equal '', @ui.error
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_execute_private_key
|
86
|
+
use_ui @ui do
|
87
|
+
@cmd.send :handle_options, %W[--private-key #{@pkey_file_name}]
|
88
|
+
end
|
89
|
+
|
90
|
+
assert_equal '', @ui.output
|
91
|
+
assert_equal '', @ui.error
|
92
|
+
|
93
|
+
assert_equal File.read(@pkey_file_name),
|
94
|
+
Gem::Security::OPT[:issuer_key].to_s
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_execute_remove
|
98
|
+
use_ui @ui do
|
99
|
+
@cmd.send :handle_options, %W[--remove rubygems]
|
100
|
+
end
|
101
|
+
|
102
|
+
assert_equal "Removed '/CN=rubygems/DC=example/DC=com'\n", @ui.output
|
103
|
+
assert_equal '', @ui.error
|
104
|
+
|
105
|
+
assert !File.exist?(@cert_file_name)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_execute_sign
|
109
|
+
use_ui @ui do
|
110
|
+
@cmd.send :handle_options, %W[
|
111
|
+
-K #{@pkey_file_name} -C #{@cert_file_name} --sign #{@cert_file_name}
|
112
|
+
]
|
113
|
+
end
|
114
|
+
|
115
|
+
assert_equal '', @ui.output
|
116
|
+
assert_equal '', @ui.error
|
117
|
+
|
118
|
+
# HACK this test sucks
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#++
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
9
|
+
require 'rubygems/commands/check_command'
|
10
|
+
|
11
|
+
class TestGemCommandsCheckCommand < RubyGemTestCase
|
12
|
+
|
13
|
+
def setup
|
14
|
+
super
|
15
|
+
|
16
|
+
@cmd = Gem::Commands::CheckCommand.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_initialize
|
20
|
+
assert_equal "check", @cmd.command
|
21
|
+
assert_equal "gem check", @cmd.program_name
|
22
|
+
assert_match(/Check/, @cmd.summary)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/commands/contents_command'
|
4
|
+
|
5
|
+
class TestGemCommandsContentsCommand < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@cmd = Gem::Commands::ContentsCommand.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_execute
|
14
|
+
@cmd.options[:args] = %w[foo]
|
15
|
+
quick_gem 'foo' do |gem|
|
16
|
+
gem.files = %w[lib/foo.rb Rakefile]
|
17
|
+
end
|
18
|
+
|
19
|
+
use_ui @ui do
|
20
|
+
@cmd.execute
|
21
|
+
end
|
22
|
+
|
23
|
+
assert_match %r|lib/foo\.rb|, @ui.output
|
24
|
+
assert_match %r|Rakefile|, @ui.output
|
25
|
+
assert_equal "", @ui.error
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_execute_bad_gem
|
29
|
+
@cmd.options[:args] = %w[foo]
|
30
|
+
|
31
|
+
assert_raise MockGemUi::TermError do
|
32
|
+
use_ui @ui do
|
33
|
+
@cmd.execute
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
assert_match %r|Unable to find gem 'foo' in default gem paths|, @ui.output
|
38
|
+
assert_match %r|Directories searched:|, @ui.output
|
39
|
+
assert_equal "", @ui.error
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_execute_exact_match
|
43
|
+
@cmd.options[:args] = %w[foo]
|
44
|
+
quick_gem 'foo' do |gem|
|
45
|
+
gem.files = %w[lib/foo.rb Rakefile]
|
46
|
+
end
|
47
|
+
|
48
|
+
quick_gem 'foo_bar' do |gem|
|
49
|
+
gem.files = %w[lib/foo_bar.rb Rakefile]
|
50
|
+
end
|
51
|
+
|
52
|
+
use_ui @ui do
|
53
|
+
@cmd.execute
|
54
|
+
end
|
55
|
+
|
56
|
+
assert_match %r|lib/foo\.rb|, @ui.output
|
57
|
+
assert_match %r|Rakefile|, @ui.output
|
58
|
+
assert_equal "", @ui.error
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_execute_lib_only
|
62
|
+
@cmd.options[:args] = %w[foo]
|
63
|
+
@cmd.options[:lib_only] = true
|
64
|
+
|
65
|
+
quick_gem 'foo' do |gem|
|
66
|
+
gem.files = %w[lib/foo.rb Rakefile]
|
67
|
+
end
|
68
|
+
|
69
|
+
use_ui @ui do
|
70
|
+
@cmd.execute
|
71
|
+
end
|
72
|
+
|
73
|
+
assert_match %r|lib/foo\.rb|, @ui.output
|
74
|
+
assert_no_match %r|Rakefile|, @ui.output
|
75
|
+
|
76
|
+
assert_equal "", @ui.error
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_handle_options
|
80
|
+
assert_equal false, @cmd.options[:lib_only]
|
81
|
+
assert_equal [], @cmd.options[:specdirs]
|
82
|
+
assert_equal nil, @cmd.options[:version]
|
83
|
+
|
84
|
+
@cmd.send :handle_options, %w[-l -s foo --version 0.0.2]
|
85
|
+
|
86
|
+
assert_equal true, @cmd.options[:lib_only]
|
87
|
+
assert_equal %w[foo], @cmd.options[:specdirs]
|
88
|
+
assert_equal Gem::Requirement.new('0.0.2'), @cmd.options[:version]
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/commands/dependency_command'
|
4
|
+
|
5
|
+
class TestGemCommandsDependencyCommand < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@cmd = Gem::Commands::DependencyCommand.new
|
11
|
+
@cmd.options[:domain] = :local
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_execute
|
15
|
+
quick_gem 'foo' do |gem|
|
16
|
+
gem.add_dependency 'bar', '> 1.0.0'
|
17
|
+
end
|
18
|
+
|
19
|
+
@cmd.options[:args] = %w[foo]
|
20
|
+
|
21
|
+
use_ui @ui do
|
22
|
+
@cmd.execute
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_equal "Gem foo-0.0.2\n bar (> 1.0.0)\n\n", @ui.output
|
26
|
+
assert_equal '', @ui.error
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_execute_no_match
|
30
|
+
@cmd.options[:args] = %w[foo]
|
31
|
+
|
32
|
+
assert_raise MockGemUi::TermError do
|
33
|
+
use_ui @ui do
|
34
|
+
@cmd.execute
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
assert_equal "No match found for foo (>= 0)\n", @ui.output
|
39
|
+
assert_equal '', @ui.error
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_execute_pipe_format
|
43
|
+
quick_gem 'foo' do |gem|
|
44
|
+
gem.add_dependency 'bar', '> 1.0.0'
|
45
|
+
end
|
46
|
+
|
47
|
+
@cmd.options[:args] = %w[foo]
|
48
|
+
@cmd.options[:pipe_format] = true
|
49
|
+
|
50
|
+
use_ui @ui do
|
51
|
+
@cmd.execute
|
52
|
+
end
|
53
|
+
|
54
|
+
assert_equal "bar --version '> 1.0.0'\n", @ui.output
|
55
|
+
assert_equal '', @ui.error
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_execute_reverse
|
59
|
+
quick_gem 'foo' do |gem|
|
60
|
+
gem.add_dependency 'bar', '> 1.0.0'
|
61
|
+
end
|
62
|
+
|
63
|
+
quick_gem 'baz' do |gem|
|
64
|
+
gem.add_dependency 'foo'
|
65
|
+
end
|
66
|
+
|
67
|
+
@cmd.options[:args] = %w[foo]
|
68
|
+
@cmd.options[:reverse_dependencies] = true
|
69
|
+
|
70
|
+
use_ui @ui do
|
71
|
+
@cmd.execute
|
72
|
+
end
|
73
|
+
|
74
|
+
expected = <<-EOF
|
75
|
+
Gem foo-0.0.2
|
76
|
+
bar (> 1.0.0)
|
77
|
+
Used by
|
78
|
+
baz-0.0.2 (foo (>= 0))
|
79
|
+
|
80
|
+
EOF
|
81
|
+
|
82
|
+
assert_equal expected, @ui.output
|
83
|
+
assert_equal '', @ui.error
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_execute_remote
|
87
|
+
foo = quick_gem 'foo' do |gem|
|
88
|
+
gem.add_dependency 'bar', '> 1.0.0'
|
89
|
+
end
|
90
|
+
|
91
|
+
util_setup_source_info_cache foo
|
92
|
+
|
93
|
+
FileUtils.rm File.join(@gemhome, 'specifications',
|
94
|
+
"#{foo.full_name}.gemspec")
|
95
|
+
|
96
|
+
@cmd.options[:args] = %w[foo]
|
97
|
+
@cmd.options[:domain] = :remote
|
98
|
+
|
99
|
+
use_ui @ui do
|
100
|
+
@cmd.execute
|
101
|
+
end
|
102
|
+
|
103
|
+
assert_equal "Gem foo-0.0.2\n bar (> 1.0.0)\n\n", @ui.output
|
104
|
+
assert_equal '', @ui.error
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/commands/environment_command'
|
4
|
+
|
5
|
+
class TestGemCommandsEnvironmentCommand < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@cmd = Gem::Commands::EnvironmentCommand.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_execute
|
14
|
+
orig_sources = Gem.sources.dup
|
15
|
+
Gem.sources.replace %w[http://gems.example.com]
|
16
|
+
|
17
|
+
@cmd.send :handle_options, %w[]
|
18
|
+
|
19
|
+
use_ui @ui do
|
20
|
+
@cmd.execute
|
21
|
+
end
|
22
|
+
|
23
|
+
assert_match %r|RUBYGEMS VERSION: (\d\.)+\d \((\d\.)+\d\)|, @ui.output
|
24
|
+
assert_match %r|RUBY VERSION: \d\.\d\.\d \(.*\) \[.*\]|, @ui.output
|
25
|
+
assert_match %r|INSTALLATION DIRECTORY: #{Regexp.escape @gemhome}|,
|
26
|
+
@ui.output
|
27
|
+
assert_match %r|RUBYGEMS PREFIX: |, @ui.output
|
28
|
+
assert_match %r|RUBY EXECUTABLE:.*ruby|, @ui.output
|
29
|
+
assert_match %r|RUBYGEMS PLATFORMS:|, @ui.output
|
30
|
+
assert_match %r|- #{Gem::Platform.local}|, @ui.output
|
31
|
+
assert_match %r|GEM PATHS:|, @ui.output
|
32
|
+
assert_match %r|- #{Regexp.escape @gemhome}|, @ui.output
|
33
|
+
assert_match %r|GEM CONFIGURATION:|, @ui.output
|
34
|
+
assert_match %r|:verbose => |, @ui.output
|
35
|
+
assert_match %r|REMOTE SOURCES:|, @ui.output
|
36
|
+
assert_equal '', @ui.error
|
37
|
+
|
38
|
+
ensure
|
39
|
+
Gem.sources.replace orig_sources
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_execute_gemdir
|
43
|
+
@cmd.send :handle_options, %w[gemdir]
|
44
|
+
|
45
|
+
use_ui @ui do
|
46
|
+
@cmd.execute
|
47
|
+
end
|
48
|
+
|
49
|
+
assert_equal "#{@gemhome}\n", @ui.output
|
50
|
+
assert_equal '', @ui.error
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_execute_gempath
|
54
|
+
@cmd.send :handle_options, %w[gempath]
|
55
|
+
|
56
|
+
use_ui @ui do
|
57
|
+
@cmd.execute
|
58
|
+
end
|
59
|
+
|
60
|
+
assert_equal "#{@gemhome}\n", @ui.output
|
61
|
+
assert_equal '', @ui.error
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_execute_packageversion
|
65
|
+
@cmd.send :handle_options, %w[packageversion]
|
66
|
+
|
67
|
+
use_ui @ui do
|
68
|
+
@cmd.execute
|
69
|
+
end
|
70
|
+
|
71
|
+
assert_equal "#{Gem::RubyGemsPackageVersion}\n", @ui.output
|
72
|
+
assert_equal '', @ui.error
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_execute_remotesources
|
76
|
+
orig_sources = Gem.sources.dup
|
77
|
+
Gem.sources.replace %w[http://gems.example.com]
|
78
|
+
|
79
|
+
@cmd.send :handle_options, %w[remotesources]
|
80
|
+
|
81
|
+
use_ui @ui do
|
82
|
+
@cmd.execute
|
83
|
+
end
|
84
|
+
|
85
|
+
assert_equal "http://gems.example.com\n", @ui.output
|
86
|
+
assert_equal '', @ui.error
|
87
|
+
|
88
|
+
ensure
|
89
|
+
Gem.sources.replace orig_sources
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_execute_unknown
|
93
|
+
@cmd.send :handle_options, %w[unknown]
|
94
|
+
|
95
|
+
assert_raise Gem::CommandLineError do
|
96
|
+
use_ui @ui do
|
97
|
+
@cmd.execute
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
assert_equal '', @ui.output
|
102
|
+
assert_equal '', @ui.error
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_execute_version
|
106
|
+
@cmd.send :handle_options, %w[version]
|
107
|
+
|
108
|
+
use_ui @ui do
|
109
|
+
@cmd.execute
|
110
|
+
end
|
111
|
+
|
112
|
+
assert_equal "#{Gem::RubyGemsVersion}\n", @ui.output
|
113
|
+
assert_equal '', @ui.error
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|