diff options
author | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-16 18:49:26 +0900 |
---|---|---|
committer | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-30 00:39:06 +0900 |
commit | fcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch) | |
tree | 64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/test/rubygems/test_gem_commands_help_command.rb |
Fresh start
Diffstat (limited to 'jni/ruby/test/rubygems/test_gem_commands_help_command.rb')
-rw-r--r-- | jni/ruby/test/rubygems/test_gem_commands_help_command.rb | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/jni/ruby/test/rubygems/test_gem_commands_help_command.rb b/jni/ruby/test/rubygems/test_gem_commands_help_command.rb new file mode 100644 index 0000000..bed6095 --- /dev/null +++ b/jni/ruby/test/rubygems/test_gem_commands_help_command.rb @@ -0,0 +1,74 @@ +require "rubygems" +require "rubygems/test_case" +require "rubygems/commands/help_command" +require "rubygems/package" +require "rubygems/command_manager" +require File.expand_path('../rubygems_plugin', __FILE__) + +class TestGemCommandsHelpCommand < Gem::TestCase + def setup + super + + @cmd = Gem::Commands::HelpCommand.new + + load File.expand_path('../rubygems_plugin.rb', __FILE__) unless + Gem::Commands.const_defined? :InterruptCommand + end + + def test_gem_help_bad + util_gem 'bad' do |out, err| + assert_equal('', out) + assert_match "Unknown command bad", err + end + end + + def test_gem_help_gem_dependencies + util_gem 'gem_dependencies' do |out, err| + assert_match 'gem.deps.rb', out + assert_equal '', err + end + end + + def test_gem_help_platforms + util_gem 'platforms' do |out, err| + assert_match(/x86-freebsd/, out) + assert_equal '', err + end + end + + def test_gem_help_commands + mgr = Gem::CommandManager.new + + util_gem 'commands' do |out, err| + mgr.command_names.each do |cmd| + assert_match(/\s+#{cmd}\s+\S+/, out) + end + + if defined?(OpenSSL::SSL) then + assert_empty err + + refute_match 'No command found for ', out + end + end + end + + def test_gem_no_args_shows_help + util_gem do |out, err| + assert_match(/Usage:/, out) + assert_match(/gem install/, out) + assert_equal '', err + end + end + + def util_gem *args + @cmd.options[:args] = args + + use_ui @ui do + Dir.chdir @tempdir do + @cmd.execute + end + end + + yield @ui.output, @ui.error + end +end |