libgems 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +5811 -0
- data/History.txt +887 -0
- data/LICENSE.txt +51 -0
- data/README.md +87 -0
- data/Rakefile +113 -0
- data/lib/gauntlet_libgems.rb +50 -0
- data/lib/libgems.rb +1246 -0
- data/lib/libgems/builder.rb +102 -0
- data/lib/libgems/command.rb +534 -0
- data/lib/libgems/command_manager.rb +182 -0
- data/lib/libgems/commands/build_command.rb +53 -0
- data/lib/libgems/commands/cert_command.rb +86 -0
- data/lib/libgems/commands/check_command.rb +80 -0
- data/lib/libgems/commands/cleanup_command.rb +106 -0
- data/lib/libgems/commands/contents_command.rb +98 -0
- data/lib/libgems/commands/dependency_command.rb +195 -0
- data/lib/libgems/commands/environment_command.rb +133 -0
- data/lib/libgems/commands/fetch_command.rb +67 -0
- data/lib/libgems/commands/generate_index_command.rb +133 -0
- data/lib/libgems/commands/help_command.rb +172 -0
- data/lib/libgems/commands/install_command.rb +178 -0
- data/lib/libgems/commands/list_command.rb +35 -0
- data/lib/libgems/commands/lock_command.rb +110 -0
- data/lib/libgems/commands/mirror_command.rb +111 -0
- data/lib/libgems/commands/outdated_command.rb +33 -0
- data/lib/libgems/commands/owner_command.rb +75 -0
- data/lib/libgems/commands/pristine_command.rb +93 -0
- data/lib/libgems/commands/push_command.rb +56 -0
- data/lib/libgems/commands/query_command.rb +280 -0
- data/lib/libgems/commands/rdoc_command.rb +91 -0
- data/lib/libgems/commands/search_command.rb +31 -0
- data/lib/libgems/commands/server_command.rb +86 -0
- data/lib/libgems/commands/sources_command.rb +157 -0
- data/lib/libgems/commands/specification_command.rb +125 -0
- data/lib/libgems/commands/stale_command.rb +27 -0
- data/lib/libgems/commands/uninstall_command.rb +83 -0
- data/lib/libgems/commands/unpack_command.rb +121 -0
- data/lib/libgems/commands/update_command.rb +160 -0
- data/lib/libgems/commands/which_command.rb +86 -0
- data/lib/libgems/config_file.rb +345 -0
- data/lib/libgems/custom_require.rb +44 -0
- data/lib/libgems/defaults.rb +101 -0
- data/lib/libgems/dependency.rb +227 -0
- data/lib/libgems/dependency_installer.rb +286 -0
- data/lib/libgems/dependency_list.rb +208 -0
- data/lib/libgems/doc_manager.rb +242 -0
- data/lib/libgems/errors.rb +35 -0
- data/lib/libgems/exceptions.rb +91 -0
- data/lib/libgems/ext.rb +18 -0
- data/lib/libgems/ext/builder.rb +56 -0
- data/lib/libgems/ext/configure_builder.rb +25 -0
- data/lib/libgems/ext/ext_conf_builder.rb +24 -0
- data/lib/libgems/ext/rake_builder.rb +39 -0
- data/lib/libgems/format.rb +81 -0
- data/lib/libgems/gem_openssl.rb +92 -0
- data/lib/libgems/gem_path_searcher.rb +100 -0
- data/lib/libgems/gem_runner.rb +79 -0
- data/lib/libgems/gemcutter_utilities.rb +49 -0
- data/lib/libgems/indexer.rb +720 -0
- data/lib/libgems/install_update_options.rb +125 -0
- data/lib/libgems/installer.rb +604 -0
- data/lib/libgems/local_remote_options.rb +135 -0
- data/lib/libgems/old_format.rb +153 -0
- data/lib/libgems/package.rb +97 -0
- data/lib/libgems/package/f_sync_dir.rb +23 -0
- data/lib/libgems/package/tar_header.rb +266 -0
- data/lib/libgems/package/tar_input.rb +222 -0
- data/lib/libgems/package/tar_output.rb +144 -0
- data/lib/libgems/package/tar_reader.rb +106 -0
- data/lib/libgems/package/tar_reader/entry.rb +141 -0
- data/lib/libgems/package/tar_writer.rb +241 -0
- data/lib/libgems/package_task.rb +126 -0
- data/lib/libgems/platform.rb +183 -0
- data/lib/libgems/remote_fetcher.rb +414 -0
- data/lib/libgems/require_paths_builder.rb +18 -0
- data/lib/libgems/requirement.rb +153 -0
- data/lib/libgems/security.rb +814 -0
- data/lib/libgems/server.rb +872 -0
- data/lib/libgems/source_index.rb +597 -0
- data/lib/libgems/source_info_cache.rb +395 -0
- data/lib/libgems/source_info_cache_entry.rb +56 -0
- data/lib/libgems/spec_fetcher.rb +337 -0
- data/lib/libgems/specification.rb +1487 -0
- data/lib/libgems/test_utilities.rb +147 -0
- data/lib/libgems/text.rb +65 -0
- data/lib/libgems/uninstaller.rb +278 -0
- data/lib/libgems/user_interaction.rb +527 -0
- data/lib/libgems/validator.rb +240 -0
- data/lib/libgems/version.rb +316 -0
- data/lib/libgems/version_option.rb +65 -0
- data/lib/rbconfig/datadir.rb +20 -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/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/libgems_plugin.rb +2 -0
- data/test/plugin/load/libgems_plugin.rb +1 -0
- data/test/plugin/standarderror/libgems_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 +780 -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 +207 -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 +1334 -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 +402 -0
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
|
2
|
+
require 'libgems/commands/query_command'
|
|
3
|
+
|
|
4
|
+
class TestGemCommandsQueryCommand < RubyGemTestCase
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
super
|
|
8
|
+
|
|
9
|
+
@cmd = LibGems::Commands::QueryCommand.new
|
|
10
|
+
|
|
11
|
+
util_setup_fake_fetcher
|
|
12
|
+
|
|
13
|
+
@si = util_setup_spec_fetcher @a1, @a2, @pl1, @a3a
|
|
14
|
+
|
|
15
|
+
@fetcher.data["#{@gem_repo}Marshal.#{LibGems.marshal_version}"] = proc do
|
|
16
|
+
raise LibGems::RemoteFetcher::FetchError
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_execute
|
|
21
|
+
@cmd.handle_options %w[-r]
|
|
22
|
+
|
|
23
|
+
use_ui @ui do
|
|
24
|
+
@cmd.execute
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
expected = <<-EOF
|
|
28
|
+
|
|
29
|
+
*** REMOTE GEMS ***
|
|
30
|
+
|
|
31
|
+
a (2)
|
|
32
|
+
pl (1 i386-linux)
|
|
33
|
+
EOF
|
|
34
|
+
|
|
35
|
+
assert_equal expected, @ui.output
|
|
36
|
+
assert_equal '', @ui.error
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_execute_platform
|
|
40
|
+
@a1r = @a1.dup
|
|
41
|
+
|
|
42
|
+
@a1.platform = 'x86-linux'
|
|
43
|
+
@a2.platform = 'universal-darwin'
|
|
44
|
+
|
|
45
|
+
@si = util_setup_spec_fetcher @a1, @a1r, @a2, @b2, @pl1
|
|
46
|
+
|
|
47
|
+
@cmd.handle_options %w[-r -a]
|
|
48
|
+
|
|
49
|
+
use_ui @ui do
|
|
50
|
+
@cmd.execute
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
expected = <<-EOF
|
|
54
|
+
|
|
55
|
+
*** REMOTE GEMS ***
|
|
56
|
+
|
|
57
|
+
a (2 universal-darwin, 1 ruby x86-linux)
|
|
58
|
+
b (2)
|
|
59
|
+
pl (1 i386-linux)
|
|
60
|
+
EOF
|
|
61
|
+
|
|
62
|
+
assert_equal expected, @ui.output
|
|
63
|
+
assert_equal '', @ui.error
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_execute_all
|
|
67
|
+
a1_name = @a1.full_name
|
|
68
|
+
a2_name = @a2.full_name
|
|
69
|
+
|
|
70
|
+
@cmd.handle_options %w[-r --all]
|
|
71
|
+
|
|
72
|
+
use_ui @ui do
|
|
73
|
+
@cmd.execute
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
expected = <<-EOF
|
|
77
|
+
|
|
78
|
+
*** REMOTE GEMS ***
|
|
79
|
+
|
|
80
|
+
a (2, 1)
|
|
81
|
+
pl (1 i386-linux)
|
|
82
|
+
EOF
|
|
83
|
+
|
|
84
|
+
assert_equal expected, @ui.output
|
|
85
|
+
assert_equal '', @ui.error
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def test_execute_all_prerelease
|
|
89
|
+
a1_name = @a1.full_name
|
|
90
|
+
a2_name = @a2.full_name
|
|
91
|
+
|
|
92
|
+
@cmd.handle_options %w[-r --all --prerelease]
|
|
93
|
+
|
|
94
|
+
use_ui @ui do
|
|
95
|
+
@cmd.execute
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
expected = <<-EOF
|
|
99
|
+
|
|
100
|
+
*** REMOTE GEMS ***
|
|
101
|
+
|
|
102
|
+
a (3.a, 2, 1)
|
|
103
|
+
pl (1 i386-linux)
|
|
104
|
+
EOF
|
|
105
|
+
|
|
106
|
+
assert_equal expected, @ui.output
|
|
107
|
+
assert_equal '', @ui.error
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_execute_details
|
|
111
|
+
@a2.summary = 'This is a lot of text. ' * 4
|
|
112
|
+
@a2.authors = ['Abraham Lincoln', 'Hirohito']
|
|
113
|
+
@a2.homepage = 'http://a.example.com/'
|
|
114
|
+
@a2.rubyforge_project = 'rubygems'
|
|
115
|
+
|
|
116
|
+
@si = util_setup_spec_fetcher @a1, @a2, @pl1
|
|
117
|
+
|
|
118
|
+
@cmd.handle_options %w[-r -d]
|
|
119
|
+
|
|
120
|
+
use_ui @ui do
|
|
121
|
+
@cmd.execute
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
expected = <<-EOF
|
|
125
|
+
|
|
126
|
+
*** REMOTE GEMS ***
|
|
127
|
+
|
|
128
|
+
a (2)
|
|
129
|
+
Authors: Abraham Lincoln, Hirohito
|
|
130
|
+
Rubyforge: http://rubyforge.org/projects/rubygems
|
|
131
|
+
Homepage: http://a.example.com/
|
|
132
|
+
|
|
133
|
+
This is a lot of text. This is a lot of text. This is a lot of text.
|
|
134
|
+
This is a lot of text.
|
|
135
|
+
|
|
136
|
+
pl (1)
|
|
137
|
+
Platform: i386-linux
|
|
138
|
+
Author: A User
|
|
139
|
+
Homepage: http://example.com
|
|
140
|
+
|
|
141
|
+
this is a summary
|
|
142
|
+
EOF
|
|
143
|
+
|
|
144
|
+
assert_equal expected, @ui.output
|
|
145
|
+
assert_equal '', @ui.error
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def test_execute_details_platform
|
|
149
|
+
@a1.platform = 'x86-linux'
|
|
150
|
+
|
|
151
|
+
@a2.summary = 'This is a lot of text. ' * 4
|
|
152
|
+
@a2.authors = ['Abraham Lincoln', 'Hirohito']
|
|
153
|
+
@a2.homepage = 'http://a.example.com/'
|
|
154
|
+
@a2.rubyforge_project = 'rubygems'
|
|
155
|
+
@a2.platform = 'universal-darwin'
|
|
156
|
+
|
|
157
|
+
@si = util_setup_spec_fetcher @a1, @a2, @pl1
|
|
158
|
+
|
|
159
|
+
@cmd.handle_options %w[-r -d]
|
|
160
|
+
|
|
161
|
+
use_ui @ui do
|
|
162
|
+
@cmd.execute
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
expected = <<-EOF
|
|
166
|
+
|
|
167
|
+
*** REMOTE GEMS ***
|
|
168
|
+
|
|
169
|
+
a (2, 1)
|
|
170
|
+
Platforms:
|
|
171
|
+
1: x86-linux
|
|
172
|
+
2: universal-darwin
|
|
173
|
+
Authors: Abraham Lincoln, Hirohito
|
|
174
|
+
Rubyforge: http://rubyforge.org/projects/rubygems
|
|
175
|
+
Homepage: http://a.example.com/
|
|
176
|
+
|
|
177
|
+
This is a lot of text. This is a lot of text. This is a lot of text.
|
|
178
|
+
This is a lot of text.
|
|
179
|
+
|
|
180
|
+
pl (1)
|
|
181
|
+
Platform: i386-linux
|
|
182
|
+
Author: A User
|
|
183
|
+
Homepage: http://example.com
|
|
184
|
+
|
|
185
|
+
this is a summary
|
|
186
|
+
EOF
|
|
187
|
+
|
|
188
|
+
assert_equal expected, @ui.output
|
|
189
|
+
assert_equal '', @ui.error
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def test_execute_installed
|
|
193
|
+
@cmd.handle_options %w[-n c --installed]
|
|
194
|
+
|
|
195
|
+
e = assert_raises LibGems::SystemExitException do
|
|
196
|
+
use_ui @ui do
|
|
197
|
+
@cmd.execute
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
assert_equal 0, e.exit_code
|
|
202
|
+
|
|
203
|
+
assert_equal "true\n", @ui.output
|
|
204
|
+
|
|
205
|
+
assert_equal '', @ui.error
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def test_execute_installed_no_name
|
|
209
|
+
@cmd.handle_options %w[--installed]
|
|
210
|
+
|
|
211
|
+
e = assert_raises LibGems::SystemExitException do
|
|
212
|
+
use_ui @ui do
|
|
213
|
+
@cmd.execute
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
assert_equal '', @ui.output
|
|
218
|
+
assert_equal "ERROR: You must specify a gem name\n", @ui.error
|
|
219
|
+
|
|
220
|
+
assert_equal 4, e.exit_code
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def test_execute_installed_not_installed
|
|
224
|
+
@cmd.handle_options %w[-n not_installed --installed]
|
|
225
|
+
|
|
226
|
+
e = assert_raises LibGems::SystemExitException do
|
|
227
|
+
use_ui @ui do
|
|
228
|
+
@cmd.execute
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
assert_equal "false\n", @ui.output
|
|
233
|
+
assert_equal '', @ui.error
|
|
234
|
+
|
|
235
|
+
assert_equal 1, e.exit_code
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def test_execute_installed_version
|
|
239
|
+
@cmd.handle_options %w[-n c --installed --version 1.2]
|
|
240
|
+
|
|
241
|
+
e = assert_raises LibGems::SystemExitException do
|
|
242
|
+
use_ui @ui do
|
|
243
|
+
@cmd.execute
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
assert_equal "true\n", @ui.output
|
|
248
|
+
assert_equal '', @ui.error
|
|
249
|
+
|
|
250
|
+
assert_equal 0, e.exit_code
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def test_execute_installed_version_not_installed
|
|
254
|
+
@cmd.handle_options %w[-n c --installed --version 2]
|
|
255
|
+
|
|
256
|
+
e = assert_raises LibGems::SystemExitException do
|
|
257
|
+
use_ui @ui do
|
|
258
|
+
@cmd.execute
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
assert_equal "false\n", @ui.output
|
|
263
|
+
assert_equal '', @ui.error
|
|
264
|
+
|
|
265
|
+
assert_equal 1, e.exit_code
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def test_execute_local_details
|
|
269
|
+
@a3a.summary = 'This is a lot of text. ' * 4
|
|
270
|
+
@a3a.authors = ['Abraham Lincoln', 'Hirohito']
|
|
271
|
+
@a3a.homepage = 'http://a.example.com/'
|
|
272
|
+
@a3a.rubyforge_project = 'rubygems'
|
|
273
|
+
|
|
274
|
+
@cmd.handle_options %w[--local --details]
|
|
275
|
+
|
|
276
|
+
use_ui @ui do
|
|
277
|
+
@cmd.execute
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
expected = <<-EOF
|
|
281
|
+
|
|
282
|
+
*** LOCAL GEMS ***
|
|
283
|
+
|
|
284
|
+
a (3.a, 2, 1)
|
|
285
|
+
Author: A User
|
|
286
|
+
Homepage: http://example.com
|
|
287
|
+
Installed at (3.a): #{@gemhome}
|
|
288
|
+
(2): #{@gemhome}
|
|
289
|
+
(1): #{@gemhome}
|
|
290
|
+
|
|
291
|
+
this is a summary
|
|
292
|
+
|
|
293
|
+
a_evil (9)
|
|
294
|
+
Author: A User
|
|
295
|
+
Homepage: http://example.com
|
|
296
|
+
Installed at: #{@gemhome}
|
|
297
|
+
|
|
298
|
+
this is a summary
|
|
299
|
+
|
|
300
|
+
b (2)
|
|
301
|
+
Author: A User
|
|
302
|
+
Homepage: http://example.com
|
|
303
|
+
Installed at: #{@gemhome}
|
|
304
|
+
|
|
305
|
+
this is a summary
|
|
306
|
+
|
|
307
|
+
c (1.2)
|
|
308
|
+
Author: A User
|
|
309
|
+
Homepage: http://example.com
|
|
310
|
+
Installed at: #{@gemhome}
|
|
311
|
+
|
|
312
|
+
this is a summary
|
|
313
|
+
|
|
314
|
+
pl (1)
|
|
315
|
+
Platform: i386-linux
|
|
316
|
+
Author: A User
|
|
317
|
+
Homepage: http://example.com
|
|
318
|
+
Installed at: #{@gemhome}
|
|
319
|
+
|
|
320
|
+
this is a summary
|
|
321
|
+
EOF
|
|
322
|
+
|
|
323
|
+
assert_equal expected, @ui.output
|
|
324
|
+
assert_equal '', @ui.error
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
def test_execute_local_notty
|
|
328
|
+
@cmd.handle_options %w[]
|
|
329
|
+
|
|
330
|
+
@ui.outs.tty = false
|
|
331
|
+
|
|
332
|
+
use_ui @ui do
|
|
333
|
+
@cmd.execute
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
expected = <<-EOF
|
|
337
|
+
a (3.a, 2, 1)
|
|
338
|
+
a_evil (9)
|
|
339
|
+
b (2)
|
|
340
|
+
c (1.2)
|
|
341
|
+
pl (1 i386-linux)
|
|
342
|
+
EOF
|
|
343
|
+
|
|
344
|
+
assert_equal expected, @ui.output
|
|
345
|
+
assert_equal '', @ui.error
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
def test_execute_no_versions
|
|
349
|
+
@cmd.handle_options %w[-r --no-versions]
|
|
350
|
+
|
|
351
|
+
use_ui @ui do
|
|
352
|
+
@cmd.execute
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
expected = <<-EOF
|
|
356
|
+
|
|
357
|
+
*** REMOTE GEMS ***
|
|
358
|
+
|
|
359
|
+
a
|
|
360
|
+
pl
|
|
361
|
+
EOF
|
|
362
|
+
|
|
363
|
+
assert_equal expected, @ui.output
|
|
364
|
+
assert_equal '', @ui.error
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
def test_execute_notty
|
|
368
|
+
@cmd.handle_options %w[-r]
|
|
369
|
+
|
|
370
|
+
@ui.outs.tty = false
|
|
371
|
+
|
|
372
|
+
use_ui @ui do
|
|
373
|
+
@cmd.execute
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
expected = <<-EOF
|
|
377
|
+
a (2)
|
|
378
|
+
pl (1 i386-linux)
|
|
379
|
+
EOF
|
|
380
|
+
|
|
381
|
+
assert_equal expected, @ui.output
|
|
382
|
+
assert_equal '', @ui.error
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
def test_execute_prerelease
|
|
386
|
+
@cmd.handle_options %w[-r --prerelease]
|
|
387
|
+
|
|
388
|
+
use_ui @ui do
|
|
389
|
+
@cmd.execute
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
expected = <<-EOF
|
|
393
|
+
|
|
394
|
+
*** REMOTE GEMS ***
|
|
395
|
+
|
|
396
|
+
a (3.a)
|
|
397
|
+
EOF
|
|
398
|
+
|
|
399
|
+
assert_equal expected, @ui.output
|
|
400
|
+
assert_equal '', @ui.error
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
def test_execute_prerelease_local
|
|
404
|
+
@cmd.handle_options %w[-l --prerelease]
|
|
405
|
+
|
|
406
|
+
use_ui @ui do
|
|
407
|
+
@cmd.execute
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
expected = <<-EOF
|
|
411
|
+
|
|
412
|
+
*** LOCAL GEMS ***
|
|
413
|
+
|
|
414
|
+
a (3.a, 2, 1)
|
|
415
|
+
a_evil (9)
|
|
416
|
+
b (2)
|
|
417
|
+
c (1.2)
|
|
418
|
+
pl (1 i386-linux)
|
|
419
|
+
EOF
|
|
420
|
+
|
|
421
|
+
assert_equal expected, @ui.output
|
|
422
|
+
assert_equal "WARNING: prereleases are always shown locally\n", @ui.error
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
end
|
|
426
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
|
2
|
+
require 'libgems/commands/server_command'
|
|
3
|
+
|
|
4
|
+
class TestGemCommandsServerCommand < RubyGemTestCase
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
super
|
|
8
|
+
|
|
9
|
+
@cmd = LibGems::Commands::ServerCommand.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_handle_options
|
|
13
|
+
@cmd.send :handle_options, %w[-p 8808 --no-daemon]
|
|
14
|
+
|
|
15
|
+
assert_equal false, @cmd.options[:daemon]
|
|
16
|
+
assert_equal [], @cmd.options[:gemdir]
|
|
17
|
+
assert_equal 8808, @cmd.options[:port]
|
|
18
|
+
|
|
19
|
+
@cmd.send :handle_options, %w[-p 9999 -d /nonexistent --daemon]
|
|
20
|
+
|
|
21
|
+
assert_equal true, @cmd.options[:daemon]
|
|
22
|
+
assert_equal [File.expand_path('/nonexistent')], @cmd.options[:gemdir]
|
|
23
|
+
assert_equal 9999, @cmd.options[:port]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_handle_options_gemdir
|
|
27
|
+
@cmd.send :handle_options, %w[--dir a --dir b]
|
|
28
|
+
|
|
29
|
+
assert_equal [File.expand_path('a'), File.expand_path('b')],
|
|
30
|
+
@cmd.options[:gemdir]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_handle_options_port
|
|
34
|
+
@cmd.send :handle_options, %w[-p 0]
|
|
35
|
+
assert_equal 0, @cmd.options[:port]
|
|
36
|
+
|
|
37
|
+
@cmd.send :handle_options, %w[-p 65535]
|
|
38
|
+
assert_equal 65535, @cmd.options[:port]
|
|
39
|
+
|
|
40
|
+
@cmd.send :handle_options, %w[-p http]
|
|
41
|
+
assert_equal 80, @cmd.options[:port]
|
|
42
|
+
|
|
43
|
+
e = assert_raises OptionParser::InvalidArgument do
|
|
44
|
+
@cmd.send :handle_options, %w[-p nonexistent]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
assert_equal 'invalid argument: -p nonexistent: no such named service',
|
|
48
|
+
e.message
|
|
49
|
+
|
|
50
|
+
e = assert_raises OptionParser::InvalidArgument do
|
|
51
|
+
@cmd.send :handle_options, %w[-p 65536]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
assert_equal 'invalid argument: -p 65536: not a port number',
|
|
55
|
+
e.message
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|