diff options
Diffstat (limited to 'test/rubygems/test_gem_commands_server_command.rb')
-rw-r--r-- | test/rubygems/test_gem_commands_server_command.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_commands_server_command.rb b/test/rubygems/test_gem_commands_server_command.rb index 93d5a6ed47..64ecbeb1f0 100644 --- a/test/rubygems/test_gem_commands_server_command.rb +++ b/test/rubygems/test_gem_commands_server_command.rb @@ -22,5 +22,31 @@ class TestGemCommandsServerCommand < RubyGemTestCase assert_equal File.expand_path('/nonexistent'), @cmd.options[:gemdir] assert_equal 9999, @cmd.options[:port] end + + def test_handle_options_port + @cmd.send :handle_options, %w[-p 0] + assert_equal 0, @cmd.options[:port] + + @cmd.send :handle_options, %w[-p 65535] + assert_equal 65535, @cmd.options[:port] + + @cmd.send :handle_options, %w[-p http] + assert_equal 80, @cmd.options[:port] + + e = assert_raises OptionParser::InvalidArgument do + @cmd.send :handle_options, %w[-p nonexistent] + end + + assert_equal 'invalid argument: -p nonexistent: no such named service', + e.message + + e = assert_raises OptionParser::InvalidArgument do + @cmd.send :handle_options, %w[-p 65536] + end + + assert_equal 'invalid argument: -p 65536: not a port number', + e.message + end + end |