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
@@ -6,8 +6,7 @@
|
|
6
6
|
#++
|
7
7
|
|
8
8
|
require 'test/unit'
|
9
|
-
require '
|
10
|
-
|
9
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
11
10
|
require 'rubygems/source_info_cache'
|
12
11
|
|
13
12
|
class Gem::SourceIndex
|
@@ -34,31 +33,48 @@ class TestGemSourceInfoCache < RubyGemTestCase
|
|
34
33
|
Gem.sources.replace @original_sources
|
35
34
|
end
|
36
35
|
|
37
|
-
def
|
36
|
+
def test_self_cache_refreshes
|
37
|
+
Gem.configuration.update_sources = true #true by default
|
38
38
|
source_index = Gem::SourceIndex.new 'key' => 'sys'
|
39
|
-
@fetcher.data[
|
39
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = source_index.dump
|
40
40
|
|
41
|
-
Gem.sources.replace %
|
41
|
+
Gem.sources.replace %W[#{@gem_repo}]
|
42
42
|
|
43
|
-
use_ui
|
43
|
+
use_ui @ui do
|
44
44
|
assert_not_nil Gem::SourceInfoCache.cache
|
45
45
|
assert_kind_of Gem::SourceInfoCache, Gem::SourceInfoCache.cache
|
46
46
|
assert_equal Gem::SourceInfoCache.cache.object_id,
|
47
47
|
Gem::SourceInfoCache.cache.object_id
|
48
|
+
assert_match %r|Bulk updating|, @ui.output
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_self_cache_skips_refresh_based_on_configuration
|
53
|
+
Gem.configuration.update_sources = false
|
54
|
+
source_index = Gem::SourceIndex.new 'key' => 'sys'
|
55
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = source_index.dump
|
56
|
+
|
57
|
+
Gem.sources.replace %w[#{@gem_repo}]
|
58
|
+
|
59
|
+
use_ui @ui do
|
60
|
+
assert_not_nil Gem::SourceInfoCache.cache
|
61
|
+
assert_kind_of Gem::SourceInfoCache, Gem::SourceInfoCache.cache
|
62
|
+
assert_equal Gem::SourceInfoCache.cache.object_id,
|
63
|
+
Gem::SourceInfoCache.cache.object_id
|
64
|
+
assert_no_match %r|Bulk updating|, @ui.output
|
48
65
|
end
|
49
66
|
end
|
50
67
|
|
51
68
|
def test_self_cache_data
|
52
|
-
source = 'http://gems.example.com'
|
53
69
|
source_index = Gem::SourceIndex.new 'key' => 'sys'
|
54
|
-
@fetcher.data["#{
|
70
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = source_index.dump
|
55
71
|
|
56
72
|
Gem::SourceInfoCache.instance_variable_set :@cache, nil
|
57
73
|
sice = Gem::SourceInfoCacheEntry.new source_index, 0
|
58
74
|
|
59
|
-
use_ui
|
75
|
+
use_ui @ui do
|
60
76
|
assert_equal source_index.gems,
|
61
|
-
Gem::SourceInfoCache.cache_data[
|
77
|
+
Gem::SourceInfoCache.cache_data[@gem_repo].source_index.gems
|
62
78
|
end
|
63
79
|
end
|
64
80
|
|
@@ -77,9 +93,9 @@ class TestGemSourceInfoCache < RubyGemTestCase
|
|
77
93
|
end
|
78
94
|
|
79
95
|
def test_cache_data_irreparable
|
80
|
-
@fetcher.data[
|
96
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = @source_index.dump
|
81
97
|
|
82
|
-
data = {
|
98
|
+
data = { @gem_repo => { 'totally' => 'borked' } }
|
83
99
|
|
84
100
|
[@sic.system_cache_file, @sic.user_cache_file].each do |fn|
|
85
101
|
FileUtils.mkdir_p File.dirname(fn)
|
@@ -88,9 +104,9 @@ class TestGemSourceInfoCache < RubyGemTestCase
|
|
88
104
|
|
89
105
|
@sic.instance_eval { @cache_data = nil }
|
90
106
|
|
91
|
-
fetched = use_ui
|
107
|
+
fetched = use_ui @ui do @sic.cache_data end
|
92
108
|
|
93
|
-
fetched_si = fetched[
|
109
|
+
fetched_si = fetched["#{@gem_repo}"].source_index
|
94
110
|
|
95
111
|
assert_equal @source_index.index_signature, fetched_si.index_signature
|
96
112
|
end
|
@@ -115,7 +131,7 @@ class TestGemSourceInfoCache < RubyGemTestCase
|
|
115
131
|
|
116
132
|
def test_cache_data_repair
|
117
133
|
data = {
|
118
|
-
|
134
|
+
@gem_repo => {
|
119
135
|
'cache' => Gem::SourceIndex.new,
|
120
136
|
'size' => 0,
|
121
137
|
}
|
@@ -128,7 +144,7 @@ class TestGemSourceInfoCache < RubyGemTestCase
|
|
128
144
|
@sic.instance_eval { @cache_data = nil }
|
129
145
|
|
130
146
|
expected = {
|
131
|
-
|
147
|
+
@gem_repo =>
|
132
148
|
Gem::SourceInfoCacheEntry.new(Gem::SourceIndex.new, 0)
|
133
149
|
}
|
134
150
|
assert_equal expected, @sic.cache_data
|
@@ -177,12 +193,58 @@ class TestGemSourceInfoCache < RubyGemTestCase
|
|
177
193
|
|
178
194
|
def test_search
|
179
195
|
si = Gem::SourceIndex.new @gem1.full_name => @gem1
|
180
|
-
cache_data = {
|
196
|
+
cache_data = {
|
197
|
+
@gem_repo => Gem::SourceInfoCacheEntry.new(si, nil)
|
198
|
+
}
|
181
199
|
@sic.instance_variable_set :@cache_data, cache_data
|
182
200
|
|
183
201
|
assert_equal [@gem1], @sic.search(//)
|
184
202
|
end
|
185
203
|
|
204
|
+
def test_search_dependency
|
205
|
+
si = Gem::SourceIndex.new @gem1.full_name => @gem1
|
206
|
+
cache_data = {
|
207
|
+
@gem_repo => Gem::SourceInfoCacheEntry.new(si, nil)
|
208
|
+
}
|
209
|
+
@sic.instance_variable_set :@cache_data, cache_data
|
210
|
+
|
211
|
+
dep = Gem::Dependency.new @gem1.name, @gem1.version
|
212
|
+
|
213
|
+
assert_equal [@gem1], @sic.search(dep)
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_search_no_matches
|
217
|
+
si = Gem::SourceIndex.new @gem1.full_name => @gem1
|
218
|
+
cache_data = {
|
219
|
+
@gem_repo => Gem::SourceInfoCacheEntry.new(si, nil)
|
220
|
+
}
|
221
|
+
@sic.instance_variable_set :@cache_data, cache_data
|
222
|
+
|
223
|
+
assert_equal [], @sic.search(/nonexistent/)
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_search_no_matches_in_source
|
227
|
+
si = Gem::SourceIndex.new @gem1.full_name => @gem1
|
228
|
+
cache_data = {
|
229
|
+
@gem_repo => Gem::SourceInfoCacheEntry.new(si, nil)
|
230
|
+
}
|
231
|
+
@sic.instance_variable_set :@cache_data, cache_data
|
232
|
+
Gem.sources.replace %w[more-gems.example.com]
|
233
|
+
|
234
|
+
assert_equal [], @sic.search(/nonexistent/)
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_search_with_source
|
238
|
+
si = Gem::SourceIndex.new @gem1.full_name => @gem1
|
239
|
+
cache_data = {
|
240
|
+
@gem_repo => Gem::SourceInfoCacheEntry.new(si, nil)
|
241
|
+
}
|
242
|
+
@sic.instance_variable_set :@cache_data, cache_data
|
243
|
+
|
244
|
+
assert_equal [[@gem1, @gem_repo]],
|
245
|
+
@sic.search_with_source(//)
|
246
|
+
end
|
247
|
+
|
186
248
|
def test_system_cache_file
|
187
249
|
assert_equal File.join(Gem.dir, "source_cache"), @sic.system_cache_file
|
188
250
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'test/unit'
|
2
|
-
require '
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/source_info_cache_entry'
|
3
4
|
|
4
5
|
class TestGemSourceInfoCacheEntry < RubyGemTestCase
|
5
6
|
|
@@ -9,20 +10,21 @@ class TestGemSourceInfoCacheEntry < RubyGemTestCase
|
|
9
10
|
util_setup_fake_fetcher
|
10
11
|
|
11
12
|
@si = Gem::SourceIndex.new @gem1.full_name => @gem1.name
|
12
|
-
@sic_e = Gem::SourceInfoCacheEntry.new @si, @si.
|
13
|
+
@sic_e = Gem::SourceInfoCacheEntry.new @si, @si.dump.size
|
13
14
|
end
|
14
15
|
|
15
16
|
def test_refresh
|
16
|
-
@fetcher.data[
|
17
|
-
|
17
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}.Z"] =
|
18
|
+
proc { raise Exception }
|
19
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = @si.dump
|
18
20
|
|
19
21
|
assert_nothing_raised do
|
20
|
-
@sic_e.refresh
|
22
|
+
@sic_e.refresh @gem_repo
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
26
|
def test_refresh_bad_uri
|
25
|
-
assert_raise
|
27
|
+
assert_raise URI::BadURIError do
|
26
28
|
@sic_e.refresh 'gems.example.com'
|
27
29
|
end
|
28
30
|
end
|
@@ -30,10 +32,10 @@ class TestGemSourceInfoCacheEntry < RubyGemTestCase
|
|
30
32
|
def test_refresh_update
|
31
33
|
si = Gem::SourceIndex.new @gem1.full_name => @gem1,
|
32
34
|
@gem2.full_name => @gem2
|
33
|
-
@fetcher.data[
|
35
|
+
@fetcher.data["#{@gem_repo}/Marshal.#{@marshal_version}"] = si.dump
|
34
36
|
|
35
|
-
use_ui
|
36
|
-
@sic_e.refresh
|
37
|
+
use_ui @ui do
|
38
|
+
@sic_e.refresh @gem_repo
|
37
39
|
end
|
38
40
|
|
39
41
|
new_gem = @sic_e.source_index.specification(@gem2.full_name)
|
@@ -0,0 +1,738 @@
|
|
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 'stringio'
|
8
|
+
require 'test/unit'
|
9
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
10
|
+
require 'rubygems/specification'
|
11
|
+
|
12
|
+
class TestGemSpecification < RubyGemTestCase
|
13
|
+
|
14
|
+
LEGACY_YAML_SPEC = <<-EOF
|
15
|
+
--- !ruby/object:Gem::Specification
|
16
|
+
rubygems_version: "1.0"
|
17
|
+
name: keyedlist
|
18
|
+
version: !ruby/object:Gem::Version
|
19
|
+
version: 0.4.0
|
20
|
+
date: 2004-03-28 15:37:49.828000 +02:00
|
21
|
+
platform:
|
22
|
+
summary: A Hash which automatically computes keys.
|
23
|
+
require_paths:
|
24
|
+
- lib
|
25
|
+
files:
|
26
|
+
- lib/keyedlist.rb
|
27
|
+
autorequire: keyedlist
|
28
|
+
author: Florian Gross
|
29
|
+
email: flgr@ccan.de
|
30
|
+
has_rdoc: true
|
31
|
+
EOF
|
32
|
+
|
33
|
+
LEGACY_RUBY_SPEC = <<-EOF
|
34
|
+
Gem::Specification.new do |s|
|
35
|
+
s.name = %q{keyedlist}
|
36
|
+
s.version = %q{0.4.0}
|
37
|
+
s.has_rdoc = true
|
38
|
+
s.summary = %q{A Hash which automatically computes keys.}
|
39
|
+
s.files = ["lib/keyedlist.rb"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.autorequire = %q{keyedlist}
|
42
|
+
s.author = %q{Florian Gross}
|
43
|
+
s.email = %q{flgr@ccan.de}
|
44
|
+
end
|
45
|
+
EOF
|
46
|
+
|
47
|
+
def setup
|
48
|
+
super
|
49
|
+
|
50
|
+
@a0_0_1 = quick_gem 'a', '0.0.1' do |s|
|
51
|
+
s.executable = 'exec'
|
52
|
+
s.extensions << 'ext/a/extconf.rb'
|
53
|
+
s.has_rdoc = 'true'
|
54
|
+
s.test_file = 'test/suite.rb'
|
55
|
+
s.requirements << 'A working computer'
|
56
|
+
|
57
|
+
s.add_dependency 'rake', '> 0.4'
|
58
|
+
s.add_dependency 'jabber4r', '> 0.0.0'
|
59
|
+
s.add_dependency 'pqa', ['> 0.4', '<= 0.6']
|
60
|
+
|
61
|
+
s.mark_version
|
62
|
+
s.files = %w[lib/code.rb]
|
63
|
+
end
|
64
|
+
|
65
|
+
@a0_0_2 = quick_gem 'a', '0.0.2' do |s|
|
66
|
+
s.files = %w[lib/code.rb]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_self_attribute_names
|
71
|
+
expected_value = %w[
|
72
|
+
authors
|
73
|
+
autorequire
|
74
|
+
bindir
|
75
|
+
cert_chain
|
76
|
+
date
|
77
|
+
default_executable
|
78
|
+
dependencies
|
79
|
+
description
|
80
|
+
email
|
81
|
+
executables
|
82
|
+
extensions
|
83
|
+
extra_rdoc_files
|
84
|
+
files
|
85
|
+
has_rdoc
|
86
|
+
homepage
|
87
|
+
name
|
88
|
+
platform
|
89
|
+
post_install_message
|
90
|
+
rdoc_options
|
91
|
+
require_paths
|
92
|
+
required_ruby_version
|
93
|
+
required_rubygems_version
|
94
|
+
requirements
|
95
|
+
rubyforge_project
|
96
|
+
rubygems_version
|
97
|
+
signing_key
|
98
|
+
specification_version
|
99
|
+
summary
|
100
|
+
test_files
|
101
|
+
version
|
102
|
+
]
|
103
|
+
|
104
|
+
actual_value = Gem::Specification.attribute_names.map { |a| a.to_s }.sort
|
105
|
+
|
106
|
+
assert_equal expected_value, actual_value
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_self_load
|
110
|
+
spec = File.join @gemhome, 'specifications', "#{@a0_0_2.full_name}.gemspec"
|
111
|
+
gs = Gem::Specification.load spec
|
112
|
+
|
113
|
+
assert_equal @a0_0_2, gs
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_self_load_legacy_ruby
|
117
|
+
s = eval LEGACY_RUBY_SPEC
|
118
|
+
assert_equal 'keyedlist', s.name
|
119
|
+
assert_equal '0.4.0', s.version.to_s
|
120
|
+
assert_equal true, s.has_rdoc?
|
121
|
+
assert_equal Gem::Specification::TODAY, s.date
|
122
|
+
assert s.required_ruby_version.satisfied_by?(Gem::Version.new('0.0.1'))
|
123
|
+
assert_equal false, s.has_unit_tests?
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_self_load_legacy_yaml
|
127
|
+
s = YAML.load StringIO.new(LEGACY_YAML_SPEC)
|
128
|
+
assert_equal 'keyedlist', s.name
|
129
|
+
assert_equal '0.4.0', s.version.to_s
|
130
|
+
assert_equal true, s.has_rdoc?
|
131
|
+
#assert_equal Date.today, s.date
|
132
|
+
#assert s.required_ruby_version.satisfied_by?(Gem::Version.new('0.0.1'))
|
133
|
+
assert_equal false, s.has_unit_tests?
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_self_normalize_yaml_input_with_183_yaml
|
137
|
+
input = "!ruby/object:Gem::Specification "
|
138
|
+
assert_equal "--- #{input}", Gem::Specification.normalize_yaml_input(input)
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_self_normalize_yaml_input_with_non_183_yaml
|
142
|
+
input = "--- !ruby/object:Gem::Specification "
|
143
|
+
assert_equal input, Gem::Specification.normalize_yaml_input(input)
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_self_normalize_yaml_input_with_183_io
|
147
|
+
input = "!ruby/object:Gem::Specification "
|
148
|
+
assert_equal "--- #{input}",
|
149
|
+
Gem::Specification.normalize_yaml_input(StringIO.new(input))
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_self_normalize_yaml_input_with_non_183_io
|
153
|
+
input = "--- !ruby/object:Gem::Specification "
|
154
|
+
assert_equal input,
|
155
|
+
Gem::Specification.normalize_yaml_input(StringIO.new(input))
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_initialize
|
159
|
+
spec = Gem::Specification.new do |s|
|
160
|
+
s.name = "blah"
|
161
|
+
s.version = "1.3.5"
|
162
|
+
end
|
163
|
+
|
164
|
+
assert_equal "blah", spec.name
|
165
|
+
assert_equal "1.3.5", spec.version.to_s
|
166
|
+
assert_equal Gem::Platform::RUBY, spec.platform
|
167
|
+
assert_equal nil, spec.summary
|
168
|
+
assert_equal [], spec.files
|
169
|
+
|
170
|
+
assert_equal [], spec.test_files
|
171
|
+
assert_equal [], spec.rdoc_options
|
172
|
+
assert_equal [], spec.extra_rdoc_files
|
173
|
+
assert_equal [], spec.executables
|
174
|
+
assert_equal [], spec.extensions
|
175
|
+
assert_equal [], spec.requirements
|
176
|
+
assert_equal [], spec.dependencies
|
177
|
+
assert_equal 'bin', spec.bindir
|
178
|
+
assert_equal false, spec.has_rdoc
|
179
|
+
assert_equal false, spec.has_rdoc?
|
180
|
+
assert_equal '>= 0', spec.required_ruby_version.to_s
|
181
|
+
assert_equal '>= 0', spec.required_rubygems_version.to_s
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_initialize_future
|
185
|
+
version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + 1
|
186
|
+
spec = Gem::Specification.new do |s|
|
187
|
+
s.name = "blah"
|
188
|
+
s.version = "1.3.5"
|
189
|
+
|
190
|
+
s.specification_version = version
|
191
|
+
|
192
|
+
s.new_unknown_attribute = "a value"
|
193
|
+
end
|
194
|
+
|
195
|
+
assert_equal "blah", spec.name
|
196
|
+
assert_equal "1.3.5", spec.version.to_s
|
197
|
+
end
|
198
|
+
|
199
|
+
def test__dump
|
200
|
+
@a0_0_2.platform = Gem::Platform.local
|
201
|
+
@a0_0_2.instance_variable_set :@original_platform, 'old_platform'
|
202
|
+
|
203
|
+
data = Marshal.dump @a0_0_2
|
204
|
+
|
205
|
+
same_spec = Marshal.load data
|
206
|
+
|
207
|
+
assert_equal 'old_platform', same_spec.original_platform
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_author
|
211
|
+
assert_equal 'A User', @a0_0_1.author
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_authors
|
215
|
+
assert_equal ['A User'], @a0_0_1.authors
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_bindir_equals
|
219
|
+
@a0_0_1.bindir = 'apps'
|
220
|
+
|
221
|
+
assert_equal 'apps', @a0_0_1.bindir
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_bindir_equals_nil
|
225
|
+
@a0_0_2.bindir = nil
|
226
|
+
@a0_0_2.executable = 'app'
|
227
|
+
|
228
|
+
assert_equal nil, @a0_0_2.bindir
|
229
|
+
assert_equal %w[lib/code.rb app], @a0_0_2.files
|
230
|
+
end
|
231
|
+
|
232
|
+
def test_date
|
233
|
+
assert_equal Gem::Specification::TODAY, @a0_0_1.date
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_date_equals_date
|
237
|
+
@a0_0_1.date = Date.new(2003, 9, 17)
|
238
|
+
assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_date_equals_string
|
242
|
+
@a0_0_1.date = '2003-09-17'
|
243
|
+
assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
|
244
|
+
end
|
245
|
+
|
246
|
+
def test_date_equals_time
|
247
|
+
@a0_0_1.date = Time.local(2003, 9, 17, 0,0,0)
|
248
|
+
assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
|
249
|
+
end
|
250
|
+
|
251
|
+
def test_date_equals_time_local
|
252
|
+
# HACK PDT
|
253
|
+
@a0_0_1.date = Time.local(2003, 9, 17, 19,50,0)
|
254
|
+
assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
|
255
|
+
end
|
256
|
+
|
257
|
+
def test_date_equals_time_utc
|
258
|
+
# HACK PDT
|
259
|
+
@a0_0_1.date = Time.local(2003, 9, 17, 19,50,0)
|
260
|
+
assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_default_executable
|
264
|
+
assert_equal 'exec', @a0_0_1.default_executable
|
265
|
+
|
266
|
+
@a0_0_1.default_executable = nil
|
267
|
+
@a0_0_1.instance_variable_set :@executables, nil
|
268
|
+
assert_equal nil, @a0_0_1.default_executable
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_dependencies
|
272
|
+
rake = Gem::Dependency.new 'rake', '> 0.4'
|
273
|
+
jabber = Gem::Dependency.new 'jabber4r', '> 0.0.0'
|
274
|
+
pqa = Gem::Dependency.new 'pqa', ['> 0.4', '<= 0.6']
|
275
|
+
|
276
|
+
assert_equal [rake, jabber, pqa], @a0_0_1.dependencies
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_description
|
280
|
+
assert_equal 'This is a test description', @a0_0_1.description
|
281
|
+
end
|
282
|
+
|
283
|
+
def test_eql_eh
|
284
|
+
g1 = quick_gem 'gem'
|
285
|
+
g2 = quick_gem 'gem'
|
286
|
+
|
287
|
+
assert_equal g1, g2
|
288
|
+
assert_equal g1.hash, g2.hash
|
289
|
+
assert_equal true, g1.eql?(g2)
|
290
|
+
end
|
291
|
+
|
292
|
+
def test_equals2
|
293
|
+
assert_equal @a0_0_1, @a0_0_1
|
294
|
+
assert_equal @a0_0_1, @a0_0_1.dup
|
295
|
+
assert_not_equal @a0_0_1, @a0_0_2
|
296
|
+
assert_not_equal @a0_0_1, Object.new
|
297
|
+
end
|
298
|
+
|
299
|
+
# The cgikit specification was reported to be causing trouble in at least
|
300
|
+
# one version of RubyGems, so we test explicitly for it.
|
301
|
+
def test_equals2_cgikit
|
302
|
+
cgikit = Gem::Specification.new do |s|
|
303
|
+
s.name = %q{cgikit}
|
304
|
+
s.version = "1.1.0"
|
305
|
+
s.date = %q{2004-03-13}
|
306
|
+
s.summary = %q{CGIKit is a componented-oriented web application } +
|
307
|
+
%q{framework like Apple Computers WebObjects. } +
|
308
|
+
%{This framework services Model-View-Controller architecture } +
|
309
|
+
%q{programming by components based on a HTML file, a definition } +
|
310
|
+
%q{file and a Ruby source. }
|
311
|
+
s.email = %q{info@spice-of-life.net}
|
312
|
+
s.homepage = %q{http://www.spice-of-life.net/download/cgikit/}
|
313
|
+
s.autorequire = %q{cgikit}
|
314
|
+
s.bindir = nil
|
315
|
+
s.has_rdoc = nil
|
316
|
+
s.required_ruby_version = nil
|
317
|
+
s.platform = nil
|
318
|
+
s.files = ["lib/cgikit", "lib/cgikit.rb", "lib/cgikit/components", "..."]
|
319
|
+
end
|
320
|
+
|
321
|
+
assert_equal cgikit, cgikit
|
322
|
+
end
|
323
|
+
|
324
|
+
def test_equals2_default_executable
|
325
|
+
spec = @a0_0_1.dup
|
326
|
+
spec.default_executable = 'xx'
|
327
|
+
|
328
|
+
assert_not_equal @a0_0_1, spec
|
329
|
+
assert_not_equal spec, @a0_0_1
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_equals2_extensions
|
333
|
+
spec = @a0_0_1.dup
|
334
|
+
spec.extensions = 'xx'
|
335
|
+
|
336
|
+
assert_not_equal @a0_0_1, spec
|
337
|
+
assert_not_equal spec, @a0_0_1
|
338
|
+
end
|
339
|
+
|
340
|
+
def test_executables
|
341
|
+
@a0_0_1.executable = 'app'
|
342
|
+
assert_equal %w[app], @a0_0_1.executables
|
343
|
+
end
|
344
|
+
|
345
|
+
def test_executable_equals
|
346
|
+
@a0_0_2.executable = 'app'
|
347
|
+
assert_equal 'app', @a0_0_2.executable
|
348
|
+
assert_equal %w[lib/code.rb bin/app], @a0_0_2.files
|
349
|
+
end
|
350
|
+
|
351
|
+
def test_extensions
|
352
|
+
assert_equal ['ext/a/extconf.rb'], @a0_0_1.extensions
|
353
|
+
end
|
354
|
+
|
355
|
+
def test_files
|
356
|
+
@a0_0_1.files = %w(files bin/common)
|
357
|
+
@a0_0_1.test_files = %w(test_files bin/common)
|
358
|
+
@a0_0_1.executables = %w(executables common)
|
359
|
+
@a0_0_1.extra_rdoc_files = %w(extra_rdoc_files bin/common)
|
360
|
+
@a0_0_1.extensions = %w(extensions bin/common)
|
361
|
+
|
362
|
+
expected = %w[
|
363
|
+
bin/common
|
364
|
+
bin/executables
|
365
|
+
extensions
|
366
|
+
extra_rdoc_files
|
367
|
+
files
|
368
|
+
test_files
|
369
|
+
]
|
370
|
+
assert_equal expected, @a0_0_1.files.sort
|
371
|
+
end
|
372
|
+
|
373
|
+
def test_files_duplicate
|
374
|
+
@a0_0_2.files = %w[a b c d b]
|
375
|
+
@a0_0_2.extra_rdoc_files = %w[x y z x]
|
376
|
+
@a0_0_2.normalize
|
377
|
+
|
378
|
+
assert_equal %w[a b c d x y z], @a0_0_2.files
|
379
|
+
assert_equal %w[x y z], @a0_0_2.extra_rdoc_files
|
380
|
+
end
|
381
|
+
|
382
|
+
def test_files_extra_rdoc_files
|
383
|
+
@a0_0_2.files = %w[a b c d]
|
384
|
+
@a0_0_2.extra_rdoc_files = %w[x y z]
|
385
|
+
@a0_0_2.normalize
|
386
|
+
assert_equal %w[a b c d x y z], @a0_0_2.files
|
387
|
+
end
|
388
|
+
|
389
|
+
def test_files_non_array
|
390
|
+
@a0_0_1.files = "F"
|
391
|
+
@a0_0_1.test_files = "TF"
|
392
|
+
@a0_0_1.executables = "X"
|
393
|
+
@a0_0_1.extra_rdoc_files = "ERF"
|
394
|
+
@a0_0_1.extensions = "E"
|
395
|
+
|
396
|
+
assert_equal %w[E ERF F TF bin/X], @a0_0_1.files.sort
|
397
|
+
end
|
398
|
+
|
399
|
+
def test_files_non_array_pathological
|
400
|
+
@a0_0_1.instance_variable_set :@files, "F"
|
401
|
+
@a0_0_1.instance_variable_set :@test_files, "TF"
|
402
|
+
@a0_0_1.instance_variable_set :@extra_rdoc_files, "ERF"
|
403
|
+
@a0_0_1.instance_variable_set :@extensions, "E"
|
404
|
+
@a0_0_1.instance_variable_set :@executables, "X"
|
405
|
+
|
406
|
+
assert_equal %w[E ERF F TF bin/X], @a0_0_1.files.sort
|
407
|
+
assert_kind_of Integer, @a0_0_1.hash
|
408
|
+
end
|
409
|
+
|
410
|
+
def test_full_name
|
411
|
+
assert_equal 'a-0.0.1', @a0_0_1.full_name
|
412
|
+
|
413
|
+
@a0_0_1.platform = Gem::Platform.new ['universal', 'darwin', nil]
|
414
|
+
assert_equal 'a-0.0.1-universal-darwin', @a0_0_1.full_name
|
415
|
+
|
416
|
+
@a0_0_1.instance_variable_set :@new_platform, 'mswin32'
|
417
|
+
assert_equal 'a-0.0.1-mswin32', @a0_0_1.full_name, 'legacy'
|
418
|
+
|
419
|
+
return if win_platform?
|
420
|
+
|
421
|
+
@a0_0_1.platform = 'current'
|
422
|
+
assert_equal 'a-0.0.1-x86-darwin-8', @a0_0_1.full_name
|
423
|
+
end
|
424
|
+
|
425
|
+
def test_full_name_windows
|
426
|
+
test_cases = {
|
427
|
+
'i386-mswin32' => 'a-0.0.1-x86-mswin32-60',
|
428
|
+
'i386-mswin32_80' => 'a-0.0.1-x86-mswin32-80',
|
429
|
+
'i386-mingw32' => 'a-0.0.1-x86-mingw32'
|
430
|
+
}
|
431
|
+
|
432
|
+
test_cases.each do |arch, expected|
|
433
|
+
util_set_arch arch
|
434
|
+
@a0_0_1.platform = 'current'
|
435
|
+
assert_equal expected, @a0_0_1.full_name
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
def test_has_rdoc_eh
|
440
|
+
assert_equal true, @a0_0_1.has_rdoc?
|
441
|
+
end
|
442
|
+
|
443
|
+
def test_hash
|
444
|
+
assert_equal @a0_0_1.hash, @a0_0_1.hash
|
445
|
+
assert_equal @a0_0_1.hash, @a0_0_1.dup.hash
|
446
|
+
assert_not_equal @a0_0_1.hash, @a0_0_2.hash
|
447
|
+
end
|
448
|
+
|
449
|
+
def test_lib_files
|
450
|
+
@a0_0_1.files = %w[lib/foo.rb Rakefile]
|
451
|
+
|
452
|
+
assert_equal %w[lib/foo.rb], @a0_0_1.lib_files
|
453
|
+
end
|
454
|
+
|
455
|
+
def test_name
|
456
|
+
assert_equal 'a', @a0_0_1.name
|
457
|
+
end
|
458
|
+
|
459
|
+
def test_original_name
|
460
|
+
assert_equal 'a-0.0.1', @a0_0_1.full_name
|
461
|
+
|
462
|
+
@a0_0_1.platform = 'i386-linux'
|
463
|
+
@a0_0_1.instance_variable_set :@original_platform, 'i386-linux'
|
464
|
+
assert_equal 'a-0.0.1-i386-linux', @a0_0_1.original_name
|
465
|
+
end
|
466
|
+
|
467
|
+
def test_platform
|
468
|
+
assert_equal Gem::Platform::RUBY, @a0_0_1.platform
|
469
|
+
end
|
470
|
+
|
471
|
+
def test_platform_equals
|
472
|
+
@a0_0_1.platform = nil
|
473
|
+
assert_equal Gem::Platform::RUBY, @a0_0_1.platform
|
474
|
+
|
475
|
+
@a0_0_1.platform = Gem::Platform::RUBY
|
476
|
+
assert_equal Gem::Platform::RUBY, @a0_0_1.platform
|
477
|
+
|
478
|
+
test_cases = {
|
479
|
+
'i386-mswin32' => ['x86', 'mswin32', '60'],
|
480
|
+
'i386-mswin32_80' => ['x86', 'mswin32', '80'],
|
481
|
+
'i386-mingw32' => ['x86', 'mingw32', nil ],
|
482
|
+
'x86-darwin8' => ['x86', 'darwin', '8' ],
|
483
|
+
}
|
484
|
+
|
485
|
+
test_cases.each do |arch, expected|
|
486
|
+
util_set_arch arch
|
487
|
+
@a0_0_1.platform = Gem::Platform::CURRENT
|
488
|
+
assert_equal Gem::Platform.new(expected), @a0_0_1.platform
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
def test_platform_equals_legacy
|
493
|
+
@a0_0_1.platform = Gem::Platform::WIN32
|
494
|
+
assert_equal Gem::Platform::MSWIN32, @a0_0_1.platform
|
495
|
+
|
496
|
+
@a0_0_1.platform = Gem::Platform::LINUX_586
|
497
|
+
assert_equal Gem::Platform::X86_LINUX, @a0_0_1.platform
|
498
|
+
|
499
|
+
@a0_0_1.platform = Gem::Platform::DARWIN
|
500
|
+
assert_equal Gem::Platform::PPC_DARWIN, @a0_0_1.platform
|
501
|
+
end
|
502
|
+
|
503
|
+
def test_require_paths
|
504
|
+
@a0_0_1.require_path = 'lib'
|
505
|
+
assert_equal %w[lib], @a0_0_1.require_paths
|
506
|
+
end
|
507
|
+
|
508
|
+
def test_requirements
|
509
|
+
assert_equal ['A working computer'], @a0_0_1.requirements
|
510
|
+
end
|
511
|
+
|
512
|
+
def test_spaceship_name
|
513
|
+
s1 = quick_gem 'a', '1'
|
514
|
+
s2 = quick_gem 'b', '1'
|
515
|
+
|
516
|
+
assert_equal(-1, (s1 <=> s2))
|
517
|
+
assert_equal( 0, (s1 <=> s1))
|
518
|
+
assert_equal( 1, (s2 <=> s1))
|
519
|
+
end
|
520
|
+
|
521
|
+
def test_spaceship_platform
|
522
|
+
s1 = quick_gem 'a', '1'
|
523
|
+
s2 = quick_gem 'a', '1' do |s|
|
524
|
+
s.platform = Gem::Platform.new 'x86-my_platform1'
|
525
|
+
end
|
526
|
+
|
527
|
+
assert_equal( -1, (s1 <=> s2))
|
528
|
+
assert_equal( 0, (s1 <=> s1))
|
529
|
+
assert_equal( 1, (s2 <=> s1))
|
530
|
+
end
|
531
|
+
|
532
|
+
def test_spaceship_version
|
533
|
+
s1 = quick_gem 'a', '1'
|
534
|
+
s2 = quick_gem 'a', '2'
|
535
|
+
|
536
|
+
assert_equal( -1, (s1 <=> s2))
|
537
|
+
assert_equal( 0, (s1 <=> s1))
|
538
|
+
assert_equal( 1, (s2 <=> s1))
|
539
|
+
end
|
540
|
+
|
541
|
+
def test_summary
|
542
|
+
assert_equal 'this is a summary', @a0_0_1.summary
|
543
|
+
end
|
544
|
+
|
545
|
+
def test_test_files
|
546
|
+
@a0_0_1.test_file = 'test/suite.rb'
|
547
|
+
assert_equal ['test/suite.rb'], @a0_0_1.test_files
|
548
|
+
end
|
549
|
+
|
550
|
+
def test_test_suite_file
|
551
|
+
@a0_0_2.test_suite_file = 'test/suite.rb'
|
552
|
+
assert_equal ['test/suite.rb'], @a0_0_2.test_files
|
553
|
+
# XXX: what about the warning?
|
554
|
+
end
|
555
|
+
|
556
|
+
def test_to_ruby
|
557
|
+
@a0_0_2.required_rubygems_version = Gem::Requirement.new '> 0'
|
558
|
+
|
559
|
+
ruby_code = @a0_0_2.to_ruby
|
560
|
+
|
561
|
+
expected = "Gem::Specification.new do |s|
|
562
|
+
s.name = %q{a}
|
563
|
+
s.version = \"0.0.2\"
|
564
|
+
|
565
|
+
s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION} if s.respond_to? :specification_version=
|
566
|
+
|
567
|
+
s.required_rubygems_version = Gem::Requirement.new(\"> 0\") if s.respond_to? :required_rubygems_version=
|
568
|
+
s.authors = [\"A User\"]
|
569
|
+
s.date = %q{#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}}
|
570
|
+
s.description = %q{This is a test description}
|
571
|
+
s.email = %q{example@example.com}
|
572
|
+
s.files = [\"lib/code.rb\"]
|
573
|
+
s.has_rdoc = true
|
574
|
+
s.homepage = %q{http://example.com}
|
575
|
+
s.require_paths = [\"lib\"]
|
576
|
+
s.rubygems_version = %q{#{Gem::RubyGemsVersion}}
|
577
|
+
s.summary = %q{this is a summary}
|
578
|
+
end
|
579
|
+
"
|
580
|
+
|
581
|
+
assert_equal expected, ruby_code
|
582
|
+
|
583
|
+
same_spec = eval ruby_code
|
584
|
+
|
585
|
+
assert_equal @a0_0_2, same_spec
|
586
|
+
end
|
587
|
+
|
588
|
+
def test_to_ruby_fancy
|
589
|
+
@a0_0_1.platform = Gem::Platform::PPC_DARWIN
|
590
|
+
ruby_code = @a0_0_1.to_ruby
|
591
|
+
|
592
|
+
expected = "Gem::Specification.new do |s|
|
593
|
+
s.name = %q{a}
|
594
|
+
s.version = \"0.0.1\"
|
595
|
+
s.platform = Gem::Platform.new([\"ppc\", \"darwin\", nil])
|
596
|
+
|
597
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
598
|
+
|
599
|
+
s.required_rubygems_version = Gem::Requirement.new(\">= 0\") if s.respond_to? :required_rubygems_version=
|
600
|
+
s.authors = [\"A User\"]
|
601
|
+
s.date = %q{#{Gem::Specification::TODAY.strftime "%Y-%m-%d"}}
|
602
|
+
s.default_executable = %q{exec}
|
603
|
+
s.description = %q{This is a test description}
|
604
|
+
s.email = %q{example@example.com}
|
605
|
+
s.executables = [\"exec\"]
|
606
|
+
s.extensions = [\"ext/a/extconf.rb\"]
|
607
|
+
s.files = [\"lib/code.rb\", \"test/suite.rb\", \"bin/exec\", \"ext/a/extconf.rb\"]
|
608
|
+
s.has_rdoc = %q{true}
|
609
|
+
s.homepage = %q{http://example.com}
|
610
|
+
s.require_paths = [\"lib\"]
|
611
|
+
s.requirements = [\"A working computer\"]
|
612
|
+
s.rubygems_version = %q{#{Gem::RubyGemsVersion}}
|
613
|
+
s.summary = %q{this is a summary}
|
614
|
+
s.test_files = [\"test/suite.rb\"]
|
615
|
+
|
616
|
+
s.add_dependency(%q<rake>, [\"> 0.4\"])
|
617
|
+
s.add_dependency(%q<jabber4r>, [\"> 0.0.0\"])
|
618
|
+
s.add_dependency(%q<pqa>, [\"> 0.4\", \"<= 0.6\"])
|
619
|
+
end
|
620
|
+
"
|
621
|
+
|
622
|
+
assert_equal expected, ruby_code
|
623
|
+
|
624
|
+
same_spec = eval ruby_code
|
625
|
+
|
626
|
+
assert_equal @a0_0_1, same_spec
|
627
|
+
end
|
628
|
+
|
629
|
+
def test_to_ruby_legacy
|
630
|
+
gemspec1 = eval LEGACY_RUBY_SPEC
|
631
|
+
ruby_code = gemspec1.to_ruby
|
632
|
+
gemspec2 = eval ruby_code
|
633
|
+
|
634
|
+
assert_equal gemspec1, gemspec2
|
635
|
+
end
|
636
|
+
|
637
|
+
def test_to_ruby_platform
|
638
|
+
@a0_0_2.platform = Gem::Platform.local
|
639
|
+
@a0_0_2.instance_variable_set :@original_platform, 'old_platform'
|
640
|
+
|
641
|
+
ruby_code = @a0_0_2.to_ruby
|
642
|
+
|
643
|
+
same_spec = eval ruby_code
|
644
|
+
|
645
|
+
assert_equal 'old_platform', same_spec.original_platform
|
646
|
+
end
|
647
|
+
|
648
|
+
def test_to_yaml
|
649
|
+
yaml_str = @a0_0_1.to_yaml
|
650
|
+
same_spec = YAML.load(yaml_str)
|
651
|
+
|
652
|
+
assert_equal @a0_0_1, same_spec
|
653
|
+
end
|
654
|
+
|
655
|
+
def test_to_yaml_fancy
|
656
|
+
@a0_0_1.platform = Gem::Platform::PPC_DARWIN
|
657
|
+
yaml_str = @a0_0_1.to_yaml
|
658
|
+
|
659
|
+
same_spec = YAML.load(yaml_str)
|
660
|
+
|
661
|
+
assert_equal Gem::Platform::PPC_DARWIN, same_spec.platform
|
662
|
+
|
663
|
+
assert_equal @a0_0_1, same_spec
|
664
|
+
end
|
665
|
+
|
666
|
+
def test_to_yaml_legacy_platform
|
667
|
+
@a0_0_1.platform = 'powerpc-darwin7.9.0'
|
668
|
+
@a0_0_1.instance_variable_set :@original_platform, 'powerpc-darwin7.9.0'
|
669
|
+
|
670
|
+
yaml_str = @a0_0_1.to_yaml
|
671
|
+
|
672
|
+
same_spec = YAML.load(yaml_str)
|
673
|
+
|
674
|
+
assert_equal Gem::Platform.new('powerpc-darwin7'), same_spec.platform
|
675
|
+
assert_equal 'powerpc-darwin7.9.0', same_spec.original_platform
|
676
|
+
end
|
677
|
+
|
678
|
+
def test_validate
|
679
|
+
assert @a0_0_1.validate
|
680
|
+
end
|
681
|
+
|
682
|
+
def test_validate_empty
|
683
|
+
e = assert_raise Gem::InvalidSpecificationException do
|
684
|
+
Gem::Specification.new.validate
|
685
|
+
end
|
686
|
+
|
687
|
+
assert_equal 'missing value for attribute name', e.message
|
688
|
+
end
|
689
|
+
|
690
|
+
def test_validate_empty_require_paths
|
691
|
+
@a0_0_1.require_paths = []
|
692
|
+
e = assert_raise Gem::InvalidSpecificationException do
|
693
|
+
@a0_0_1.validate
|
694
|
+
end
|
695
|
+
|
696
|
+
assert_equal 'specification must have at least one require_path', e.message
|
697
|
+
end
|
698
|
+
|
699
|
+
def test_validate_platform_bad
|
700
|
+
@a0_0_1.platform = Object.new
|
701
|
+
assert_raise Gem::InvalidSpecificationException do @a0_0_1.validate end
|
702
|
+
|
703
|
+
@a0_0_1.platform = "my-custom-platform"
|
704
|
+
e = assert_raise Gem::InvalidSpecificationException do
|
705
|
+
@a0_0_1.validate
|
706
|
+
end
|
707
|
+
|
708
|
+
assert_equal 'invalid platform "my-custom-platform", see Gem::Platform',
|
709
|
+
e.message
|
710
|
+
end
|
711
|
+
|
712
|
+
def test_validate_platform_legacy
|
713
|
+
@a0_0_1.platform = Gem::Platform::WIN32
|
714
|
+
assert @a0_0_1.validate
|
715
|
+
|
716
|
+
@a0_0_1.platform = Gem::Platform::LINUX_586
|
717
|
+
assert @a0_0_1.validate
|
718
|
+
|
719
|
+
@a0_0_1.platform = Gem::Platform::DARWIN
|
720
|
+
assert @a0_0_1.validate
|
721
|
+
end
|
722
|
+
|
723
|
+
def test_validate_rubygems_version
|
724
|
+
@a0_0_1.rubygems_version = "3"
|
725
|
+
e = assert_raise Gem::InvalidSpecificationException do
|
726
|
+
@a0_0_1.validate
|
727
|
+
end
|
728
|
+
|
729
|
+
assert_equal "expected RubyGems version #{Gem::RubyGemsVersion}, was 3",
|
730
|
+
e.message
|
731
|
+
end
|
732
|
+
|
733
|
+
def test_version
|
734
|
+
assert_equal Gem::Version.new('0.0.1'), @a0_0_1.version
|
735
|
+
end
|
736
|
+
|
737
|
+
end
|
738
|
+
|