1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Add the "rpm" remote dependency.

This commit is contained in:
Nick Hoffman 2012-02-29 16:54:54 -05:00
parent 6543a8f3e6
commit 13d14e3d7d
2 changed files with 17 additions and 0 deletions

View file

@ -49,6 +49,12 @@ module Capistrano
self
end
def rpm(name, version, options={})
@message ||= "package `#{name}' #{version} could not be found"
try("rpm -q #{name} | grep '#{version}'", options)
self
end
def match(command, expect, options={})
expect = Regexp.new(Regexp.escape(expect.to_s)) unless expect.is_a?(Regexp)

View file

@ -43,6 +43,12 @@ class RemoteDependencyTest < Test::Unit::TestCase
assert_equal "package `dpkg' 1.15 could not be found (host)", @dependency.message
end
def test_should_use_standard_error_message_for_rpm
setup_for_a_configuration_rpm_run("rpm", "4.8", false)
@dependency.rpm("rpm", "4.8")
assert_equal "package `rpm' 4.8 could not be found (host)", @dependency.message
end
def test_should_fail_if_directory_not_found
setup_for_a_configuration_run("test -d /data", false)
assert !@dependency.directory("/data").pass?
@ -132,4 +138,9 @@ class RemoteDependencyTest < Test::Unit::TestCase
find_deb_cmd = "dpkg -s #{name} | grep '^Version: #{version}'"
setup_for_a_configuration_run(find_deb_cmd, passing)
end
def setup_for_a_configuration_rpm_run(name, version, passing)
find_rpm_cmd = "rpm -q #{name} | grep '#{version}'"
setup_for_a_configuration_run(find_rpm_cmd, passing)
end
end