rubygems-update 1.3.7 → 1.4.0
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.tar.gz.sig +0 -0
- data/.autotest +4 -1
- data/ChangeLog +23 -0
- data/History.txt +30 -1
- data/Manifest.txt +1 -1
- data/{README → README.rdoc} +4 -4
- data/Rakefile +7 -56
- data/lib/rbconfig/datadir.rb +6 -13
- data/lib/rubygems.rb +144 -89
- data/lib/rubygems/builder.rb +15 -5
- data/lib/rubygems/command.rb +12 -4
- data/lib/rubygems/command_manager.rb +1 -1
- data/lib/rubygems/commands/build_command.rb +1 -1
- data/lib/rubygems/commands/cert_command.rb +4 -4
- data/lib/rubygems/commands/check_command.rb +1 -1
- data/lib/rubygems/commands/fetch_command.rb +1 -1
- data/lib/rubygems/commands/install_command.rb +4 -16
- data/lib/rubygems/commands/lock_command.rb +1 -1
- data/lib/rubygems/commands/mirror_command.rb +4 -4
- data/lib/rubygems/commands/pristine_command.rb +0 -1
- data/lib/rubygems/commands/push_command.rb +13 -2
- data/lib/rubygems/commands/query_command.rb +4 -4
- data/lib/rubygems/commands/server_command.rb +9 -1
- data/lib/rubygems/commands/setup_command.rb +3 -3
- data/lib/rubygems/commands/sources_command.rb +2 -1
- data/lib/rubygems/commands/specification_command.rb +2 -1
- data/lib/rubygems/commands/unpack_command.rb +2 -1
- data/lib/rubygems/commands/update_command.rb +2 -2
- data/lib/rubygems/commands/which_command.rb +1 -0
- data/lib/rubygems/custom_require.rb +0 -2
- data/lib/rubygems/dependency.rb +15 -20
- data/lib/rubygems/dependency_installer.rb +31 -24
- data/lib/rubygems/dependency_list.rb +2 -7
- data/lib/rubygems/doc_manager.rb +2 -2
- data/lib/rubygems/ext/rake_builder.rb +1 -1
- data/lib/rubygems/format.rb +0 -4
- data/lib/rubygems/gem_openssl.rb +1 -3
- data/lib/rubygems/gem_path_searcher.rb +17 -0
- data/lib/rubygems/gem_runner.rb +6 -0
- data/lib/rubygems/gemcutter_utilities.rb +3 -3
- data/lib/rubygems/indexer.rb +4 -4
- data/lib/rubygems/install_update_options.rb +6 -0
- data/lib/rubygems/installer.rb +13 -6
- data/lib/rubygems/local_remote_options.rb +18 -5
- data/lib/rubygems/old_format.rb +4 -4
- data/lib/rubygems/package.rb +1 -6
- data/lib/rubygems/package/tar_input.rb +3 -0
- data/lib/rubygems/package_task.rb +6 -6
- data/lib/rubygems/platform.rb +1 -1
- data/lib/rubygems/remote_fetcher.rb +39 -8
- data/lib/rubygems/requirement.rb +1 -1
- data/lib/rubygems/security.rb +145 -106
- data/lib/rubygems/server.rb +16 -2
- data/lib/rubygems/source_index.rb +14 -45
- data/lib/rubygems/source_info_cache.rb +1 -2
- data/lib/rubygems/spec_fetcher.rb +32 -3
- data/lib/rubygems/specification.rb +34 -16
- data/lib/rubygems/text.rb +35 -0
- data/lib/rubygems/uninstaller.rb +1 -1
- data/lib/rubygems/user_interaction.rb +70 -0
- data/lib/rubygems/validator.rb +5 -3
- data/lib/rubygems/version.rb +36 -25
- data/test/gem_package_tar_test_case.rb +3 -1
- data/test/gemutilities.rb +26 -4
- data/test/test_config.rb +6 -2
- data/test/test_gem.rb +87 -29
- data/test/test_gem_command_manager.rb +3 -6
- data/test/test_gem_commands_cert_command.rb +2 -2
- data/test/test_gem_commands_install_command.rb +55 -0
- data/test/test_gem_commands_outdated_command.rb +2 -2
- data/test/test_gem_commands_owner_command.rb +6 -6
- data/test/test_gem_commands_push_command.rb +27 -7
- data/test/test_gem_commands_query_command.rb +0 -6
- data/test/test_gem_commands_specification_command.rb +4 -4
- data/test/test_gem_config_file.rb +0 -2
- data/test/test_gem_dependency_installer.rb +21 -23
- data/test/test_gem_ext_ext_conf_builder.rb +0 -9
- data/test/test_gem_ext_rake_builder.rb +0 -15
- data/test/test_gem_gemcutter_utilities.rb +1 -1
- data/test/test_gem_installer.rb +0 -5
- data/test/test_gem_local_remote_options.rb +18 -1
- data/test/test_gem_package_task.rb +1 -1
- data/test/test_gem_platform.rb +0 -1
- data/test/test_gem_remote_fetcher.rb +5 -3
- data/test/test_gem_requirement.rb +2 -2
- data/test/test_gem_security.rb +90 -0
- data/test/test_gem_server.rb +6 -6
- data/test/test_gem_source_index.rb +7 -13
- data/test/test_gem_specification.rb +3 -18
- data/test/test_gem_stream_ui.rb +69 -5
- data/test/test_gem_text.rb +43 -0
- data/test/test_gem_version.rb +14 -7
- data/test/test_kernel.rb +1 -1
- data/util/gem_prelude.rb +8 -8
- metadata +15 -10
- metadata.gz.sig +0 -0
@@ -2,7 +2,7 @@ require File.expand_path('../gemutilities', __FILE__)
|
|
2
2
|
require 'rubygems'
|
3
3
|
require 'rubygems/package_task'
|
4
4
|
|
5
|
-
class TestGemPackageTask <
|
5
|
+
class TestGemPackageTask < RubyGemTestCase
|
6
6
|
|
7
7
|
def test_gem_package
|
8
8
|
gem = Gem::Specification.new do |g|
|
data/test/test_gem_platform.rb
CHANGED
@@ -117,7 +117,6 @@ class TestGemPlatform < RubyGemTestCase
|
|
117
117
|
|
118
118
|
def test_initialize_platform
|
119
119
|
platform = Gem::Platform.new 'cpu-my_platform1'
|
120
|
-
expected = Gem::Platform.new platform
|
121
120
|
|
122
121
|
assert_equal 'cpu', platform.cpu
|
123
122
|
assert_equal 'my_platform', platform.os
|
@@ -562,7 +562,7 @@ gems:
|
|
562
562
|
end
|
563
563
|
end
|
564
564
|
|
565
|
-
conn = {
|
565
|
+
conn = { "#{Thread.current.object_id}:gems.example.com:80" => conn }
|
566
566
|
fetcher.instance_variable_set :@connections, conn
|
567
567
|
|
568
568
|
data = fetcher.open_uri_or_path 'http://gems.example.com/redirect'
|
@@ -581,7 +581,7 @@ gems:
|
|
581
581
|
res
|
582
582
|
end
|
583
583
|
|
584
|
-
conn = {
|
584
|
+
conn = { "#{Thread.current.object_id}:gems.example.com:80" => conn }
|
585
585
|
fetcher.instance_variable_set :@connections, conn
|
586
586
|
|
587
587
|
e = assert_raises Gem::RemoteFetcher::FetchError do
|
@@ -646,11 +646,13 @@ gems:
|
|
646
646
|
|
647
647
|
def assert_error(exception_class=Exception)
|
648
648
|
got_exception = false
|
649
|
+
|
649
650
|
begin
|
650
651
|
yield
|
651
|
-
rescue exception_class
|
652
|
+
rescue exception_class
|
652
653
|
got_exception = true
|
653
654
|
end
|
655
|
+
|
654
656
|
assert got_exception, "Expected exception conforming to #{exception_class}"
|
655
657
|
end
|
656
658
|
|
@@ -216,9 +216,9 @@ class TestGemRequirement < RubyGemTestCase
|
|
216
216
|
refute_satisfied_by "2.0", "~> 1.4.4"
|
217
217
|
|
218
218
|
refute_satisfied_by "1.1.pre", "~> 1.0.0"
|
219
|
-
|
219
|
+
refute_satisfied_by "1.1.pre", "~> 1.1"
|
220
220
|
refute_satisfied_by "2.0.a", "~> 1.0"
|
221
|
-
|
221
|
+
refute_satisfied_by "2.0.a", "~> 2.0"
|
222
222
|
end
|
223
223
|
|
224
224
|
def test_satisfied_by_eh_multiple
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'rubygems/security'
|
3
|
+
|
4
|
+
class TestGemSecurity < RubyGemTestCase
|
5
|
+
|
6
|
+
def test_class_build_cert
|
7
|
+
name = OpenSSL::X509::Name.parse "CN=nobody/DC=example"
|
8
|
+
key = OpenSSL::PKey::RSA.new 512
|
9
|
+
opt = { :cert_age => 60 }
|
10
|
+
|
11
|
+
cert = Gem::Security.build_cert name, key, opt
|
12
|
+
|
13
|
+
assert_kind_of OpenSSL::X509::Certificate, cert
|
14
|
+
|
15
|
+
assert_equal 2, cert.version
|
16
|
+
assert_equal 0, cert.serial
|
17
|
+
assert_equal key.public_key.to_pem, cert.public_key.to_pem
|
18
|
+
assert_in_delta Time.now, cert.not_before, 10
|
19
|
+
assert_in_delta Time.now + 60, cert.not_after, 10
|
20
|
+
assert_equal name.to_s, cert.subject.to_s
|
21
|
+
|
22
|
+
assert_equal 3, cert.extensions.length
|
23
|
+
|
24
|
+
constraints = cert.extensions.find { |ext| ext.oid == 'basicConstraints' }
|
25
|
+
assert_equal 'CA:FALSE', constraints.value
|
26
|
+
|
27
|
+
key_usage = cert.extensions.find { |ext| ext.oid == 'keyUsage' }
|
28
|
+
assert_equal 'Digital Signature, Key Encipherment, Data Encipherment',
|
29
|
+
key_usage.value
|
30
|
+
|
31
|
+
key_ident = cert.extensions.find { |ext| ext.oid == 'subjectKeyIdentifier' }
|
32
|
+
assert_equal 59, key_ident.value.length
|
33
|
+
|
34
|
+
assert_equal name.to_s, cert.issuer.to_s
|
35
|
+
assert_equal name.to_s, cert.subject.to_s
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_class_build_self_signed_cert
|
39
|
+
email = 'nobody@example'
|
40
|
+
opt = {
|
41
|
+
:cert_age => 60,
|
42
|
+
:key_size => 512,
|
43
|
+
:save_cert => false,
|
44
|
+
:save_key => false,
|
45
|
+
}
|
46
|
+
|
47
|
+
result = Gem::Security.build_self_signed_cert email, opt
|
48
|
+
|
49
|
+
key = result[:key]
|
50
|
+
|
51
|
+
assert_kind_of OpenSSL::PKey::RSA, key
|
52
|
+
# assert_equal 512, key.something_here
|
53
|
+
|
54
|
+
cert = result[:cert]
|
55
|
+
|
56
|
+
assert_equal '/CN=nobody/DC=example', cert.issuer.to_s
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_class_sign_cert
|
60
|
+
name = OpenSSL::X509::Name.parse "CN=nobody/DC=example"
|
61
|
+
key = OpenSSL::PKey::RSA.new 512
|
62
|
+
cert = OpenSSL::X509::Certificate.new
|
63
|
+
|
64
|
+
cert.subject = name
|
65
|
+
cert.public_key = key.public_key
|
66
|
+
|
67
|
+
signed = Gem::Security.sign_cert cert, key, cert
|
68
|
+
|
69
|
+
assert cert.verify key
|
70
|
+
assert_equal name.to_s, signed.subject.to_s
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_class_email_to_name
|
74
|
+
munger = Gem::Security::OPT[:munge_re]
|
75
|
+
|
76
|
+
assert_equal '/CN=nobody/DC=example',
|
77
|
+
Gem::Security.email_to_name('nobody@example', munger).to_s
|
78
|
+
|
79
|
+
assert_equal '/CN=nobody/DC=example/DC=com',
|
80
|
+
Gem::Security.email_to_name('nobody@example.com', munger).to_s
|
81
|
+
|
82
|
+
assert_equal '/CN=no.body/DC=example',
|
83
|
+
Gem::Security.email_to_name('no.body@example', munger).to_s
|
84
|
+
|
85
|
+
assert_equal '/CN=no_body/DC=example',
|
86
|
+
Gem::Security.email_to_name('no+body@example', munger).to_s
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
data/test/test_gem_server.rb
CHANGED
@@ -92,7 +92,7 @@ class TestGemServer < RubyGemTestCase
|
|
92
92
|
def test_listen
|
93
93
|
util_listen
|
94
94
|
|
95
|
-
|
95
|
+
capture_io do
|
96
96
|
@server.listen
|
97
97
|
end
|
98
98
|
|
@@ -102,10 +102,10 @@ class TestGemServer < RubyGemTestCase
|
|
102
102
|
def test_listen_addresses
|
103
103
|
util_listen
|
104
104
|
|
105
|
-
|
105
|
+
capture_io do
|
106
106
|
@server.listen %w[a b]
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
assert_equal 2, @server.server.listeners.length
|
110
110
|
end
|
111
111
|
|
@@ -125,7 +125,7 @@ class TestGemServer < RubyGemTestCase
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def test_quick_a_1_mswin32_gemspec_rz
|
128
|
-
|
128
|
+
quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
|
129
129
|
|
130
130
|
data = StringIO.new "GET /quick/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
|
131
131
|
@req.parse data
|
@@ -143,7 +143,7 @@ class TestGemServer < RubyGemTestCase
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def test_quick_common_substrings
|
146
|
-
|
146
|
+
quick_gem 'ab', '1'
|
147
147
|
|
148
148
|
data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
|
149
149
|
@req.parse data
|
@@ -236,7 +236,7 @@ class TestGemServer < RubyGemTestCase
|
|
236
236
|
end
|
237
237
|
|
238
238
|
def test_quick_marshal_a_1_mswin32_gemspec_rz
|
239
|
-
|
239
|
+
quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
|
240
240
|
|
241
241
|
data = StringIO.new "GET /quick/Marshal.#{Gem.marshal_version}/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
|
242
242
|
@req.parse data
|
@@ -116,19 +116,14 @@ end
|
|
116
116
|
fp.write 'raise Exception, "epic fail"'
|
117
117
|
end
|
118
118
|
|
119
|
-
|
119
|
+
out, err = capture_io do
|
120
120
|
assert_equal nil, Gem::SourceIndex.load_specification(spec_file)
|
121
121
|
end
|
122
122
|
|
123
|
-
assert_equal '',
|
124
|
-
|
125
|
-
expected = <<-EOF
|
126
|
-
WARNING: #<Exception: epic fail>
|
127
|
-
raise Exception, "epic fail"
|
128
|
-
WARNING: Invalid .gemspec format in '#{spec_file}'
|
129
|
-
EOF
|
123
|
+
assert_equal '', out
|
130
124
|
|
131
|
-
|
125
|
+
expected = "Invalid gemspec in [#{spec_file}]: epic fail\n"
|
126
|
+
assert_equal expected, err
|
132
127
|
end
|
133
128
|
|
134
129
|
def test_self_load_specification_interrupt
|
@@ -163,14 +158,13 @@ WARNING: Invalid .gemspec format in '#{spec_file}'
|
|
163
158
|
fp.write '1 +'
|
164
159
|
end
|
165
160
|
|
166
|
-
|
161
|
+
out, err = capture_io do
|
167
162
|
assert_equal nil, Gem::SourceIndex.load_specification(spec_file)
|
168
163
|
end
|
169
164
|
|
170
|
-
assert_equal '',
|
165
|
+
assert_equal '', out
|
171
166
|
|
172
|
-
assert_match(/syntax error/,
|
173
|
-
assert_match(/1 \+/, @ui.error)
|
167
|
+
assert_match(/syntax error/, err)
|
174
168
|
end
|
175
169
|
|
176
170
|
def test_self_load_specification_system_exit
|
@@ -777,7 +777,6 @@ Gem::Specification.new do |s|
|
|
777
777
|
s.summary = %q{this is a summary}
|
778
778
|
|
779
779
|
if s.respond_to? :specification_version then
|
780
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
781
780
|
s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION}
|
782
781
|
|
783
782
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
@@ -832,7 +831,6 @@ Gem::Specification.new do |s|
|
|
832
831
|
s.test_files = [\"test/suite.rb\"]
|
833
832
|
|
834
833
|
if s.respond_to? :specification_version then
|
835
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
836
834
|
s.specification_version = 3
|
837
835
|
|
838
836
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
@@ -1175,21 +1173,6 @@ end
|
|
1175
1173
|
end
|
1176
1174
|
end
|
1177
1175
|
|
1178
|
-
def test_validate_rubyforge_project
|
1179
|
-
util_setup_validate
|
1180
|
-
|
1181
|
-
Dir.chdir @tempdir do
|
1182
|
-
@a1.rubyforge_project = ''
|
1183
|
-
|
1184
|
-
use_ui @ui do
|
1185
|
-
@a1.validate
|
1186
|
-
end
|
1187
|
-
|
1188
|
-
assert_equal "WARNING: no rubyforge_project specified\n",
|
1189
|
-
@ui.error, 'error'
|
1190
|
-
end
|
1191
|
-
end
|
1192
|
-
|
1193
1176
|
def test_validate_rubygems_version
|
1194
1177
|
util_setup_validate
|
1195
1178
|
|
@@ -1258,7 +1241,9 @@ end
|
|
1258
1241
|
specfile.write "raise 'boom'"
|
1259
1242
|
specfile.close
|
1260
1243
|
begin
|
1261
|
-
|
1244
|
+
capture_io do
|
1245
|
+
Gem::Specification.load(specfile.path)
|
1246
|
+
end
|
1262
1247
|
rescue => e
|
1263
1248
|
name_rexp = Regexp.new(Regexp.escape(specfile.path))
|
1264
1249
|
assert e.backtrace.grep(name_rexp).any?
|
data/test/test_gem_stream_ui.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.expand_path('../gemutilities', __FILE__)
|
2
2
|
require 'rubygems/user_interaction'
|
3
|
+
require 'timeout'
|
3
4
|
|
4
5
|
class TestGemStreamUI < RubyGemTestCase
|
5
6
|
|
@@ -24,6 +25,7 @@ class TestGemStreamUI < RubyGemTestCase
|
|
24
25
|
@err = StringIO.new
|
25
26
|
|
26
27
|
@in.extend IsTty
|
28
|
+
@out.extend IsTty
|
27
29
|
|
28
30
|
@sui = Gem::StreamUI.new @in, @out, @err
|
29
31
|
end
|
@@ -105,32 +107,94 @@ class TestGemStreamUI < RubyGemTestCase
|
|
105
107
|
assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string
|
106
108
|
end
|
107
109
|
|
108
|
-
def
|
110
|
+
def test_progress_reporter_silent_nil
|
109
111
|
@cfg.verbose = nil
|
110
112
|
reporter = @sui.progress_reporter 10, 'hi'
|
111
113
|
assert_kind_of Gem::StreamUI::SilentProgressReporter, reporter
|
112
114
|
end
|
113
115
|
|
114
|
-
def
|
116
|
+
def test_progress_reporter_silent_false
|
115
117
|
@cfg.verbose = false
|
116
118
|
reporter = @sui.progress_reporter 10, 'hi'
|
117
119
|
assert_kind_of Gem::StreamUI::SilentProgressReporter, reporter
|
118
120
|
assert_equal "", @out.string
|
119
121
|
end
|
120
122
|
|
121
|
-
def
|
123
|
+
def test_progress_reporter_simple
|
122
124
|
@cfg.verbose = true
|
123
125
|
reporter = @sui.progress_reporter 10, 'hi'
|
124
126
|
assert_kind_of Gem::StreamUI::SimpleProgressReporter, reporter
|
125
127
|
assert_equal "hi\n", @out.string
|
126
128
|
end
|
127
129
|
|
128
|
-
def
|
130
|
+
def test_progress_reporter_verbose
|
129
131
|
@cfg.verbose = 0
|
130
132
|
reporter = @sui.progress_reporter 10, 'hi'
|
131
133
|
assert_kind_of Gem::StreamUI::VerboseProgressReporter, reporter
|
132
134
|
assert_equal "hi\n", @out.string
|
133
135
|
end
|
134
136
|
|
135
|
-
|
137
|
+
def test_download_reporter_silent_nil
|
138
|
+
@cfg.verbose = nil
|
139
|
+
reporter = @sui.download_reporter
|
140
|
+
reporter.fetch 'a.gem', 1024
|
141
|
+
assert_kind_of Gem::StreamUI::SilentDownloadReporter, reporter
|
142
|
+
assert_equal "", @out.string
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_download_reporter_silent_false
|
146
|
+
@cfg.verbose = false
|
147
|
+
reporter = @sui.download_reporter
|
148
|
+
reporter.fetch 'a.gem', 1024
|
149
|
+
assert_kind_of Gem::StreamUI::SilentDownloadReporter, reporter
|
150
|
+
assert_equal "", @out.string
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_download_reporter_anything
|
154
|
+
@cfg.verbose = 0
|
155
|
+
reporter = @sui.download_reporter
|
156
|
+
assert_kind_of Gem::StreamUI::VerboseDownloadReporter, reporter
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_verbose_download_reporter
|
160
|
+
@cfg.verbose = true
|
161
|
+
reporter = @sui.download_reporter
|
162
|
+
reporter.fetch 'a.gem', 1024
|
163
|
+
assert_equal "Fetching: a.gem", @out.string
|
164
|
+
end
|
136
165
|
|
166
|
+
def test_verbose_download_reporter_progress
|
167
|
+
@cfg.verbose = true
|
168
|
+
reporter = @sui.download_reporter
|
169
|
+
reporter.fetch 'a.gem', 1024
|
170
|
+
reporter.update 512
|
171
|
+
assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)", @out.string
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_verbose_download_reporter_progress_once
|
175
|
+
@cfg.verbose = true
|
176
|
+
reporter = @sui.download_reporter
|
177
|
+
reporter.fetch 'a.gem', 1024
|
178
|
+
reporter.update 510
|
179
|
+
reporter.update 512
|
180
|
+
assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)", @out.string
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_verbose_download_reporter_progress_complete
|
184
|
+
@cfg.verbose = true
|
185
|
+
reporter = @sui.download_reporter
|
186
|
+
reporter.fetch 'a.gem', 1024
|
187
|
+
reporter.update 510
|
188
|
+
reporter.done
|
189
|
+
assert_equal "Fetching: a.gem\rFetching: a.gem ( 50%)\rFetching: a.gem (100%)\n", @out.string
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_verbose_download_reporter_no_tty
|
193
|
+
@out.tty = false
|
194
|
+
|
195
|
+
@cfg.verbose = true
|
196
|
+
reporter = @sui.download_reporter
|
197
|
+
reporter.fetch 'a.gem', 1024
|
198
|
+
assert_equal "", @out.string
|
199
|
+
end
|
200
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require "rubygems/text"
|
3
|
+
|
4
|
+
class TestGemText < RubyGemTestCase
|
5
|
+
include Gem::Text
|
6
|
+
|
7
|
+
def test_format_text
|
8
|
+
assert_equal "text to\nwrap", format_text("text to wrap", 8)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_format_text_indent
|
12
|
+
assert_equal " text to\n wrap", format_text("text to wrap", 8, 2)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_format_text_none
|
16
|
+
assert_equal "text to wrap", format_text("text to wrap", 40)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_format_text_none_indent
|
20
|
+
assert_equal " text to wrap", format_text("text to wrap", 40, 2)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_levenshtein_distance_add
|
24
|
+
assert_equal 2, levenshtein_distance("zentest", "zntst")
|
25
|
+
assert_equal 2, levenshtein_distance("zntst", "zentest")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_levenshtein_distance_empty
|
29
|
+
assert_equal 5, levenshtein_distance("abcde", "")
|
30
|
+
assert_equal 5, levenshtein_distance("", "abcde")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_levenshtein_distance_remove
|
34
|
+
assert_equal 3, levenshtein_distance("zentest", "zentestxxx")
|
35
|
+
assert_equal 3, levenshtein_distance("zentestxxx", "zentest")
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_levenshtein_distance_replace
|
39
|
+
assert_equal 2, levenshtein_distance("zentest", "ZenTest")
|
40
|
+
assert_equal 7, levenshtein_distance("xxxxxxx", "ZenTest")
|
41
|
+
assert_equal 7, levenshtein_distance("zentest", "xxxxxxx")
|
42
|
+
end
|
43
|
+
end
|