Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/rubygems/commands/exec_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
22 changes: 22 additions & 0 deletions test/rubygems/test_gem_commands_exec_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down