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
data/test/test_loadmanager.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#--
|
3
|
-
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
4
|
-
# All rights reserved.
|
5
|
-
# See LICENSE.txt for permissions.
|
6
|
-
#++
|
7
|
-
|
8
|
-
|
9
|
-
# This test case disabled because it's incompatible with the new custom_require.rb.
|
10
|
-
|
11
|
-
require 'test/unit'
|
12
|
-
#require 'rubygems/loadpath_manager'
|
13
|
-
require 'rubygems/builder'
|
14
|
-
|
15
|
-
require 'test/gemenvironment'
|
16
|
-
|
17
|
-
class TestLoadPathManager #< Test::Unit::TestCase
|
18
|
-
def setup
|
19
|
-
TestEnvironment.create
|
20
|
-
Gem.clear_paths
|
21
|
-
Gem.use_paths("test/data/gemhome")
|
22
|
-
end
|
23
|
-
|
24
|
-
def teardown
|
25
|
-
Gem.clear_paths
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_build_paths
|
29
|
-
assert defined?(Gem::LoadPathManager)
|
30
|
-
Gem::LoadPathManager.build_paths
|
31
|
-
assert_equal [
|
32
|
-
"test/data/gemhome/gems/a-0.0.2/lib",
|
33
|
-
"test/data/gemhome/gems/a-0.0.1/lib",
|
34
|
-
"test/data/gemhome/gems/b-0.0.2/lib",
|
35
|
-
"test/data/gemhome/gems/c-1.2/lib"
|
36
|
-
], Gem::LoadPathManager.paths
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_search_loadpath
|
40
|
-
assert Gem::LoadPathManager.search_loadpath("test/unit")
|
41
|
-
assert ! Gem::LoadPathManager.search_loadpath("once_in_a_blue_moon")
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_search_gempath
|
45
|
-
assert Gem::LoadPathManager.search_gempath("code")
|
46
|
-
assert ! Gem::LoadPathManager.search_gempath("once_in_a_blue_moon")
|
47
|
-
end
|
48
|
-
end
|
@@ -1,52 +0,0 @@
|
|
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 'test/unit'
|
8
|
-
$:.unshift '../lib'
|
9
|
-
require 'rubygems'
|
10
|
-
Gem::manage_gems
|
11
|
-
|
12
|
-
require 'test/mockgemui'
|
13
|
-
|
14
|
-
class InterruptCommand < Gem::Command
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
super('interrupt', 'Raises an Interrupt Exception', {})
|
18
|
-
end
|
19
|
-
|
20
|
-
def execute
|
21
|
-
raise Interrupt, "Interrupt exception"
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
class TestProcessCommands < Test::Unit::TestCase
|
27
|
-
include Gem::DefaultUserInteraction
|
28
|
-
|
29
|
-
def setup
|
30
|
-
@command_manager = Gem::CommandManager.new
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_query_command
|
34
|
-
use_ui(MockGemUi.new) do
|
35
|
-
@command_manager.process_args "query"
|
36
|
-
assert_match(/LOCAL GEMS/, ui.output)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_run_interrupt
|
41
|
-
use_ui(MockGemUi.new) do
|
42
|
-
@command_manager.register_command :interrupt
|
43
|
-
assert_raises MockGemUi::TermError do
|
44
|
-
@command_manager.run 'interrupt'
|
45
|
-
end
|
46
|
-
assert_equal '', ui.output
|
47
|
-
assert_equal "ERROR: Interrupted\n", ui.error
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
data/test/test_source_index.rb
DELETED
@@ -1,231 +0,0 @@
|
|
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 'test/unit'
|
8
|
-
require 'test/gemutilities'
|
9
|
-
require 'rubygems/source_index'
|
10
|
-
|
11
|
-
Gem.manage_gems
|
12
|
-
|
13
|
-
class Gem::SourceIndex
|
14
|
-
public :convert_specs, :fetcher, :fetch_bulk_index, :fetch_quick_index,
|
15
|
-
:find_missing, :gems, :reduce_specs, :remove_extra,
|
16
|
-
:update_with_missing, :unzip
|
17
|
-
end
|
18
|
-
|
19
|
-
class TestSourceIndex < RubyGemTestCase
|
20
|
-
|
21
|
-
def setup
|
22
|
-
super
|
23
|
-
|
24
|
-
util_setup_fake_fetcher
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_convert_specs
|
28
|
-
specs = @source_index.convert_specs([@gem1].to_yaml)
|
29
|
-
|
30
|
-
@gem1.files = []
|
31
|
-
|
32
|
-
assert_equal [@gem1], specs
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_create_from_directory
|
36
|
-
# TODO
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_fetcher
|
40
|
-
assert_equal @fetcher, @source_index.fetcher
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_fetch_bulk_index_compressed
|
44
|
-
util_setup_bulk_fetch true
|
45
|
-
use_ui MockGemUi.new do
|
46
|
-
fetched_index = @source_index.fetch_bulk_index @uri
|
47
|
-
assert_equal [@gem1.full_name, @gem4.full_name, @gem2.full_name].sort,
|
48
|
-
fetched_index.gems.map { |n,s| n }.sort
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_fetch_bulk_index_error
|
53
|
-
@fetcher.data["http://gems.example.com/yaml.Z"] = proc { raise SocketError }
|
54
|
-
@fetcher.data["http://gems.example.com/yaml"] = proc { raise SocketError }
|
55
|
-
|
56
|
-
e = assert_raise Gem::RemoteSourceException do
|
57
|
-
use_ui MockGemUi.new do
|
58
|
-
@source_index.fetch_bulk_index @uri
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
assert_equal 'Error fetching remote gem cache: SocketError',
|
63
|
-
e.message
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_fetch_bulk_index_uncompressed
|
67
|
-
util_setup_bulk_fetch false
|
68
|
-
use_ui MockGemUi.new do
|
69
|
-
fetched_index = @source_index.fetch_bulk_index @uri
|
70
|
-
assert_equal [@gem1.full_name, @gem4.full_name, @gem2.full_name].sort,
|
71
|
-
fetched_index.gems.map { |n,s| n }.sort
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_fetch_quick_index
|
76
|
-
quick_index = util_zip @gem_names
|
77
|
-
@fetcher.data['http://gems.example.com/quick/index.rz'] = quick_index
|
78
|
-
|
79
|
-
quick_index = @source_index.fetch_quick_index @uri
|
80
|
-
assert_equal [@gem1.full_name, @gem4.full_name, @gem2.full_name].sort,
|
81
|
-
quick_index.sort
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_fetch_quick_index_error
|
85
|
-
@fetcher.data['http://gems.example.com/quick/index.rz'] =
|
86
|
-
proc { raise Exception }
|
87
|
-
|
88
|
-
e = assert_raise Gem::OperationNotSupportedError do
|
89
|
-
@source_index.fetch_quick_index @uri
|
90
|
-
end
|
91
|
-
|
92
|
-
assert_equal 'No quick index found: Exception', e.message
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_find_missing
|
96
|
-
missing = @source_index.find_missing [@gem3.full_name]
|
97
|
-
assert_equal [@gem3.full_name], missing
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_find_missing_none_missing
|
101
|
-
missing = @source_index.find_missing @gem_names.split
|
102
|
-
assert_equal [], missing
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_latest_specs
|
106
|
-
spec = quick_gem @gem1.name, '0.0.1'
|
107
|
-
@source_index.add_spec spec
|
108
|
-
|
109
|
-
expected = {
|
110
|
-
@gem1.name => @gem1,
|
111
|
-
@gem2.name => @gem2,
|
112
|
-
@gem4.name => @gem4
|
113
|
-
}
|
114
|
-
|
115
|
-
assert_equal expected, @source_index.latest_specs
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_outdated
|
119
|
-
sic = Gem::SourceInfoCache.new
|
120
|
-
Gem::SourceInfoCache.instance_variable_set :@cache, sic
|
121
|
-
|
122
|
-
assert_equal [], @source_index.outdated
|
123
|
-
|
124
|
-
updated = quick_gem @gem1.name, '999'
|
125
|
-
util_setup_source_info_cache updated
|
126
|
-
|
127
|
-
assert_equal [updated.name], @source_index.outdated
|
128
|
-
ensure
|
129
|
-
Gem::SourceInfoCache.instance_variable_set :@cache, nil
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_reduce_specs
|
133
|
-
specs = YAML.load @source_index.reduce_specs([@gem1].to_yaml)
|
134
|
-
assert_equal [], specs.first.files
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_remove_extra
|
138
|
-
@source_index.remove_extra [@gem1.full_name]
|
139
|
-
assert_equal [@gem1.full_name], @source_index.gems.map { |n,s| n }
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_remove_extra_no_changes
|
143
|
-
gems = @gem_names.split.sort
|
144
|
-
@source_index.remove_extra gems
|
145
|
-
assert_equal gems, @source_index.gems.map { |n,s| n }.sort
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_search
|
149
|
-
assert_equal [@gem1, @gem4], @source_index.search("gem_one")
|
150
|
-
assert_equal [@gem1], @source_index.search("gem_one", "= 0.0.2")
|
151
|
-
|
152
|
-
assert_equal [], @source_index.search("bogusstring")
|
153
|
-
assert_equal [], @source_index.search("gem_one", "= 3.2.1")
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_search_empty_cache
|
157
|
-
empty_source_index = Gem::SourceIndex.new({})
|
158
|
-
assert_equal [], empty_source_index.search("foo")
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_signature
|
162
|
-
sig = @source_index.gem_signature('foo-1.2.3')
|
163
|
-
assert_equal 64, sig.length
|
164
|
-
assert_match(/^[a-f0-9]{64}$/, sig)
|
165
|
-
end
|
166
|
-
|
167
|
-
def test_specification
|
168
|
-
assert_equal @gem1, @source_index.specification(@gem1.full_name)
|
169
|
-
|
170
|
-
assert_nil @source_index.specification("foo-1.2.4")
|
171
|
-
end
|
172
|
-
|
173
|
-
def test_index_signature
|
174
|
-
sig = @source_index.index_signature
|
175
|
-
assert_match(/^[a-f0-9]{64}$/, sig)
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_unzip
|
179
|
-
input = "x\234+\316\317MU(I\255(\001\000\021\350\003\232"
|
180
|
-
assert_equal 'some text', @source_index.unzip(input)
|
181
|
-
end
|
182
|
-
|
183
|
-
def test_update_bulk
|
184
|
-
util_setup_bulk_fetch true
|
185
|
-
|
186
|
-
@source_index.gems.replace({})
|
187
|
-
assert_equal [], @source_index.gems.keys.sort
|
188
|
-
|
189
|
-
use_ui MockGemUi.new do
|
190
|
-
@source_index.update @uri
|
191
|
-
|
192
|
-
assert_equal @gem_names.split, @source_index.gems.keys.sort
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
def test_update_incremental
|
197
|
-
quick_index = util_zip @gem_names
|
198
|
-
@fetcher.data['http://gems.example.com/quick/index.rz'] = quick_index
|
199
|
-
|
200
|
-
spec_uri = "http://gems.example.com/quick/#{@gem3.full_name}.gemspec.rz"
|
201
|
-
@fetcher.data[spec_uri] = util_zip @gem3.to_yaml
|
202
|
-
|
203
|
-
use_ui MockGemUi.new do
|
204
|
-
@source_index.update @uri
|
205
|
-
|
206
|
-
assert_equal @gem_names.split, @source_index.gems.keys.sort
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
def test_update_with_missing
|
211
|
-
spec_uri = "http://gems.example.com/quick/#{@gem3.full_name}.gemspec.rz"
|
212
|
-
@fetcher.data[spec_uri] = util_zip @gem3.to_yaml
|
213
|
-
|
214
|
-
use_ui MockGemUi.new do
|
215
|
-
@source_index.update_with_missing @uri, [@gem3.full_name]
|
216
|
-
end
|
217
|
-
|
218
|
-
assert_equal @gem3, @source_index.specification(@gem3.full_name)
|
219
|
-
end
|
220
|
-
|
221
|
-
def util_setup_bulk_fetch(compressed)
|
222
|
-
source_index = @source_index.to_yaml
|
223
|
-
|
224
|
-
if compressed then
|
225
|
-
@fetcher.data['http://gems.example.com/yaml.Z'] = util_zip source_index
|
226
|
-
else
|
227
|
-
@fetcher.data['http://gems.example.com/yaml'] = source_index
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#--
|
3
|
-
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
4
|
-
# All rights reserved.
|
5
|
-
# See LICENSE.txt for permissions.
|
6
|
-
#++
|
7
|
-
|
8
|
-
|
9
|
-
require 'test/unit'
|
10
|
-
require 'rubygems/command_manager'
|
11
|
-
require 'rubygems/user_interaction'
|
12
|
-
require 'test/mockgemui'
|
13
|
-
|
14
|
-
class TestSpecificExtras < Test::Unit::TestCase
|
15
|
-
include Gem::DefaultUserInteraction
|
16
|
-
|
17
|
-
def setup
|
18
|
-
@cm = Gem::CommandManager.new
|
19
|
-
@cmd = @cm['rdoc']
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
def test_add_extra_args
|
24
|
-
added_args = ["--all"]
|
25
|
-
command = "rdoc"
|
26
|
-
Gem::Command.add_specific_extra_args command, added_args
|
27
|
-
|
28
|
-
assert_equal(added_args, Gem::Command.specific_extra_args(command))
|
29
|
-
|
30
|
-
Gem::Command.instance_eval "public :add_extra_args"
|
31
|
-
h = @cmd.add_extra_args([])
|
32
|
-
assert_equal(added_args,h)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_add_extra_args_unknown
|
36
|
-
added_args = ["--definitely_not_there"]
|
37
|
-
command = "rdoc"
|
38
|
-
Gem::Command.add_specific_extra_args command, added_args
|
39
|
-
|
40
|
-
assert_equal(added_args, Gem::Command.specific_extra_args(command))
|
41
|
-
|
42
|
-
Gem::Command.instance_eval "public :add_extra_args"
|
43
|
-
h = @cmd.add_extra_args([])
|
44
|
-
assert_equal([],h)
|
45
|
-
end
|
46
|
-
end
|
data/test/test_specification.rb
DELETED
@@ -1,565 +0,0 @@
|
|
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 'test/unit'
|
8
|
-
require 'stringio'
|
9
|
-
require 'test/gemutilities'
|
10
|
-
require 'rubygems'
|
11
|
-
Gem::manage_gems
|
12
|
-
|
13
|
-
LEGACY_GEM_SPEC_FILE = 'test/data/legacy/keyedlist-0.4.0.ruby'
|
14
|
-
LEGACY_GEM_YAML_FILE = 'test/data/legacy/keyedlist-0.4.0.yaml'
|
15
|
-
|
16
|
-
class TestDefaultSpecification < Test::Unit::TestCase
|
17
|
-
def test_defaults
|
18
|
-
spec = Gem::Specification.new do |s|
|
19
|
-
s.name = "blah"
|
20
|
-
s.version = "1.3.5"
|
21
|
-
end
|
22
|
-
assert_equal "blah", spec.name
|
23
|
-
assert_equal "1.3.5", spec.version.to_s
|
24
|
-
assert_equal Gem::Platform::RUBY, spec.platform
|
25
|
-
assert_equal nil, spec.summary
|
26
|
-
assert_equal [], spec.files
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class TestSimpleSpecification < Test::Unit::TestCase
|
31
|
-
def setup
|
32
|
-
@spec = Gem::Specification.new do |s|
|
33
|
-
s.version = "1.0.0"
|
34
|
-
s.name = "boo"
|
35
|
-
s.platform = Gem::Platform::RUBY
|
36
|
-
s.date = Time.now
|
37
|
-
s.summary = "Hello"
|
38
|
-
s.require_paths = ["."]
|
39
|
-
end
|
40
|
-
@spec.mark_version
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_empty_specification_is_invalid
|
44
|
-
spec = Gem::Specification.new
|
45
|
-
assert_raises(Gem::InvalidSpecificationException) {
|
46
|
-
spec.validate
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_empty_non_nil_require_paths_is_invalid
|
51
|
-
@spec.require_paths = []
|
52
|
-
assert_raises(Gem::InvalidSpecificationException) {
|
53
|
-
@spec.validate
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_spec_with_all_required_attributes_validates
|
58
|
-
assert_nothing_raised {
|
59
|
-
@spec.validate
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_rdoc_files_included
|
64
|
-
@spec.files = %w(a b c d)
|
65
|
-
@spec.extra_rdoc_files = %w(x y z)
|
66
|
-
@spec.normalize
|
67
|
-
assert @spec.files.include?('x')
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_duplicate_files_removed
|
71
|
-
@spec.files = %w(a b c d b)
|
72
|
-
@spec.extra_rdoc_files = %w(x y z x)
|
73
|
-
@spec.normalize
|
74
|
-
assert_equal 1, @spec.files.select{|n| n=='b'}.size
|
75
|
-
assert_equal 1, @spec.extra_rdoc_files.select{|n| n=='x'}.size
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_invalid_version_in_gem_spec_makes_spec_invalid
|
79
|
-
@spec.rubygems_version = "3"
|
80
|
-
assert_raises(Gem::InvalidSpecificationException) { @spec.validate }
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_singular_attributes
|
84
|
-
@spec.require_path = 'mylib'
|
85
|
-
@spec.test_file = 'test/suite.rb'
|
86
|
-
@spec.executable = 'bin/app'
|
87
|
-
assert_equal ['mylib'], @spec.require_paths
|
88
|
-
assert_equal ['test/suite.rb'], @spec.test_files
|
89
|
-
assert_equal ['bin/app'], @spec.executables
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_add_bindir_to_list_of_files
|
93
|
-
@spec.bindir = 'apps'
|
94
|
-
@spec.executable = 'app'
|
95
|
-
assert_equal ['apps/app'], @spec.files
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_no_bindir_in_list_of_files
|
99
|
-
@spec.bindir = nil
|
100
|
-
@spec.executable = 'bin/app'
|
101
|
-
assert_equal ['bin/app'], @spec.files
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_deprecated_attributes
|
105
|
-
@spec.test_suite_file = 'test/suite.rb'
|
106
|
-
assert_equal ['test/suite.rb'], @spec.test_files
|
107
|
-
# XXX: what about the warning?
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_attribute_names
|
111
|
-
expected_value = %w{
|
112
|
-
rubygems_version specification_version name version date summary
|
113
|
-
require_paths authors email homepage rubyforge_project description
|
114
|
-
autorequire default_executable bindir has_rdoc required_ruby_version
|
115
|
-
platform files test_files rdoc_options extra_rdoc_files
|
116
|
-
executables extensions requirements dependencies signing_key cert_chain
|
117
|
-
post_install_message
|
118
|
-
}.sort
|
119
|
-
actual_value = Gem::Specification.attribute_names.map { |a| a.to_s }.sort
|
120
|
-
assert_equal expected_value, actual_value
|
121
|
-
end
|
122
|
-
|
123
|
-
# TODO: test all the methods in the "convenience class methods" section of specification.rb
|
124
|
-
|
125
|
-
def test_defaults
|
126
|
-
# @spec is pretty plain, so we'll test some of the default values.
|
127
|
-
assert_equal [], @spec.test_files
|
128
|
-
assert_equal [], @spec.rdoc_options
|
129
|
-
assert_equal [], @spec.extra_rdoc_files
|
130
|
-
assert_equal [], @spec.executables
|
131
|
-
assert_equal [], @spec.extensions
|
132
|
-
assert_equal [], @spec.requirements
|
133
|
-
assert_equal [], @spec.dependencies
|
134
|
-
assert_equal 'bin', @spec.bindir
|
135
|
-
assert_equal false, @spec.has_rdoc
|
136
|
-
assert_equal false, @spec.has_rdoc?
|
137
|
-
assert_equal '> 0.0.0', @spec.required_ruby_version.to_s
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_directly_setting_dependencies_doesnt_work
|
141
|
-
assert_raises(NoMethodError) do
|
142
|
-
@spec.dependencies = [1,2,3]
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_array_attributes
|
147
|
-
@spec.files = (1..10)
|
148
|
-
assert_equal Array, @spec.files.class
|
149
|
-
end
|
150
|
-
|
151
|
-
def test_equality
|
152
|
-
same_spec = @spec.dup
|
153
|
-
assert_equal @spec, same_spec
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_to_yaml_and_back
|
157
|
-
yaml_str = @spec.to_yaml
|
158
|
-
same_spec = YAML.load(yaml_str)
|
159
|
-
assert_equal @spec, same_spec
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_to_ruby_and_back
|
163
|
-
ruby_code = @spec.to_ruby
|
164
|
-
same_spec = eval ruby_code
|
165
|
-
assert_equal @spec, same_spec
|
166
|
-
end
|
167
|
-
end # class TestSimpleSpecification
|
168
|
-
|
169
|
-
class TestSpecification < RubyGemTestCase
|
170
|
-
|
171
|
-
def setup
|
172
|
-
super
|
173
|
-
@spec = quick_gem "TestSpecification"
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_autorequire_array
|
177
|
-
name = "AutorequireArray"
|
178
|
-
files = %w(a.rb b.rb)
|
179
|
-
gem = quick_gem(name) do |s|
|
180
|
-
s.files = files.map { |f| File.join("lib", f) }
|
181
|
-
s.autorequire = files
|
182
|
-
end
|
183
|
-
|
184
|
-
fullname = gem.full_name
|
185
|
-
|
186
|
-
write_file("gems/#{fullname}/lib/a.rb") do |io|
|
187
|
-
io.puts "$LOADED_A = true"
|
188
|
-
end
|
189
|
-
|
190
|
-
write_file("gems/#{fullname}/lib/b.rb") do |io|
|
191
|
-
io.puts "$LOADED_B = true"
|
192
|
-
end
|
193
|
-
|
194
|
-
old_loaded = $".dup
|
195
|
-
old_verbose = $VERBOSE
|
196
|
-
$VERBOSE = nil
|
197
|
-
require_gem name
|
198
|
-
$VERBOSE = old_verbose
|
199
|
-
new_loaded = $".dup
|
200
|
-
|
201
|
-
assert_equal(files, (new_loaded - old_loaded))
|
202
|
-
assert(defined? $LOADED_A)
|
203
|
-
assert(defined? $LOADED_B)
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_autorequire_string
|
207
|
-
name = "AutorequireString"
|
208
|
-
file = "c.rb"
|
209
|
-
gem = quick_gem(name) do |s|
|
210
|
-
s.files = File.join("lib", file)
|
211
|
-
s.autorequire = file
|
212
|
-
end
|
213
|
-
|
214
|
-
fullname = gem.full_name
|
215
|
-
|
216
|
-
write_file("gems/#{fullname}/lib/c.rb") do |io|
|
217
|
-
io.puts "$LOADED_C = true"
|
218
|
-
end
|
219
|
-
|
220
|
-
old_loaded = $".dup
|
221
|
-
old_verbose = $VERBOSE
|
222
|
-
$VERBOSE = nil
|
223
|
-
require_gem name
|
224
|
-
$VERBOSE = old_verbose
|
225
|
-
new_loaded = $".dup
|
226
|
-
|
227
|
-
assert_equal(Array(file), (new_loaded - old_loaded))
|
228
|
-
assert(defined? $LOADED_C)
|
229
|
-
end
|
230
|
-
|
231
|
-
def test_date_equals_date
|
232
|
-
@spec.date = Date.new(2003, 9, 17)
|
233
|
-
assert_equal Time.local(2003, 9, 17, 0,0,0), @spec.date
|
234
|
-
end
|
235
|
-
|
236
|
-
def test_date_equals_string
|
237
|
-
@spec.date = '2003-09-17'
|
238
|
-
assert_equal Time.local(2003, 9, 17, 0,0,0), @spec.date
|
239
|
-
end
|
240
|
-
|
241
|
-
def test_date_equals_time
|
242
|
-
@spec.date = Time.local(2003, 9, 17, 0,0,0)
|
243
|
-
assert_equal Time.local(2003, 9, 17, 0,0,0), @spec.date
|
244
|
-
end
|
245
|
-
|
246
|
-
def test_date_equals_time_local
|
247
|
-
# HACK PDT
|
248
|
-
@spec.date = Time.local(2003, 9, 17, 19,50,0)
|
249
|
-
assert_equal Time.local(2003, 9, 17, 0,0,0), @spec.date
|
250
|
-
end
|
251
|
-
|
252
|
-
def test_date_equals_time_utc
|
253
|
-
# HACK PDT
|
254
|
-
@spec.date = Time.local(2003, 9, 17, 19,50,0)
|
255
|
-
assert_equal Time.local(2003, 9, 17, 0,0,0), @spec.date
|
256
|
-
end
|
257
|
-
|
258
|
-
def test_default_executable
|
259
|
-
@spec.default_executable = nil
|
260
|
-
@spec.instance_variable_set :@executables, nil
|
261
|
-
assert_equal nil, @spec.default_executable
|
262
|
-
end
|
263
|
-
|
264
|
-
def test_files_combines_several_accessor_values
|
265
|
-
@spec.files = %w(files bin/common)
|
266
|
-
@spec.test_files = %w(test_files bin/common)
|
267
|
-
@spec.executables = %w(executables common)
|
268
|
-
@spec.extra_rdoc_files = %w(extra_rdoc_files bin/common)
|
269
|
-
@spec.extensions = %w(extensions bin/common)
|
270
|
-
|
271
|
-
assert_equal(
|
272
|
-
%w(files test_files bin/executables extra_rdoc_files extensions bin/common).sort,
|
273
|
-
@spec.files.sort)
|
274
|
-
end
|
275
|
-
|
276
|
-
def test_non_array_stuff_doesnt_goof_up_files
|
277
|
-
@spec.files = "F"
|
278
|
-
@spec.test_files = "TF"
|
279
|
-
@spec.executables = "X"
|
280
|
-
@spec.extra_rdoc_files = "ERF"
|
281
|
-
@spec.extensions = "E"
|
282
|
-
|
283
|
-
assert_equal %w(TF F bin/X ERF E).sort, @spec.files.sort
|
284
|
-
end
|
285
|
-
|
286
|
-
def test_pathologically_bad_non_array_stuff_doesnt_goof_up_files
|
287
|
-
@spec.instance_variable_set "@files", "F"
|
288
|
-
@spec.instance_variable_set "@test_files", "TF"
|
289
|
-
@spec.instance_variable_set "@extra_rdoc_files", "ERF"
|
290
|
-
@spec.instance_variable_set "@extensions", "E"
|
291
|
-
|
292
|
-
assert_equal %w(F TF ERF E).sort, @spec.files.sort
|
293
|
-
assert_kind_of Integer, @spec.hash
|
294
|
-
end
|
295
|
-
|
296
|
-
def test_pathologically_bad_exectuables_doesnt_goof_up_hash
|
297
|
-
t = Time.now
|
298
|
-
@spec.instance_variable_set("@executables", t)
|
299
|
-
assert_kind_of Integer, @spec.hash
|
300
|
-
end
|
301
|
-
|
302
|
-
def test_to_ruby
|
303
|
-
today = Time.now.strftime("%Y-%m-%d")
|
304
|
-
ruby = "Gem::Specification.new do |s|
|
305
|
-
s.name = %q{TestSpecification}
|
306
|
-
s.version = \"0.0.2\"
|
307
|
-
s.date = %q{#{today}}
|
308
|
-
s.summary = %q{this is a summary}
|
309
|
-
s.email = %q{example@example.com}
|
310
|
-
s.homepage = %q{http://example.com}
|
311
|
-
s.description = %q{This is a test description}
|
312
|
-
s.has_rdoc = true
|
313
|
-
s.authors = [\"A User\"]
|
314
|
-
end
|
315
|
-
"
|
316
|
-
assert_equal ruby, @spec.to_ruby
|
317
|
-
end
|
318
|
-
|
319
|
-
end
|
320
|
-
|
321
|
-
class TestSpecificationEquality < RubyGemTestCase
|
322
|
-
|
323
|
-
def test_eql_eh
|
324
|
-
g1 = quick_gem 'gem'
|
325
|
-
g2 = quick_gem 'gem'
|
326
|
-
|
327
|
-
assert_equal g1, g2
|
328
|
-
assert_equal g1.hash, g2.hash
|
329
|
-
assert_equal true, g1.eql?(g2)
|
330
|
-
end
|
331
|
-
|
332
|
-
def test_equals_is_true_on_same_specification
|
333
|
-
s = Gem::Specification.new
|
334
|
-
assert s == s
|
335
|
-
end
|
336
|
-
|
337
|
-
def test_specs_with_same_attributes_are_equal
|
338
|
-
s = Gem::Specification.new do |spec| spec.name = "ONE" end
|
339
|
-
t = Gem::Specification.new do |spec| spec.name = "ONE" end
|
340
|
-
assert_equal s, t
|
341
|
-
assert_equal t, s
|
342
|
-
end
|
343
|
-
|
344
|
-
def test_specs_with_same_attributes_have_same_hash_code
|
345
|
-
s = Gem::Specification.new do |spec| spec.name = "ONE" end
|
346
|
-
t = Gem::Specification.new do |spec| spec.name = "ONE" end
|
347
|
-
assert_equal s.hash, t.hash
|
348
|
-
end
|
349
|
-
|
350
|
-
def test_specs_with_different_attributes_are_not_equal
|
351
|
-
s = Gem::Specification.new do |spec| spec.name = "ONE" end
|
352
|
-
t = Gem::Specification.new do |spec| spec.name = "TWO" end
|
353
|
-
assert ! (s == t)
|
354
|
-
assert ! (t == s)
|
355
|
-
end
|
356
|
-
|
357
|
-
def test_specs_with_different_attributes_have_different_hash_codes
|
358
|
-
s = Gem::Specification.new do |spec| spec.name = "ONE" end
|
359
|
-
t = Gem::Specification.new do |spec| spec.name = "TWO" end
|
360
|
-
assert s.hash != t.hash
|
361
|
-
end
|
362
|
-
|
363
|
-
def test_equals_is_false_on_non_spec_objects
|
364
|
-
s = Gem::Specification.new
|
365
|
-
t = Object.new
|
366
|
-
assert ! (s == t)
|
367
|
-
assert ! (t == s)
|
368
|
-
end
|
369
|
-
|
370
|
-
def test_proper_behavior_with_nil_default_executable
|
371
|
-
a, b, c = (0..2).collect {
|
372
|
-
Gem::Specification.new do |s|
|
373
|
-
s.name = "abc"
|
374
|
-
s.version = "1.2.3"
|
375
|
-
s.default_executable = nil
|
376
|
-
s.executables = []
|
377
|
-
end
|
378
|
-
}
|
379
|
-
c.default_executable = "xx"
|
380
|
-
assert a == b
|
381
|
-
assert a != c
|
382
|
-
assert c != a
|
383
|
-
end
|
384
|
-
|
385
|
-
def test_proper_behavior_with_bad_non_array_value_for_extensions
|
386
|
-
a, b, c = (0..2).collect {
|
387
|
-
Gem::Specification.new do |s|
|
388
|
-
s.name = "abc"
|
389
|
-
s.version = "1.2.3"
|
390
|
-
s.extensions = "bad value"
|
391
|
-
end
|
392
|
-
}
|
393
|
-
c.extensions = []
|
394
|
-
assert a == b
|
395
|
-
assert a != c
|
396
|
-
assert c != a
|
397
|
-
end
|
398
|
-
|
399
|
-
# The cgikit specification was reported to be causing trouble in at least
|
400
|
-
# one version of RubyGems, so we test explicitly for it.
|
401
|
-
def test_cgikit_specification
|
402
|
-
cgikit = Gem::Specification.new do |s|
|
403
|
-
s.name = %q{cgikit}
|
404
|
-
s.version = "1.1.0"
|
405
|
-
s.date = %q{2004-03-13}
|
406
|
-
s.summary = %q{CGIKit is a componented-oriented web application } +
|
407
|
-
%q{framework like Apple Computers WebObjects. } +
|
408
|
-
%{This framework services Model-View-Controller architecture } +
|
409
|
-
%q{programming by components based on a HTML file, a definition } +
|
410
|
-
%q{file and a Ruby source. }
|
411
|
-
s.email = %q{info@spice-of-life.net}
|
412
|
-
s.homepage = %q{http://www.spice-of-life.net/download/cgikit/}
|
413
|
-
s.autorequire = %q{cgikit}
|
414
|
-
s.bindir = nil
|
415
|
-
s.has_rdoc = nil
|
416
|
-
s.required_ruby_version = nil
|
417
|
-
s.platform = nil
|
418
|
-
s.files = ["lib/cgikit", "lib/cgikit.rb", "lib/cgikit/components", "..."]
|
419
|
-
end
|
420
|
-
|
421
|
-
assert cgikit == cgikit
|
422
|
-
end
|
423
|
-
end
|
424
|
-
|
425
|
-
class TestComplexSpecification < Test::Unit::TestCase
|
426
|
-
|
427
|
-
def setup
|
428
|
-
@spec = Gem::Specification.new do |s|
|
429
|
-
s.name = "rfoo"
|
430
|
-
s.version = "0.1"
|
431
|
-
# Omit 'platform' and test for default.
|
432
|
-
# Omit 'date' and test for default.
|
433
|
-
s.summary = <<-EOF
|
434
|
-
Ruby/Foo is an example RubyGem used for
|
435
|
-
unit testing.
|
436
|
-
EOF
|
437
|
-
# Omit 'require_paths' and test for default.
|
438
|
-
s.author = "The RubyGems Team"
|
439
|
-
s.description = s.summary
|
440
|
-
s.executable = 'foo1' # We'll test default_executable.
|
441
|
-
s.has_rdoc = 'true' # We'll test has_rdoc?
|
442
|
-
s.test_file = 'test/suite.rb' # We'll test has_unit_tests?
|
443
|
-
s.extensions << 'ext/rfoo/extconf.rb'
|
444
|
-
s.requirements << 'A working computer'
|
445
|
-
s.add_dependency('rake', '> 0.4')
|
446
|
-
s.add_dependency('jabber4r')
|
447
|
-
s.add_dependency('pqa', '> 0.4', '<= 0.6')
|
448
|
-
end
|
449
|
-
@spec.mark_version
|
450
|
-
end
|
451
|
-
|
452
|
-
def test_basics
|
453
|
-
@spec.normalize
|
454
|
-
summary_value = "Ruby/Foo is an example RubyGem used for unit testing."
|
455
|
-
assert_equal 'rfoo', @spec.name
|
456
|
-
assert_equal '0.1', @spec.version.to_s
|
457
|
-
assert_equal Gem::Platform::RUBY, @spec.platform
|
458
|
-
assert_equal Time.today, @spec.date
|
459
|
-
assert_equal summary_value, @spec.summary
|
460
|
-
assert_equal summary_value, @spec.description
|
461
|
-
assert_equal "The RubyGems Team", @spec.author
|
462
|
-
assert_equal ['foo1'], @spec.executables
|
463
|
-
assert_equal 'foo1', @spec.default_executable
|
464
|
-
assert_equal true, @spec.has_rdoc?
|
465
|
-
assert_equal ['test/suite.rb'], @spec.test_files
|
466
|
-
assert_equal ['ext/rfoo/extconf.rb'], @spec.extensions
|
467
|
-
assert_equal ['A working computer'], @spec.requirements
|
468
|
-
end
|
469
|
-
|
470
|
-
def test_dependencies
|
471
|
-
deps = @spec.dependencies.map { |d| d.to_s }
|
472
|
-
assert_equal 3, deps.size
|
473
|
-
assert deps.include?('rake (> 0.4)')
|
474
|
-
assert deps.include?('jabber4r (> 0.0.0)')
|
475
|
-
assert deps.include?('pqa (> 0.4, <= 0.6)')
|
476
|
-
end
|
477
|
-
|
478
|
-
def test_equality
|
479
|
-
same_spec = @spec.dup
|
480
|
-
assert_equal @spec, same_spec
|
481
|
-
end
|
482
|
-
|
483
|
-
def xtest_to_yaml_and_back
|
484
|
-
yaml_str = @spec.to_yaml
|
485
|
-
same_spec = YAML.load(yaml_str)
|
486
|
-
assert_equal @spec, same_spec
|
487
|
-
end
|
488
|
-
|
489
|
-
def test_to_ruby_and_back
|
490
|
-
ruby_code = @spec.to_ruby
|
491
|
-
same_spec = eval ruby_code
|
492
|
-
assert_equal @spec, same_spec
|
493
|
-
end
|
494
|
-
|
495
|
-
end # class TestComplexSpecification
|
496
|
-
|
497
|
-
class TestLegacyRubySpecification < Test::Unit::TestCase
|
498
|
-
def setup
|
499
|
-
@ruby_spec = File.read(LEGACY_GEM_SPEC_FILE)
|
500
|
-
end
|
501
|
-
|
502
|
-
def test_load_legacy
|
503
|
-
s = gemspec = eval(@ruby_spec)
|
504
|
-
assert_equal 'keyedlist', s.name
|
505
|
-
assert_equal '0.4.0', s.version.to_s
|
506
|
-
assert_equal true, s.has_rdoc?
|
507
|
-
assert_equal Time.today, s.date
|
508
|
-
assert s.required_ruby_version.satisfied_by?(Gem::Version.new('0.0.1'))
|
509
|
-
assert_equal false, s.has_unit_tests?
|
510
|
-
end
|
511
|
-
|
512
|
-
def test_to_ruby_and_back
|
513
|
-
gemspec1 = eval(@ruby_spec)
|
514
|
-
ruby_code = gemspec1.to_ruby
|
515
|
-
gemspec2 = eval(ruby_code)
|
516
|
-
assert_equal gemspec1, gemspec2
|
517
|
-
end
|
518
|
-
end # class TestLegacyRubySpecification
|
519
|
-
|
520
|
-
class TestLegacyYamlSpecification < Test::Unit::TestCase
|
521
|
-
def setup
|
522
|
-
@yaml_spec = File.read(LEGACY_GEM_YAML_FILE)
|
523
|
-
end
|
524
|
-
|
525
|
-
def test_load
|
526
|
-
s = gemspec = YAML.load(@yaml_spec)
|
527
|
-
assert_equal 'keyedlist', s.name
|
528
|
-
assert_equal '0.4.0', s.version.to_s
|
529
|
-
assert_equal true, s.has_rdoc?
|
530
|
-
#assert_equal Date.today, s.date
|
531
|
-
#assert s.required_ruby_version.satisfied_by?(Gem::Version.new('0.0.1'))
|
532
|
-
assert_equal false, s.has_unit_tests?
|
533
|
-
end
|
534
|
-
|
535
|
-
end # class TestLegacyYamlSpecification
|
536
|
-
|
537
|
-
class TestSpecificationClassMethods < Test::Unit::TestCase
|
538
|
-
def test_load
|
539
|
-
gs = Gem::Specification.load("test/data/one/one.gemspec")
|
540
|
-
assert_equal "one", gs.name
|
541
|
-
assert_equal "one-0.0.1", gs.full_name
|
542
|
-
end
|
543
|
-
|
544
|
-
def test_normalize_input_with_183_yaml
|
545
|
-
input = "!ruby/object:Gem::Specification "
|
546
|
-
assert_equal "--- #{input}", Gem::Specification.normalize_yaml_input(input)
|
547
|
-
end
|
548
|
-
|
549
|
-
def test_normalize_input_with_non_183_yaml
|
550
|
-
input = "--- !ruby/object:Gem::Specification "
|
551
|
-
assert_equal input, Gem::Specification.normalize_yaml_input(input)
|
552
|
-
end
|
553
|
-
|
554
|
-
def test_normalize_input_with_183_io
|
555
|
-
input = "!ruby/object:Gem::Specification "
|
556
|
-
assert_equal "--- #{input}",
|
557
|
-
Gem::Specification.normalize_yaml_input(StringIO.new(input))
|
558
|
-
end
|
559
|
-
|
560
|
-
def test_normalize_input_with_non_183_io
|
561
|
-
input = "--- !ruby/object:Gem::Specification "
|
562
|
-
assert_equal input,
|
563
|
-
Gem::Specification.normalize_yaml_input(StringIO.new(input))
|
564
|
-
end
|
565
|
-
end
|