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,147 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/commands/sources_command'
|
4
|
+
|
5
|
+
class TestGemCommandsSourcesCommand < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@cmd = Gem::Commands::SourcesCommand.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_execute
|
14
|
+
util_setup_source_info_cache
|
15
|
+
@cmd.handle_options []
|
16
|
+
|
17
|
+
use_ui @ui do
|
18
|
+
@cmd.execute
|
19
|
+
end
|
20
|
+
|
21
|
+
expected = <<-EOF
|
22
|
+
*** CURRENT SOURCES ***
|
23
|
+
|
24
|
+
#{@gem_repo}
|
25
|
+
EOF
|
26
|
+
|
27
|
+
assert_equal expected, @ui.output
|
28
|
+
assert_equal '', @ui.error
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_execute_add
|
32
|
+
util_setup_fake_fetcher
|
33
|
+
|
34
|
+
@si = Gem::SourceIndex.new @gem1.full_name => @gem1.name
|
35
|
+
|
36
|
+
@fetcher.data["http://beta-gems.example.com/Marshal.#{@marshal_version}"] =
|
37
|
+
@si.dump
|
38
|
+
|
39
|
+
@cmd.handle_options %w[--add http://beta-gems.example.com]
|
40
|
+
|
41
|
+
util_setup_source_info_cache
|
42
|
+
|
43
|
+
use_ui @ui do
|
44
|
+
@cmd.execute
|
45
|
+
end
|
46
|
+
|
47
|
+
expected = <<-EOF
|
48
|
+
Bulk updating Gem source index for: http://beta-gems.example.com
|
49
|
+
http://beta-gems.example.com added to sources
|
50
|
+
EOF
|
51
|
+
|
52
|
+
assert_equal expected, @ui.output
|
53
|
+
assert_equal '', @ui.error
|
54
|
+
|
55
|
+
Gem::SourceInfoCache.cache.flush
|
56
|
+
assert_equal %W[http://beta-gems.example.com #{@gem_repo}],
|
57
|
+
Gem::SourceInfoCache.cache_data.keys.sort
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_execute_add_nonexistent_source
|
61
|
+
util_setup_fake_fetcher
|
62
|
+
|
63
|
+
@si = Gem::SourceIndex.new @gem1.full_name => @gem1.name
|
64
|
+
|
65
|
+
@fetcher.data["http://beta-gems.example.com/Marshal.#{@marshal_version}"] =
|
66
|
+
proc do
|
67
|
+
raise Gem::RemoteFetcher::FetchError, 'it died'
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
Gem::RemoteFetcher.instance_variable_set :@fetcher, @fetcher
|
72
|
+
|
73
|
+
@cmd.handle_options %w[--add http://beta-gems.example.com]
|
74
|
+
|
75
|
+
util_setup_source_info_cache
|
76
|
+
|
77
|
+
use_ui @ui do
|
78
|
+
@cmd.execute
|
79
|
+
end
|
80
|
+
|
81
|
+
expected = <<-EOF
|
82
|
+
Error fetching http://beta-gems.example.com:
|
83
|
+
\tit died
|
84
|
+
EOF
|
85
|
+
|
86
|
+
assert_equal expected, @ui.output
|
87
|
+
assert_equal '', @ui.error
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_execute_add_bad_uri
|
91
|
+
@cmd.handle_options %w[--add beta-gems.example.com]
|
92
|
+
|
93
|
+
util_setup_source_info_cache
|
94
|
+
|
95
|
+
use_ui @ui do
|
96
|
+
@cmd.execute
|
97
|
+
end
|
98
|
+
|
99
|
+
expected = <<-EOF
|
100
|
+
beta-gems.example.com is not a URI
|
101
|
+
EOF
|
102
|
+
|
103
|
+
assert_equal expected, @ui.output
|
104
|
+
assert_equal '', @ui.error
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_execute_remove
|
108
|
+
@cmd.handle_options %W[--remove #{@gem_repo}]
|
109
|
+
|
110
|
+
util_setup_source_info_cache
|
111
|
+
|
112
|
+
use_ui @ui do
|
113
|
+
@cmd.execute
|
114
|
+
end
|
115
|
+
|
116
|
+
expected = "#{@gem_repo} removed from sources\n"
|
117
|
+
|
118
|
+
assert_equal expected, @ui.output
|
119
|
+
assert_equal '', @ui.error
|
120
|
+
|
121
|
+
Gem::SourceInfoCache.cache.flush
|
122
|
+
assert_equal [], Gem::SourceInfoCache.cache_data.keys
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_execute_update
|
126
|
+
@cmd.handle_options %w[--update]
|
127
|
+
|
128
|
+
util_setup_source_info_cache
|
129
|
+
util_setup_fake_fetcher
|
130
|
+
@si = Gem::SourceIndex.new @gem1.full_name => @gem1.name
|
131
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = @si.dump
|
132
|
+
|
133
|
+
use_ui @ui do
|
134
|
+
@cmd.execute
|
135
|
+
end
|
136
|
+
|
137
|
+
expected = <<-EOF
|
138
|
+
Bulk updating Gem source index for: #{@gem_repo}
|
139
|
+
source cache successfully updated
|
140
|
+
EOF
|
141
|
+
|
142
|
+
assert_equal expected, @ui.output
|
143
|
+
assert_equal '', @ui.error
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/commands/specification_command'
|
4
|
+
|
5
|
+
class TestGemCommandsSpecificationCommand < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@cmd = Gem::Commands::SpecificationCommand.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_execute
|
14
|
+
foo = quick_gem 'foo'
|
15
|
+
|
16
|
+
@cmd.options[:args] = %w[foo]
|
17
|
+
|
18
|
+
use_ui @ui do
|
19
|
+
@cmd.execute
|
20
|
+
end
|
21
|
+
|
22
|
+
assert_match %r|Gem::Specification|, @ui.output
|
23
|
+
assert_match %r|name: foo|, @ui.output
|
24
|
+
assert_equal '', @ui.error
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_execute_all
|
28
|
+
foo1 = quick_gem 'foo', '0.0.1'
|
29
|
+
foo2 = quick_gem 'foo', '0.0.2'
|
30
|
+
|
31
|
+
@cmd.options[:args] = %w[foo]
|
32
|
+
@cmd.options[:all] = true
|
33
|
+
|
34
|
+
use_ui @ui do
|
35
|
+
@cmd.execute
|
36
|
+
end
|
37
|
+
|
38
|
+
assert_match %r|Gem::Specification|, @ui.output
|
39
|
+
assert_match %r|name: foo|, @ui.output
|
40
|
+
assert_match %r|version: 0.0.1|, @ui.output
|
41
|
+
assert_match %r|version: 0.0.2|, @ui.output
|
42
|
+
assert_equal '', @ui.error
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_execute_bad_name
|
46
|
+
@cmd.options[:args] = %w[foo]
|
47
|
+
|
48
|
+
assert_raise MockGemUi::TermError do
|
49
|
+
use_ui @ui do
|
50
|
+
@cmd.execute
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
assert_equal '', @ui.output
|
55
|
+
assert_equal "ERROR: Unknown gem 'foo'\n", @ui.error
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_execute_exact_match
|
59
|
+
foo = quick_gem 'foo'
|
60
|
+
foo_bar = quick_gem 'foo_bar'
|
61
|
+
|
62
|
+
@cmd.options[:args] = %w[foo]
|
63
|
+
|
64
|
+
use_ui @ui do
|
65
|
+
@cmd.execute
|
66
|
+
end
|
67
|
+
|
68
|
+
assert_match %r|Gem::Specification|, @ui.output
|
69
|
+
assert_match %r|name: foo|, @ui.output
|
70
|
+
assert_equal '', @ui.error
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_execute_remote
|
74
|
+
foo = quick_gem 'foo'
|
75
|
+
|
76
|
+
util_setup_source_info_cache foo
|
77
|
+
|
78
|
+
FileUtils.rm File.join(@gemhome, 'specifications',
|
79
|
+
"#{foo.full_name}.gemspec")
|
80
|
+
|
81
|
+
@cmd.options[:args] = %w[foo]
|
82
|
+
@cmd.options[:domain] = :remote
|
83
|
+
|
84
|
+
use_ui @ui do
|
85
|
+
@cmd.execute
|
86
|
+
end
|
87
|
+
|
88
|
+
assert_equal "#{foo.to_yaml}\n", @ui.output
|
89
|
+
assert_equal "WARNING: Remote information is not complete\n\n", @ui.error
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/commands/unpack_command'
|
4
|
+
|
5
|
+
class TestGemCommandsUnpackCommand < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@cmd = Gem::Commands::UnpackCommand.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_execute
|
14
|
+
util_make_gems
|
15
|
+
|
16
|
+
@cmd.options[:args] = %w[a]
|
17
|
+
|
18
|
+
use_ui @ui do
|
19
|
+
Dir.chdir @tempdir do
|
20
|
+
@cmd.execute
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
assert File.exist?(File.join(@tempdir, 'a-0.0.2'))
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_execute_exact_match
|
28
|
+
foo_spec = quick_gem 'foo'
|
29
|
+
foo_bar_spec = quick_gem 'foo_bar'
|
30
|
+
|
31
|
+
use_ui @ui do
|
32
|
+
Dir.chdir @tempdir do
|
33
|
+
Gem::Builder.new(foo_spec).build
|
34
|
+
Gem::Builder.new(foo_bar_spec).build
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
foo_path = File.join(@tempdir, "#{foo_spec.full_name}.gem")
|
39
|
+
foo_bar_path = File.join(@tempdir, "#{foo_bar_spec.full_name}.gem")
|
40
|
+
Gem::Installer.new(foo_path).install
|
41
|
+
Gem::Installer.new(foo_bar_path).install
|
42
|
+
|
43
|
+
@cmd.options[:args] = %w[foo]
|
44
|
+
|
45
|
+
use_ui @ui do
|
46
|
+
Dir.chdir @tempdir do
|
47
|
+
@cmd.execute
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
assert File.exist?(File.join(@tempdir, foo_spec.full_name))
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,210 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#--
|
3
|
+
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
4
|
+
# All rights reserved.
|
5
|
+
# See LICENSE.txt for permissions.
|
6
|
+
#++
|
7
|
+
|
8
|
+
require 'test/unit'
|
9
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
10
|
+
require 'rubygems/config_file'
|
11
|
+
|
12
|
+
class TestGemConfigFile < RubyGemTestCase
|
13
|
+
|
14
|
+
def setup
|
15
|
+
super
|
16
|
+
|
17
|
+
@temp_conf = File.join @tempdir, '.gemrc'
|
18
|
+
|
19
|
+
@cfg_args = %W[--config-file #{@temp_conf}]
|
20
|
+
util_config_file
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_initialize
|
24
|
+
assert_equal @temp_conf, @cfg.config_file_name
|
25
|
+
|
26
|
+
assert_equal false, @cfg.backtrace
|
27
|
+
assert_equal true, @cfg.update_sources
|
28
|
+
assert_equal false, @cfg.benchmark
|
29
|
+
assert_equal Gem::ConfigFile::DEFAULT_BULK_THRESHOLD, @cfg.bulk_threshold
|
30
|
+
assert_equal true, @cfg.verbose
|
31
|
+
assert_equal %w[http://gems.example.com], Gem.sources
|
32
|
+
|
33
|
+
File.open @temp_conf, 'w' do |fp|
|
34
|
+
fp.puts ":backtrace: true"
|
35
|
+
fp.puts ":update_sources: false"
|
36
|
+
fp.puts ":benchmark: true"
|
37
|
+
fp.puts ":bulk_threshold: 10"
|
38
|
+
fp.puts ":verbose: false"
|
39
|
+
fp.puts ":sources:"
|
40
|
+
fp.puts " - http://more-gems.example.com"
|
41
|
+
fp.puts "install: --wrappers"
|
42
|
+
end
|
43
|
+
|
44
|
+
util_config_file
|
45
|
+
|
46
|
+
assert_equal true, @cfg.backtrace
|
47
|
+
assert_equal true, @cfg.benchmark
|
48
|
+
assert_equal 10, @cfg.bulk_threshold
|
49
|
+
assert_equal false, @cfg.verbose
|
50
|
+
assert_equal false, @cfg.update_sources
|
51
|
+
assert_equal %w[http://more-gems.example.com], Gem.sources
|
52
|
+
assert_equal '--wrappers', @cfg[:install]
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_initialize_handle_arguments_config_file
|
56
|
+
util_config_file %W[--config-file #{@temp_conf}]
|
57
|
+
|
58
|
+
assert_equal @temp_conf, @cfg.config_file_name
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_initialize_handle_arguments_config_file_equals
|
62
|
+
util_config_file %W[--config-file=#{@temp_conf}]
|
63
|
+
|
64
|
+
assert_equal @temp_conf, @cfg.config_file_name
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_handle_arguments
|
68
|
+
args = %w[--backtrace --bunch --of --args here]
|
69
|
+
|
70
|
+
@cfg.handle_arguments args
|
71
|
+
|
72
|
+
assert_equal %w[--bunch --of --args here], @cfg.args
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_handle_arguments_backtrace
|
76
|
+
assert_equal false, @cfg.backtrace
|
77
|
+
|
78
|
+
args = %w[--backtrace]
|
79
|
+
|
80
|
+
@cfg.handle_arguments args
|
81
|
+
|
82
|
+
assert_equal true, @cfg.backtrace
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_handle_arguments_benchmark
|
86
|
+
assert_equal false, @cfg.benchmark
|
87
|
+
|
88
|
+
args = %w[--benchmark]
|
89
|
+
|
90
|
+
@cfg.handle_arguments args
|
91
|
+
|
92
|
+
assert_equal true, @cfg.benchmark
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_handle_arguments_debug
|
96
|
+
old_dollar_DEBUG = $DEBUG
|
97
|
+
assert_equal false, $DEBUG
|
98
|
+
|
99
|
+
args = %w[--debug]
|
100
|
+
|
101
|
+
@cfg.handle_arguments args
|
102
|
+
|
103
|
+
assert_equal true, $DEBUG
|
104
|
+
ensure
|
105
|
+
$DEBUG = old_dollar_DEBUG
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_handle_arguments_override
|
109
|
+
File.open @temp_conf, 'w' do |fp|
|
110
|
+
fp.puts ":benchmark: false"
|
111
|
+
end
|
112
|
+
|
113
|
+
util_config_file %W[--benchmark --config-file=#{@temp_conf}]
|
114
|
+
|
115
|
+
assert_equal true, @cfg.benchmark
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_handle_arguments_traceback
|
119
|
+
assert_equal false, @cfg.backtrace
|
120
|
+
|
121
|
+
args = %w[--traceback]
|
122
|
+
|
123
|
+
@cfg.handle_arguments args
|
124
|
+
|
125
|
+
assert_equal true, @cfg.backtrace
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_really_verbose
|
129
|
+
assert_equal false, @cfg.really_verbose
|
130
|
+
|
131
|
+
@cfg.verbose = true
|
132
|
+
|
133
|
+
assert_equal false, @cfg.really_verbose
|
134
|
+
|
135
|
+
@cfg.verbose = 1
|
136
|
+
|
137
|
+
assert_equal true, @cfg.really_verbose
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_write
|
141
|
+
@cfg.backtrace = true
|
142
|
+
@cfg.benchmark = true
|
143
|
+
@cfg.update_sources = false
|
144
|
+
@cfg.bulk_threshold = 10
|
145
|
+
@cfg.verbose = false
|
146
|
+
Gem.sources.replace %w[http://more-gems.example.com]
|
147
|
+
@cfg[:install] = '--wrappers'
|
148
|
+
|
149
|
+
@cfg.write
|
150
|
+
|
151
|
+
util_config_file
|
152
|
+
|
153
|
+
# These should not be written out to the config file.
|
154
|
+
assert_equal false, @cfg.backtrace, 'backtrace'
|
155
|
+
assert_equal false, @cfg.benchmark, 'benchmark'
|
156
|
+
assert_equal Gem::ConfigFile::DEFAULT_BULK_THRESHOLD, @cfg.bulk_threshold,
|
157
|
+
'bulk_threshold'
|
158
|
+
assert_equal true, @cfg.update_sources, 'update_sources'
|
159
|
+
assert_equal true, @cfg.verbose, 'verbose'
|
160
|
+
|
161
|
+
assert_equal '--wrappers', @cfg[:install], 'install'
|
162
|
+
|
163
|
+
# this should be written out to the config file.
|
164
|
+
assert_equal %w[http://more-gems.example.com], Gem.sources
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_write_from_hash
|
168
|
+
File.open @temp_conf, 'w' do |fp|
|
169
|
+
fp.puts ":backtrace: true"
|
170
|
+
fp.puts ":benchmark: true"
|
171
|
+
fp.puts ":bulk_threshold: 10"
|
172
|
+
fp.puts ":update_sources: false"
|
173
|
+
fp.puts ":verbose: false"
|
174
|
+
fp.puts ":sources:"
|
175
|
+
fp.puts " - http://more-gems.example.com"
|
176
|
+
fp.puts "install: --wrappers"
|
177
|
+
end
|
178
|
+
|
179
|
+
util_config_file
|
180
|
+
|
181
|
+
@cfg.backtrace = :junk
|
182
|
+
@cfg.benchmark = :junk
|
183
|
+
@cfg.update_sources = :junk
|
184
|
+
@cfg.bulk_threshold = 20
|
185
|
+
@cfg.verbose = :junk
|
186
|
+
Gem.sources.replace %w[http://even-more-gems.example.com]
|
187
|
+
@cfg[:install] = '--wrappers --no-rdoc'
|
188
|
+
|
189
|
+
@cfg.write
|
190
|
+
|
191
|
+
util_config_file
|
192
|
+
|
193
|
+
# These should not be written out to the config file
|
194
|
+
assert_equal true, @cfg.backtrace, 'backtrace'
|
195
|
+
assert_equal true, @cfg.benchmark, 'benchmark'
|
196
|
+
assert_equal 10, @cfg.bulk_threshold, 'bulk_threshold'
|
197
|
+
assert_equal false, @cfg.update_sources, 'update_sources'
|
198
|
+
assert_equal false, @cfg.verbose, 'verbose'
|
199
|
+
|
200
|
+
assert_equal '--wrappers --no-rdoc', @cfg[:install], 'install'
|
201
|
+
|
202
|
+
assert_equal %w[http://even-more-gems.example.com], Gem.sources
|
203
|
+
end
|
204
|
+
|
205
|
+
def util_config_file(args = @cfg_args)
|
206
|
+
@cfg = Gem::ConfigFile.new args
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|