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
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/user_interaction'
|
4
|
+
|
5
|
+
class TestGemStreamUI < RubyGemTestCase
|
6
|
+
|
7
|
+
module IsTty
|
8
|
+
attr_accessor :tty
|
9
|
+
|
10
|
+
def tty?
|
11
|
+
@tty = true unless defined? @tty
|
12
|
+
return @tty
|
13
|
+
end
|
14
|
+
|
15
|
+
alias_method :isatty, :tty?
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
super
|
20
|
+
|
21
|
+
@cfg = Gem.configuration
|
22
|
+
|
23
|
+
@in = StringIO.new
|
24
|
+
@out = StringIO.new
|
25
|
+
@err = StringIO.new
|
26
|
+
|
27
|
+
@in.extend IsTty
|
28
|
+
|
29
|
+
@sui = Gem::StreamUI.new @in, @out, @err
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_ask
|
33
|
+
timeout(1) do
|
34
|
+
expected_answer = "Arthur, King of the Britons"
|
35
|
+
@in.string = "#{expected_answer}\n"
|
36
|
+
actual_answer = @sui.ask("What is your name?")
|
37
|
+
assert_equal expected_answer, actual_answer
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_ask_no_tty
|
42
|
+
@in.tty = false
|
43
|
+
|
44
|
+
timeout(0.1) do
|
45
|
+
answer = @sui.ask("what is your favorite color?")
|
46
|
+
assert_equal nil, answer
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_ask_yes_no_no_tty_with_default
|
51
|
+
@in.tty = false
|
52
|
+
|
53
|
+
timeout(0.1) do
|
54
|
+
answer = @sui.ask_yes_no("do coconuts migrate?", false)
|
55
|
+
assert_equal false, answer
|
56
|
+
|
57
|
+
answer = @sui.ask_yes_no("do coconuts migrate?", true)
|
58
|
+
assert_equal true, answer
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_ask_yes_no_no_tty_without_default
|
63
|
+
@in.tty = false
|
64
|
+
|
65
|
+
timeout(0.1) do
|
66
|
+
assert_raises(Gem::OperationNotSupportedError) do
|
67
|
+
@sui.ask_yes_no("do coconuts migrate?")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_choose_from_list
|
73
|
+
@in.puts "1"
|
74
|
+
@in.rewind
|
75
|
+
|
76
|
+
result = @sui.choose_from_list 'which one?', %w[foo bar]
|
77
|
+
|
78
|
+
assert_equal ['foo', 0], result
|
79
|
+
assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_choose_from_list_EOF
|
83
|
+
result = @sui.choose_from_list 'which one?', %w[foo bar]
|
84
|
+
|
85
|
+
assert_equal [nil, nil], result
|
86
|
+
assert_equal "which one?\n 1. foo\n 2. bar\n> ", @out.string
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_proress_reporter_silent_nil
|
90
|
+
@cfg.verbose = nil
|
91
|
+
reporter = @sui.progress_reporter 10, 'hi'
|
92
|
+
assert_kind_of Gem::StreamUI::SilentProgressReporter, reporter
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_proress_reporter_silent_false
|
96
|
+
@cfg.verbose = false
|
97
|
+
reporter = @sui.progress_reporter 10, 'hi'
|
98
|
+
assert_kind_of Gem::StreamUI::SilentProgressReporter, reporter
|
99
|
+
assert_equal "", @out.string
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_proress_reporter_simple
|
103
|
+
@cfg.verbose = true
|
104
|
+
reporter = @sui.progress_reporter 10, 'hi'
|
105
|
+
assert_kind_of Gem::StreamUI::SimpleProgressReporter, reporter
|
106
|
+
assert_equal "hi\n", @out.string
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_proress_reporter_verbose
|
110
|
+
@cfg.verbose = 0
|
111
|
+
reporter = @sui.progress_reporter 10, 'hi'
|
112
|
+
assert_kind_of Gem::StreamUI::VerboseProgressReporter, reporter
|
113
|
+
assert_equal "hi\n", @out.string
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
@@ -0,0 +1,70 @@
|
|
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 File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
9
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'simple_gem')
|
10
|
+
require 'rubygems/validator'
|
11
|
+
|
12
|
+
class TestGemValidator < RubyGemTestCase
|
13
|
+
|
14
|
+
def setup
|
15
|
+
super
|
16
|
+
|
17
|
+
@simple_gem = SIMPLE_GEM
|
18
|
+
@validator = Gem::Validator.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_verify_gem_file
|
22
|
+
gem_file = File.join @tempdir, 'simple_gem.gem'
|
23
|
+
File.open gem_file, 'wb' do |fp| fp.write @simple_gem end
|
24
|
+
|
25
|
+
assert_equal nil, @validator.verify_gem_file(gem_file)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_verify_gem_file_empty
|
29
|
+
e = assert_raise Gem::VerificationError do
|
30
|
+
@validator.verify_gem_file ''
|
31
|
+
end
|
32
|
+
|
33
|
+
assert_equal 'missing gem file ', e.message
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_verify_gem_file_nonexistent
|
37
|
+
file = '/nonexistent/nonexistent.gem'
|
38
|
+
e = assert_raise Gem::VerificationError do
|
39
|
+
@validator.verify_gem_file file
|
40
|
+
end
|
41
|
+
|
42
|
+
assert_equal "missing gem file #{file}", e.message
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_verify_gem
|
46
|
+
assert_equal nil, @validator.verify_gem(@simple_gem)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_verify_gem_empty
|
50
|
+
e = assert_raise Gem::VerificationError do
|
51
|
+
@validator.verify_gem ''
|
52
|
+
end
|
53
|
+
|
54
|
+
assert_equal 'empty gem file', e.message
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_verify_gem_invalid_checksum
|
58
|
+
e = assert_raise Gem::VerificationError do
|
59
|
+
@validator.verify_gem @simple_gem.upcase
|
60
|
+
end
|
61
|
+
|
62
|
+
assert_equal 'invalid checksum for gem file', e.message
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_verify_gem_no_sum
|
66
|
+
assert_equal nil, @validator.verify_gem('words')
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,191 @@
|
|
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 File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
9
|
+
require 'rubygems/version'
|
10
|
+
|
11
|
+
class TestGemVersion < RubyGemTestCase
|
12
|
+
|
13
|
+
def setup
|
14
|
+
super
|
15
|
+
|
16
|
+
@v1_0 = Gem::Version.new '1.0'
|
17
|
+
@v1_2 = Gem::Version.new '1.2'
|
18
|
+
@v1_3 = Gem::Version.new '1.3'
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_class_create
|
22
|
+
assert_version Gem::Version.create('1.0')
|
23
|
+
assert_version Gem::Version.create("1.0 ")
|
24
|
+
assert_version Gem::Version.create(" 1.0 ")
|
25
|
+
assert_version Gem::Version.create("1.0\n")
|
26
|
+
assert_version Gem::Version.create("\n1.0\n")
|
27
|
+
|
28
|
+
assert_equal Gem::Version.create('1'), Gem::Version.create(1)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_class_create_malformed
|
32
|
+
e = assert_raise ArgumentError do Gem::Version.create("junk") end
|
33
|
+
assert_equal "Malformed version number string junk", e.message
|
34
|
+
|
35
|
+
e = assert_raise ArgumentError do Gem::Version.create("1.0\n2.0") end
|
36
|
+
assert_equal "Malformed version number string 1.0\n2.0", e.message
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_bad
|
40
|
+
assert_inadequate( "", "> 0.1")
|
41
|
+
assert_inadequate( "1.2.3", "!= 1.2.3")
|
42
|
+
assert_inadequate( "1.2.003.0.0", "!= 1.02.3")
|
43
|
+
assert_inadequate( "4.5.6", "< 1.2.3")
|
44
|
+
assert_inadequate( "1.0", "> 1.1")
|
45
|
+
assert_inadequate( "0", ">")
|
46
|
+
assert_inadequate( "0", "<")
|
47
|
+
assert_inadequate( "", "= 0.1")
|
48
|
+
assert_inadequate( "1.1.1", "> 1.1.1")
|
49
|
+
assert_inadequate( "1.2", "= 1.1")
|
50
|
+
assert_inadequate( "1.40", "= 1.1")
|
51
|
+
assert_inadequate( "1.3", "= 1.40")
|
52
|
+
assert_inadequate( "9.3.3", "<= 9.3.2")
|
53
|
+
assert_inadequate( "9.3.1", ">= 9.3.2")
|
54
|
+
assert_inadequate( "9.3.03", "<= 9.3.2")
|
55
|
+
assert_inadequate( "1.0.0.1", "= 1.0")
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_bump
|
59
|
+
v = Gem::Version.new("5.2.4")
|
60
|
+
assert_equal "5.3", v.bump.to_s
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_bump_one_level
|
64
|
+
v = Gem::Version.new("5")
|
65
|
+
assert_equal "6", v.bump.to_s
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_equals2
|
69
|
+
v = Gem::Version.new("1.2")
|
70
|
+
|
71
|
+
assert_equal v, @v1_2
|
72
|
+
assert_equal @v1_2, v
|
73
|
+
|
74
|
+
assert_not_equal @v1_2, @v1_3
|
75
|
+
assert_not_equal @v1_3, @v1_2
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_hash
|
79
|
+
v = Gem::Version.new("1.2")
|
80
|
+
assert_equal v.hash, @v1_2.hash
|
81
|
+
assert_not_equal @v1_2.hash, @v1_3.hash
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_illformed_requirements
|
85
|
+
[ ">>> 1.3.5", "> blah" ].each do |rq|
|
86
|
+
assert_raises(ArgumentError, "req [#{rq}] should fail") {
|
87
|
+
Gem::Version::Requirement.new(rq)
|
88
|
+
}
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_normalize
|
93
|
+
assert_equal [1], Gem::Version.new("1").to_ints
|
94
|
+
assert_equal [1], Gem::Version.new("1.0").to_ints
|
95
|
+
assert_equal [1, 1], Gem::Version.new("1.1").to_ints
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_ok
|
99
|
+
assert_adequate( "0.2.33", "= 0.2.33")
|
100
|
+
assert_adequate( "0.2.34", "> 0.2.33")
|
101
|
+
assert_adequate( "1.0", "= 1.0")
|
102
|
+
assert_adequate( "1.0", "1.0")
|
103
|
+
assert_adequate( "1.8.2", "> 1.8.0")
|
104
|
+
assert_adequate( "1.112", "> 1.111")
|
105
|
+
assert_adequate( "0.2", "> 0.0.0")
|
106
|
+
assert_adequate( "0.0.0.0.0.2", "> 0.0.0")
|
107
|
+
assert_adequate( "0.0.1.0", "> 0.0.0.1")
|
108
|
+
assert_adequate( "10.3.2", "> 9.3.2")
|
109
|
+
assert_adequate( "1.0.0.0", "= 1.0")
|
110
|
+
assert_adequate( "10.3.2", "!= 9.3.4")
|
111
|
+
assert_adequate( "10.3.2", "> 9.3.2")
|
112
|
+
assert_adequate( "10.3.2", "> 9.3.2")
|
113
|
+
assert_adequate( " 9.3.2", ">= 9.3.2")
|
114
|
+
assert_adequate( "9.3.2 ", ">= 9.3.2")
|
115
|
+
assert_adequate( "", "= 0")
|
116
|
+
assert_adequate( "", "< 0.1")
|
117
|
+
assert_adequate( " ", "< 0.1 ")
|
118
|
+
assert_adequate( "", " < 0.1")
|
119
|
+
assert_adequate( "0", "=")
|
120
|
+
assert_adequate( "0", ">=")
|
121
|
+
assert_adequate( "0", "<=")
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_satisfied_by_eh_boxed
|
125
|
+
assert_inadequate("1.3", "~> 1.4")
|
126
|
+
assert_adequate( "1.4", "~> 1.4")
|
127
|
+
assert_adequate( "1.5", "~> 1.4")
|
128
|
+
assert_inadequate("2.0", "~> 1.4")
|
129
|
+
|
130
|
+
assert_inadequate("1.3", "~> 1.4.4")
|
131
|
+
assert_inadequate("1.4", "~> 1.4.4")
|
132
|
+
assert_adequate( "1.4.4", "~> 1.4.4")
|
133
|
+
assert_adequate( "1.4.5", "~> 1.4.4")
|
134
|
+
assert_inadequate("1.5", "~> 1.4.4")
|
135
|
+
assert_inadequate("2.0", "~> 1.4.4")
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_satisfied_by_eh_multiple
|
139
|
+
req = [">= 1.4", "<= 1.6", "!= 1.5"]
|
140
|
+
assert_inadequate("1.3", req)
|
141
|
+
assert_adequate( "1.4", req)
|
142
|
+
assert_inadequate("1.5", req)
|
143
|
+
assert_adequate( "1.6", req)
|
144
|
+
assert_inadequate("1.7", req)
|
145
|
+
assert_inadequate("2.0", req)
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_spaceship
|
149
|
+
assert_equal 1, Gem::Version.new('1.8.2') <=> Gem::Version.new('0.0.0')
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_boxed
|
153
|
+
assert_inadequate("1.3", "~> 1.4")
|
154
|
+
assert_adequate( "1.4", "~> 1.4")
|
155
|
+
assert_adequate( "1.5", "~> 1.4")
|
156
|
+
assert_inadequate("2.0", "~> 1.4")
|
157
|
+
|
158
|
+
assert_inadequate("1.3", "~> 1.4.4")
|
159
|
+
assert_inadequate("1.4", "~> 1.4.4")
|
160
|
+
assert_adequate( "1.4.4", "~> 1.4.4")
|
161
|
+
assert_adequate( "1.4.5", "~> 1.4.4")
|
162
|
+
assert_inadequate("1.5", "~> 1.4.4")
|
163
|
+
assert_inadequate("2.0", "~> 1.4.4")
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_to_s
|
167
|
+
v = Gem::Version.new("5.2.4")
|
168
|
+
assert_equal "5.2.4", v.to_s
|
169
|
+
end
|
170
|
+
|
171
|
+
def assert_adequate(version, requirement)
|
172
|
+
ver = Gem::Version.new(version)
|
173
|
+
req = Gem::Version::Requirement.new(requirement)
|
174
|
+
assert req.satisfied_by?(ver),
|
175
|
+
"Version #{version} should be adequate for Requirement #{requirement}"
|
176
|
+
end
|
177
|
+
|
178
|
+
def assert_inadequate(version, requirement)
|
179
|
+
ver = Gem::Version.new(version)
|
180
|
+
req = Gem::Version::Requirement.new(requirement)
|
181
|
+
assert ! req.satisfied_by?(ver),
|
182
|
+
"Version #{version} should not be adequate for Requirement #{requirement}"
|
183
|
+
end
|
184
|
+
|
185
|
+
def assert_version(actual)
|
186
|
+
assert_equal @v1_0, actual
|
187
|
+
assert_equal @v1_0.version, actual.version
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
3
|
+
require 'rubygems/command'
|
4
|
+
require 'rubygems/version_option'
|
5
|
+
|
6
|
+
class TestGemVersionOption < RubyGemTestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
super
|
10
|
+
|
11
|
+
@cmd = Gem::Command.new 'dummy', 'dummy'
|
12
|
+
@cmd.extend Gem::VersionOption
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_add_platform_option
|
16
|
+
@cmd.add_platform_option
|
17
|
+
|
18
|
+
assert @cmd.handles?(%w[--platform x86-darwin])
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_add_version_option
|
22
|
+
@cmd.add_version_option
|
23
|
+
|
24
|
+
assert @cmd.handles?(%w[--version >1])
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_platform_option
|
28
|
+
@cmd.add_platform_option
|
29
|
+
|
30
|
+
@cmd.handle_options %w[--platform x86-freebsd6 --platform x86-freebsd7]
|
31
|
+
|
32
|
+
expected = [
|
33
|
+
Gem::Platform::RUBY,
|
34
|
+
Gem::Platform.new('x86-freebsd6'),
|
35
|
+
Gem::Platform.new('x86-freebsd7'),
|
36
|
+
]
|
37
|
+
|
38
|
+
assert_equal expected, Gem.platforms
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_platform_option_ruby
|
42
|
+
@cmd.add_platform_option
|
43
|
+
|
44
|
+
@cmd.handle_options %w[--platform ruby]
|
45
|
+
|
46
|
+
expected = [
|
47
|
+
Gem::Platform::RUBY
|
48
|
+
]
|
49
|
+
|
50
|
+
assert_equal expected, Gem.platforms
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_platform_option_twice
|
54
|
+
@cmd.add_platform_option
|
55
|
+
|
56
|
+
@cmd.handle_options %w[--platform x86-freebsd6 --platform x86-freebsd-6]
|
57
|
+
|
58
|
+
expected = [
|
59
|
+
Gem::Platform::RUBY,
|
60
|
+
Gem::Platform.new('x86-freebsd6'),
|
61
|
+
]
|
62
|
+
|
63
|
+
assert_equal expected, Gem.platforms
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_version_option
|
67
|
+
@cmd.add_version_option
|
68
|
+
|
69
|
+
@cmd.handle_options %w[--version >1]
|
70
|
+
|
71
|
+
expected = { :version => Gem::Requirement.new('> 1'), :args => [] }
|
72
|
+
|
73
|
+
assert_equal expected, @cmd.options
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|