mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Merge branch 'master' of https://github.com/nickhoffman/capistrano into nickhoffman-master
This commit is contained in:
commit
fec72c8aa3
2 changed files with 28 additions and 1 deletions
|
@ -43,6 +43,12 @@ module Capistrano
|
|||
self
|
||||
end
|
||||
|
||||
def deb(name, version, options={})
|
||||
@message ||= "package `#{name}' #{version} could not be found"
|
||||
try("dpkg -s #{name} | grep '^Version: #{version}'", options)
|
||||
self
|
||||
end
|
||||
|
||||
def match(command, expect, options={})
|
||||
expect = Regexp.new(Regexp.escape(expect.to_s)) unless expect.is_a?(Regexp)
|
||||
|
||||
|
|
|
@ -37,6 +37,12 @@ class RemoteDependencyTest < Test::Unit::TestCase
|
|||
assert_equal "gem `capistrano' 9.9 could not be found (host)", @dependency.message
|
||||
end
|
||||
|
||||
def test_should_use_standard_error_message_for_deb
|
||||
setup_for_a_configuration_deb_run("dpkg", "1.15", false)
|
||||
@dependency.deb("dpkg", "1.15")
|
||||
assert_equal "package `dpkg' 1.15 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?
|
||||
|
@ -52,7 +58,7 @@ class RemoteDependencyTest < Test::Unit::TestCase
|
|||
assert !@dependency.file("/data/foo.txt").pass?
|
||||
end
|
||||
|
||||
def test_should_pas_if_file_found
|
||||
def test_should_pass_if_file_found
|
||||
setup_for_a_configuration_run("test -f /data/foo.txt", true)
|
||||
assert @dependency.file("/data/foo.txt").pass?
|
||||
end
|
||||
|
@ -87,6 +93,16 @@ class RemoteDependencyTest < Test::Unit::TestCase
|
|||
assert @dependency.gem("capistrano", 9.9).pass?
|
||||
end
|
||||
|
||||
def test_should_pass_if_deb_found
|
||||
setup_for_a_configuration_deb_run("dpkg", "1.15", true)
|
||||
assert @dependency.deb("dpkg", "1.15").pass?
|
||||
end
|
||||
|
||||
def test_should_fail_if_deb_not_found
|
||||
setup_for_a_configuration_deb_run("dpkg", "1.15", false)
|
||||
assert !@dependency.deb("dpkg", "1.15").pass?
|
||||
end
|
||||
|
||||
def test_should_use_alternative_message_if_provided
|
||||
setup_for_a_configuration_run("which cat", false)
|
||||
@dependency.command("cat").or("Sorry")
|
||||
|
@ -111,4 +127,9 @@ class RemoteDependencyTest < Test::Unit::TestCase
|
|||
find_gem_cmd = "gem specification --version '#{version}' #{name} 2>&1 | awk 'BEGIN { s = 0 } /^name:/ { s = 1; exit }; END { if(s == 0) exit 1 }'"
|
||||
setup_for_a_configuration_run(find_gem_cmd, passing)
|
||||
end
|
||||
|
||||
def setup_for_a_configuration_deb_run(name, version, passing)
|
||||
find_deb_cmd = "dpkg -s #{name} | grep '^Version: #{version}'"
|
||||
setup_for_a_configuration_run(find_deb_cmd, passing)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue