slimgems 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5811 -0
- data/History.txt +887 -0
- data/LICENSE.txt +51 -0
- data/README.md +87 -0
- data/Rakefile +120 -0
- data/bin/gem +25 -0
- data/bin/update_slimgems +35 -0
- data/bootstrap/Rakefile +4 -0
- data/hide_lib_for_update/note.txt +5 -0
- data/lib/gauntlet_rubygems.rb +50 -0
- data/lib/rbconfig/datadir.rb +20 -0
- data/lib/rubygems.rb +1220 -0
- data/lib/rubygems/builder.rb +102 -0
- data/lib/rubygems/command.rb +534 -0
- data/lib/rubygems/command_manager.rb +182 -0
- data/lib/rubygems/commands/build_command.rb +53 -0
- data/lib/rubygems/commands/cert_command.rb +86 -0
- data/lib/rubygems/commands/check_command.rb +80 -0
- data/lib/rubygems/commands/cleanup_command.rb +106 -0
- data/lib/rubygems/commands/contents_command.rb +98 -0
- data/lib/rubygems/commands/dependency_command.rb +195 -0
- data/lib/rubygems/commands/environment_command.rb +132 -0
- data/lib/rubygems/commands/fetch_command.rb +67 -0
- data/lib/rubygems/commands/generate_index_command.rb +133 -0
- data/lib/rubygems/commands/help_command.rb +172 -0
- data/lib/rubygems/commands/install_command.rb +178 -0
- data/lib/rubygems/commands/list_command.rb +35 -0
- data/lib/rubygems/commands/lock_command.rb +110 -0
- data/lib/rubygems/commands/mirror_command.rb +111 -0
- data/lib/rubygems/commands/outdated_command.rb +33 -0
- data/lib/rubygems/commands/owner_command.rb +75 -0
- data/lib/rubygems/commands/pristine_command.rb +93 -0
- data/lib/rubygems/commands/push_command.rb +56 -0
- data/lib/rubygems/commands/query_command.rb +280 -0
- data/lib/rubygems/commands/rdoc_command.rb +91 -0
- data/lib/rubygems/commands/search_command.rb +31 -0
- data/lib/rubygems/commands/server_command.rb +86 -0
- data/lib/rubygems/commands/setup_command.rb +387 -0
- data/lib/rubygems/commands/sources_command.rb +157 -0
- data/lib/rubygems/commands/specification_command.rb +125 -0
- data/lib/rubygems/commands/stale_command.rb +27 -0
- data/lib/rubygems/commands/uninstall_command.rb +83 -0
- data/lib/rubygems/commands/unpack_command.rb +121 -0
- data/lib/rubygems/commands/update_command.rb +212 -0
- data/lib/rubygems/commands/which_command.rb +86 -0
- data/lib/rubygems/config_file.rb +345 -0
- data/lib/rubygems/custom_require.rb +44 -0
- data/lib/rubygems/defaults.rb +101 -0
- data/lib/rubygems/dependency.rb +227 -0
- data/lib/rubygems/dependency_installer.rb +286 -0
- data/lib/rubygems/dependency_list.rb +208 -0
- data/lib/rubygems/doc_manager.rb +242 -0
- data/lib/rubygems/errors.rb +35 -0
- data/lib/rubygems/exceptions.rb +91 -0
- data/lib/rubygems/ext.rb +18 -0
- data/lib/rubygems/ext/builder.rb +56 -0
- data/lib/rubygems/ext/configure_builder.rb +25 -0
- data/lib/rubygems/ext/ext_conf_builder.rb +24 -0
- data/lib/rubygems/ext/rake_builder.rb +39 -0
- data/lib/rubygems/format.rb +81 -0
- data/lib/rubygems/gem_openssl.rb +92 -0
- data/lib/rubygems/gem_path_searcher.rb +100 -0
- data/lib/rubygems/gem_runner.rb +79 -0
- data/lib/rubygems/gemcutter_utilities.rb +49 -0
- data/lib/rubygems/indexer.rb +720 -0
- data/lib/rubygems/install_update_options.rb +125 -0
- data/lib/rubygems/installer.rb +604 -0
- data/lib/rubygems/local_remote_options.rb +135 -0
- data/lib/rubygems/old_format.rb +153 -0
- data/lib/rubygems/package.rb +97 -0
- data/lib/rubygems/package/f_sync_dir.rb +23 -0
- data/lib/rubygems/package/tar_header.rb +266 -0
- data/lib/rubygems/package/tar_input.rb +222 -0
- data/lib/rubygems/package/tar_output.rb +144 -0
- data/lib/rubygems/package/tar_reader.rb +106 -0
- data/lib/rubygems/package/tar_reader/entry.rb +141 -0
- data/lib/rubygems/package/tar_writer.rb +241 -0
- data/lib/rubygems/package_task.rb +126 -0
- data/lib/rubygems/platform.rb +183 -0
- data/lib/rubygems/remote_fetcher.rb +414 -0
- data/lib/rubygems/require_paths_builder.rb +18 -0
- data/lib/rubygems/requirement.rb +153 -0
- data/lib/rubygems/security.rb +814 -0
- data/lib/rubygems/server.rb +872 -0
- data/lib/rubygems/source_index.rb +597 -0
- data/lib/rubygems/source_info_cache.rb +395 -0
- data/lib/rubygems/source_info_cache_entry.rb +56 -0
- data/lib/rubygems/spec_fetcher.rb +337 -0
- data/lib/rubygems/specification.rb +1486 -0
- data/lib/rubygems/test_utilities.rb +147 -0
- data/lib/rubygems/text.rb +65 -0
- data/lib/rubygems/uninstaller.rb +278 -0
- data/lib/rubygems/user_interaction.rb +527 -0
- data/lib/rubygems/validator.rb +240 -0
- data/lib/rubygems/version.rb +316 -0
- data/lib/rubygems/version_option.rb +65 -0
- data/lib/ubygems.rb +10 -0
- data/setup.rb +42 -0
- data/test/bogussources.rb +8 -0
- data/test/data/gem-private_key.pem +27 -0
- data/test/data/gem-public_cert.pem +20 -0
- data/test/fake_certlib/openssl.rb +7 -0
- data/test/foo/discover.rb +0 -0
- data/test/functional.rb +92 -0
- data/test/gem_installer_test_case.rb +97 -0
- data/test/gem_package_tar_test_case.rb +132 -0
- data/test/gemutilities.rb +605 -0
- data/test/insure_session.rb +43 -0
- data/test/mockgemui.rb +56 -0
- data/test/plugin/exception/rubygems_plugin.rb +2 -0
- data/test/plugin/load/rubygems_plugin.rb +1 -0
- data/test/plugin/standarderror/rubygems_plugin.rb +2 -0
- data/test/private_key.pem +27 -0
- data/test/public_cert.pem +20 -0
- data/test/rubygems_plugin.rb +21 -0
- data/test/simple_gem.rb +66 -0
- data/test/test_config.rb +12 -0
- data/test/test_gem.rb +766 -0
- data/test/test_gem_builder.rb +27 -0
- data/test/test_gem_command.rb +178 -0
- data/test/test_gem_command_manager.rb +207 -0
- data/test/test_gem_commands_build_command.rb +74 -0
- data/test/test_gem_commands_cert_command.rb +124 -0
- data/test/test_gem_commands_check_command.rb +18 -0
- data/test/test_gem_commands_contents_command.rb +156 -0
- data/test/test_gem_commands_dependency_command.rb +216 -0
- data/test/test_gem_commands_environment_command.rb +144 -0
- data/test/test_gem_commands_fetch_command.rb +76 -0
- data/test/test_gem_commands_generate_index_command.rb +135 -0
- data/test/test_gem_commands_install_command.rb +315 -0
- data/test/test_gem_commands_list_command.rb +36 -0
- data/test/test_gem_commands_lock_command.rb +68 -0
- data/test/test_gem_commands_mirror_command.rb +60 -0
- data/test/test_gem_commands_outdated_command.rb +40 -0
- data/test/test_gem_commands_owner_command.rb +105 -0
- data/test/test_gem_commands_pristine_command.rb +108 -0
- data/test/test_gem_commands_push_command.rb +81 -0
- data/test/test_gem_commands_query_command.rb +426 -0
- data/test/test_gem_commands_server_command.rb +59 -0
- data/test/test_gem_commands_sources_command.rb +209 -0
- data/test/test_gem_commands_specification_command.rb +139 -0
- data/test/test_gem_commands_stale_command.rb +38 -0
- data/test/test_gem_commands_uninstall_command.rb +83 -0
- data/test/test_gem_commands_unpack_command.rb +199 -0
- data/test/test_gem_commands_update_command.rb +353 -0
- data/test/test_gem_commands_which_command.rb +66 -0
- data/test/test_gem_config_file.rb +287 -0
- data/test/test_gem_dependency.rb +149 -0
- data/test/test_gem_dependency_installer.rb +661 -0
- data/test/test_gem_dependency_list.rb +230 -0
- data/test/test_gem_doc_manager.rb +31 -0
- data/test/test_gem_ext_configure_builder.rb +84 -0
- data/test/test_gem_ext_ext_conf_builder.rb +173 -0
- data/test/test_gem_ext_rake_builder.rb +81 -0
- data/test/test_gem_format.rb +70 -0
- data/test/test_gem_gem_path_searcher.rb +78 -0
- data/test/test_gem_gem_runner.rb +45 -0
- data/test/test_gem_gemcutter_utilities.rb +103 -0
- data/test/test_gem_indexer.rb +673 -0
- data/test/test_gem_install_update_options.rb +68 -0
- data/test/test_gem_installer.rb +857 -0
- data/test/test_gem_local_remote_options.rb +97 -0
- data/test/test_gem_package_tar_header.rb +130 -0
- data/test/test_gem_package_tar_input.rb +112 -0
- data/test/test_gem_package_tar_output.rb +97 -0
- data/test/test_gem_package_tar_reader.rb +46 -0
- data/test/test_gem_package_tar_reader_entry.rb +109 -0
- data/test/test_gem_package_tar_writer.rb +144 -0
- data/test/test_gem_package_task.rb +59 -0
- data/test/test_gem_platform.rb +264 -0
- data/test/test_gem_remote_fetcher.rb +740 -0
- data/test/test_gem_requirement.rb +292 -0
- data/test/test_gem_server.rb +356 -0
- data/test/test_gem_silent_ui.rb +113 -0
- data/test/test_gem_source_index.rb +461 -0
- data/test/test_gem_spec_fetcher.rb +410 -0
- data/test/test_gem_specification.rb +1291 -0
- data/test/test_gem_stream_ui.rb +218 -0
- data/test/test_gem_text.rb +43 -0
- data/test/test_gem_uninstaller.rb +146 -0
- data/test/test_gem_validator.rb +63 -0
- data/test/test_gem_version.rb +181 -0
- data/test/test_gem_version_option.rb +89 -0
- data/test/test_kernel.rb +59 -0
- metadata +413 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'rubygems/builder'
|
3
|
+
|
4
|
+
class TestGemBuilder < RubyGemTestCase
|
5
|
+
|
6
|
+
def test_build
|
7
|
+
builder = Gem::Builder.new quick_gem('a')
|
8
|
+
|
9
|
+
use_ui @ui do
|
10
|
+
Dir.chdir @tempdir do
|
11
|
+
builder.build
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
assert_match %r|Successfully built RubyGem\n Name: a|, @ui.output
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_build_validates
|
19
|
+
builder = Gem::Builder.new Gem::Specification.new
|
20
|
+
|
21
|
+
assert_raises Gem::InvalidSpecificationException do
|
22
|
+
builder.build
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'rubygems/command'
|
3
|
+
|
4
|
+
class Gem::Command
|
5
|
+
public :parser
|
6
|
+
end
|
7
|
+
|
8
|
+
class TestGemCommand < RubyGemTestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
super
|
12
|
+
|
13
|
+
@xopt = nil
|
14
|
+
|
15
|
+
Gem::Command.common_options.clear
|
16
|
+
Gem::Command.common_options << [
|
17
|
+
['-x', '--exe', 'Execute'], lambda do |*a|
|
18
|
+
@xopt = true
|
19
|
+
end
|
20
|
+
]
|
21
|
+
|
22
|
+
@cmd_name = 'doit'
|
23
|
+
@cmd = Gem::Command.new @cmd_name, 'summary'
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_self_add_specific_extra_args
|
27
|
+
added_args = %w[--all]
|
28
|
+
@cmd.add_option '--all' do |v,o| end
|
29
|
+
|
30
|
+
Gem::Command.add_specific_extra_args @cmd_name, added_args
|
31
|
+
|
32
|
+
assert_equal added_args, Gem::Command.specific_extra_args(@cmd_name)
|
33
|
+
|
34
|
+
h = @cmd.add_extra_args []
|
35
|
+
|
36
|
+
assert_equal added_args, h
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_self_add_specific_extra_args_unknown
|
40
|
+
added_args = %w[--definitely_not_there]
|
41
|
+
|
42
|
+
Gem::Command.add_specific_extra_args @cmd_name, added_args
|
43
|
+
|
44
|
+
assert_equal added_args, Gem::Command.specific_extra_args(@cmd_name)
|
45
|
+
|
46
|
+
h = @cmd.add_extra_args []
|
47
|
+
|
48
|
+
assert_equal [], h
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_basic_accessors
|
52
|
+
assert_equal "doit", @cmd.command
|
53
|
+
assert_equal "gem doit", @cmd.program_name
|
54
|
+
assert_equal "summary", @cmd.summary
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_common_option_in_class
|
58
|
+
assert Array === Gem::Command.common_options
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_defaults
|
62
|
+
@cmd.add_option('-h', '--help [COMMAND]', 'Get help on COMMAND') do |value, options|
|
63
|
+
options[:help] = value
|
64
|
+
end
|
65
|
+
|
66
|
+
@cmd.defaults = { :help => true }
|
67
|
+
|
68
|
+
@cmd.when_invoked do |options|
|
69
|
+
assert options[:help], "Help options should default true"
|
70
|
+
end
|
71
|
+
|
72
|
+
use_ui @ui do
|
73
|
+
@cmd.invoke
|
74
|
+
end
|
75
|
+
|
76
|
+
assert_match %r|Usage: gem doit|, @ui.output
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_invoke
|
80
|
+
done = false
|
81
|
+
@cmd.when_invoked { done = true }
|
82
|
+
|
83
|
+
use_ui @ui do
|
84
|
+
@cmd.invoke
|
85
|
+
end
|
86
|
+
|
87
|
+
assert done
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_invode_with_bad_options
|
91
|
+
use_ui @ui do
|
92
|
+
@cmd.when_invoked do true end
|
93
|
+
|
94
|
+
ex = assert_raises OptionParser::InvalidOption do
|
95
|
+
@cmd.invoke('-zzz')
|
96
|
+
end
|
97
|
+
|
98
|
+
assert_match(/invalid option:/, ex.message)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_invoke_with_common_options
|
103
|
+
@cmd.when_invoked do true end
|
104
|
+
|
105
|
+
use_ui @ui do
|
106
|
+
@cmd.invoke "-x"
|
107
|
+
end
|
108
|
+
|
109
|
+
assert @xopt, "Should have done xopt"
|
110
|
+
end
|
111
|
+
|
112
|
+
# Returning false from the command handler invokes the usage output.
|
113
|
+
def test_invoke_with_help
|
114
|
+
done = false
|
115
|
+
|
116
|
+
use_ui @ui do
|
117
|
+
@cmd.add_option('-h', '--help [COMMAND]', 'Get help on COMMAND') do |value, options|
|
118
|
+
options[:help] = true
|
119
|
+
done = true
|
120
|
+
end
|
121
|
+
|
122
|
+
@cmd.invoke('--help')
|
123
|
+
|
124
|
+
assert done
|
125
|
+
end
|
126
|
+
|
127
|
+
assert_match(/Usage/, @ui.output)
|
128
|
+
assert_match(/gem doit/, @ui.output)
|
129
|
+
assert_match(/\[options\]/, @ui.output)
|
130
|
+
assert_match(/-h/, @ui.output)
|
131
|
+
assert_match(/--help \[COMMAND\]/, @ui.output)
|
132
|
+
assert_match(/Get help on COMMAND/, @ui.output)
|
133
|
+
assert_match(/-x/, @ui.output)
|
134
|
+
assert_match(/--exe/, @ui.output)
|
135
|
+
assert_match(/Execute/, @ui.output)
|
136
|
+
assert_match(/Common Options:/, @ui.output)
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_invoke_with_options
|
140
|
+
@cmd.add_option('-h', '--help [COMMAND]', 'Get help on COMMAND') do |value, options|
|
141
|
+
options[:help] = true
|
142
|
+
end
|
143
|
+
|
144
|
+
@cmd.when_invoked do |opts|
|
145
|
+
assert opts[:help]
|
146
|
+
end
|
147
|
+
|
148
|
+
use_ui @ui do
|
149
|
+
@cmd.invoke '-h'
|
150
|
+
end
|
151
|
+
|
152
|
+
assert_match %r|Usage: gem doit|, @ui.output
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_option_recognition
|
156
|
+
@cmd.add_option('-h', '--help [COMMAND]', 'Get help on COMMAND') do |value, options|
|
157
|
+
options[:help] = true
|
158
|
+
end
|
159
|
+
@cmd.add_option('-f', '--file FILE', 'File option') do |value, options|
|
160
|
+
options[:help] = true
|
161
|
+
end
|
162
|
+
assert @cmd.handles?(['-x'])
|
163
|
+
assert @cmd.handles?(['-h'])
|
164
|
+
assert @cmd.handles?(['-h', 'command'])
|
165
|
+
assert @cmd.handles?(['--help', 'command'])
|
166
|
+
assert @cmd.handles?(['-f', 'filename'])
|
167
|
+
assert @cmd.handles?(['--file=filename'])
|
168
|
+
refute @cmd.handles?(['-z'])
|
169
|
+
refute @cmd.handles?(['-f'])
|
170
|
+
refute @cmd.handles?(['--toothpaste'])
|
171
|
+
|
172
|
+
args = ['-h', 'command']
|
173
|
+
@cmd.handles?(args)
|
174
|
+
assert_equal ['-h', 'command'], args
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
|
@@ -0,0 +1,207 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'rubygems/command_manager'
|
3
|
+
|
4
|
+
class TestGemCommandManager < RubyGemTestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
@command_manager = Gem::CommandManager.instance
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_run_interrupt
|
13
|
+
Gem.load_plugins
|
14
|
+
|
15
|
+
use_ui @ui do
|
16
|
+
assert_raises MockGemUi::TermError do
|
17
|
+
@command_manager.run 'interrupt'
|
18
|
+
end
|
19
|
+
assert_equal '', ui.output
|
20
|
+
assert_match "Unknown command", ui.error
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_run_crash_command
|
25
|
+
@command_manager.register_command :crash
|
26
|
+
use_ui @ui do
|
27
|
+
assert_raises MockGemUi::TermError do
|
28
|
+
@command_manager.run 'crash'
|
29
|
+
end
|
30
|
+
assert_equal '', ui.output
|
31
|
+
err = ui.error.split("\n").first
|
32
|
+
assert_match "ERROR: Loading command: crash", err
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_process_args_bad_arg
|
37
|
+
use_ui @ui do
|
38
|
+
assert_raises(MockGemUi::TermError) {
|
39
|
+
@command_manager.process_args("--bad-arg")
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
assert_match(/invalid option: --bad-arg/i, @ui.error)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_process_args_install
|
47
|
+
#capture all install options
|
48
|
+
use_ui @ui do
|
49
|
+
check_options = nil
|
50
|
+
@command_manager['install'].when_invoked do |options|
|
51
|
+
check_options = options
|
52
|
+
true
|
53
|
+
end
|
54
|
+
|
55
|
+
#check defaults
|
56
|
+
@command_manager.process_args("install")
|
57
|
+
assert_equal false, check_options[:test]
|
58
|
+
assert_equal true, check_options[:generate_rdoc]
|
59
|
+
assert_equal false, check_options[:force]
|
60
|
+
assert_equal :both, check_options[:domain]
|
61
|
+
assert_equal true, check_options[:wrappers]
|
62
|
+
assert_equal Gem::Requirement.default, check_options[:version]
|
63
|
+
assert_equal nil, check_options[:install_dir]
|
64
|
+
assert_equal nil, check_options[:bin_dir]
|
65
|
+
|
66
|
+
#check settings
|
67
|
+
check_options = nil
|
68
|
+
@command_manager.process_args(
|
69
|
+
"install --force --test --local --rdoc --install-dir . --version 3.0 --no-wrapper --bindir . ")
|
70
|
+
assert_equal true, check_options[:test]
|
71
|
+
assert_equal true, check_options[:generate_rdoc]
|
72
|
+
assert_equal true, check_options[:force]
|
73
|
+
assert_equal :local, check_options[:domain]
|
74
|
+
assert_equal false, check_options[:wrappers]
|
75
|
+
assert_equal Gem::Requirement.new('3.0'), check_options[:version]
|
76
|
+
assert_equal Dir.pwd, check_options[:install_dir]
|
77
|
+
assert_equal Dir.pwd, check_options[:bin_dir]
|
78
|
+
|
79
|
+
#check remote domain
|
80
|
+
check_options = nil
|
81
|
+
@command_manager.process_args("install --remote")
|
82
|
+
assert_equal :remote, check_options[:domain]
|
83
|
+
|
84
|
+
#check both domain
|
85
|
+
check_options = nil
|
86
|
+
@command_manager.process_args("install --both")
|
87
|
+
assert_equal :both, check_options[:domain]
|
88
|
+
|
89
|
+
#check both domain
|
90
|
+
check_options = nil
|
91
|
+
@command_manager.process_args("install --both")
|
92
|
+
assert_equal :both, check_options[:domain]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_process_args_uninstall
|
97
|
+
#capture all uninstall options
|
98
|
+
check_options = nil
|
99
|
+
@command_manager['uninstall'].when_invoked do |options|
|
100
|
+
check_options = options
|
101
|
+
true
|
102
|
+
end
|
103
|
+
|
104
|
+
#check defaults
|
105
|
+
@command_manager.process_args("uninstall")
|
106
|
+
assert_equal Gem::Requirement.default, check_options[:version]
|
107
|
+
|
108
|
+
#check settings
|
109
|
+
check_options = nil
|
110
|
+
@command_manager.process_args("uninstall foobar --version 3.0")
|
111
|
+
assert_equal "foobar", check_options[:args].first
|
112
|
+
assert_equal Gem::Requirement.new('3.0'), check_options[:version]
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_process_args_check
|
116
|
+
#capture all check options
|
117
|
+
check_options = nil
|
118
|
+
@command_manager['check'].when_invoked do |options|
|
119
|
+
check_options = options
|
120
|
+
true
|
121
|
+
end
|
122
|
+
|
123
|
+
#check defaults
|
124
|
+
@command_manager.process_args("check")
|
125
|
+
assert_equal false, check_options[:verify]
|
126
|
+
assert_equal false, check_options[:alien]
|
127
|
+
|
128
|
+
#check settings
|
129
|
+
check_options = nil
|
130
|
+
@command_manager.process_args("check --verify foobar --alien")
|
131
|
+
assert_equal "foobar", check_options[:verify]
|
132
|
+
assert_equal true, check_options[:alien]
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_process_args_build
|
136
|
+
#capture all build options
|
137
|
+
check_options = nil
|
138
|
+
@command_manager['build'].when_invoked do |options|
|
139
|
+
check_options = options
|
140
|
+
true
|
141
|
+
end
|
142
|
+
|
143
|
+
#check defaults
|
144
|
+
@command_manager.process_args("build")
|
145
|
+
#NOTE: Currently no defaults
|
146
|
+
|
147
|
+
#check settings
|
148
|
+
check_options = nil
|
149
|
+
@command_manager.process_args("build foobar.rb")
|
150
|
+
assert_equal 'foobar.rb', check_options[:args].first
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_process_args_query
|
154
|
+
#capture all query options
|
155
|
+
check_options = nil
|
156
|
+
@command_manager['query'].when_invoked do |options|
|
157
|
+
check_options = options
|
158
|
+
true
|
159
|
+
end
|
160
|
+
|
161
|
+
#check defaults
|
162
|
+
@command_manager.process_args("query")
|
163
|
+
assert_equal(//, check_options[:name])
|
164
|
+
assert_equal :local, check_options[:domain]
|
165
|
+
assert_equal false, check_options[:details]
|
166
|
+
|
167
|
+
#check settings
|
168
|
+
check_options = nil
|
169
|
+
@command_manager.process_args("query --name foobar --local --details")
|
170
|
+
assert_equal(/foobar/i, check_options[:name])
|
171
|
+
assert_equal :local, check_options[:domain]
|
172
|
+
assert_equal true, check_options[:details]
|
173
|
+
|
174
|
+
#remote domain
|
175
|
+
check_options = nil
|
176
|
+
@command_manager.process_args("query --remote")
|
177
|
+
assert_equal :remote, check_options[:domain]
|
178
|
+
|
179
|
+
#both (local/remote) domains
|
180
|
+
check_options = nil
|
181
|
+
@command_manager.process_args("query --both")
|
182
|
+
assert_equal :both, check_options[:domain]
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_process_args_update
|
186
|
+
#capture all update options
|
187
|
+
check_options = nil
|
188
|
+
@command_manager['update'].when_invoked do |options|
|
189
|
+
check_options = options
|
190
|
+
true
|
191
|
+
end
|
192
|
+
|
193
|
+
#check defaults
|
194
|
+
@command_manager.process_args("update")
|
195
|
+
assert_equal true, check_options[:generate_rdoc]
|
196
|
+
|
197
|
+
#check settings
|
198
|
+
check_options = nil
|
199
|
+
@command_manager.process_args("update --force --test --rdoc --install-dir .")
|
200
|
+
assert_equal true, check_options[:test]
|
201
|
+
assert_equal true, check_options[:generate_rdoc]
|
202
|
+
assert_equal true, check_options[:force]
|
203
|
+
assert_equal Dir.pwd, check_options[:install_dir]
|
204
|
+
end
|
205
|
+
|
206
|
+
end
|
207
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'rubygems/commands/build_command'
|
3
|
+
require 'rubygems/format'
|
4
|
+
|
5
|
+
class TestGemCommandsBuildCommand < RubyGemTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@gem = quick_gem 'some_gem' do |s|
|
11
|
+
s.rubyforge_project = 'example'
|
12
|
+
end
|
13
|
+
|
14
|
+
@cmd = Gem::Commands::BuildCommand.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_execute
|
18
|
+
gemspec_file = File.join(@tempdir, @gem.spec_name)
|
19
|
+
|
20
|
+
File.open gemspec_file, 'w' do |gs|
|
21
|
+
gs.write @gem.to_ruby
|
22
|
+
end
|
23
|
+
|
24
|
+
util_test_build_gem @gem, gemspec_file
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_execute_yaml
|
28
|
+
gemspec_file = File.join(@tempdir, @gem.spec_name)
|
29
|
+
|
30
|
+
File.open gemspec_file, 'w' do |gs|
|
31
|
+
gs.write @gem.to_yaml
|
32
|
+
end
|
33
|
+
|
34
|
+
util_test_build_gem @gem, gemspec_file
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_execute_bad_gem
|
38
|
+
@cmd.options[:args] = %w[some_gem]
|
39
|
+
use_ui @ui do
|
40
|
+
@cmd.execute
|
41
|
+
end
|
42
|
+
|
43
|
+
assert_equal '', @ui.output
|
44
|
+
assert_equal "ERROR: Gemspec file not found: some_gem\n", @ui.error
|
45
|
+
end
|
46
|
+
|
47
|
+
def util_test_build_gem(gem, gemspec_file)
|
48
|
+
@cmd.options[:args] = [gemspec_file]
|
49
|
+
|
50
|
+
use_ui @ui do
|
51
|
+
Dir.chdir @tempdir do
|
52
|
+
@cmd.execute
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
output = @ui.output.split "\n"
|
57
|
+
assert_equal " Successfully built RubyGem", output.shift
|
58
|
+
assert_equal " Name: some_gem", output.shift
|
59
|
+
assert_equal " Version: 2", output.shift
|
60
|
+
assert_equal " File: some_gem-2.gem", output.shift
|
61
|
+
assert_equal [], output
|
62
|
+
assert_equal '', @ui.error
|
63
|
+
|
64
|
+
gem_file = File.join @tempdir, gem.file_name
|
65
|
+
assert File.exist?(gem_file)
|
66
|
+
|
67
|
+
spec = Gem::Format.from_file_by_path(gem_file).spec
|
68
|
+
|
69
|
+
assert_equal "some_gem", spec.name
|
70
|
+
assert_equal "this is a summary", spec.summary
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|