diff --git a/lib/rubygems/commands/exec_command.rb b/lib/rubygems/commands/exec_command.rb index 1feafbdd3583..ac97a7e6a628 100644 --- a/lib/rubygems/commands/exec_command.rb +++ b/lib/rubygems/commands/exec_command.rb @@ -3,17 +3,20 @@ require_relative "../command" require_relative "../dependency_installer" require_relative "../gem_runner" +require_relative "../local_remote_options" require_relative "../package" require_relative "../version_option" class Gem::Commands::ExecCommand < Gem::Command include Gem::VersionOption + include Gem::LocalRemoteOptions def initialize super "exec", "Run a command from a gem", { version: Gem::Requirement.default, } + add_source_option add_version_option add_prerelease_option "to be installed" diff --git a/test/rubygems/test_gem_commands_exec_command.rb b/test/rubygems/test_gem_commands_exec_command.rb index b949cd34a67b..b2dcbb52484a 100644 --- a/test/rubygems/test_gem_commands_exec_command.rb +++ b/test/rubygems/test_gem_commands_exec_command.rb @@ -143,6 +143,28 @@ def test_gem_with_executable end end + def test_gem_with_executable_from_custom_source + spec_fetcher "http://other-gems.example.com/" do |fetcher| + fetcher.gem "a", 2 do |s| + s.executables = %w[a] + s.files = %w[bin/a lib/a.rb] + + write_file File.join(*%W[gems #{s.original_name} bin a]) do |f| + f << "Gem.ui.say #{s.original_name.dump}" + end + end + end + + util_clear_gems + + use_ui @ui do + @cmd.invoke "--source", "http://other-gems.example.com", "a:2" + assert_equal "a-2\n", @ui.output + end + + assert_include Gem.sources.to_a, "http://other-gems.example.com/" + end + def test_gem_with_platforms spec_fetcher do |fetcher| fetcher.download "a", 2 do |s|