Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/nickhoffman/capistrano in…

…to nickhoffman-master
  • Loading branch information...
commit fec72c8aa37b3d3c7245bfa2f84bf23acba6e3c3 2 parents 75efaf3 + 5a144cd
@leehambley leehambley authored
View
6 lib/capistrano/recipes/deploy/remote_dependency.rb
@@ -43,6 +43,12 @@ def gem(name, version, options={})
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)
View
23 test/deploy/remote_dependency_test.rb
@@ -37,6 +37,12 @@ def test_should_use_standard_error_message_for_gem
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 @@ def test_should_fail_if_file_not_found
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 @@ def test_should_pass_if_gem_found
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 @@ def setup_for_a_configuration_gem_run(name, version, passing)
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
Please sign in to comment.
Something went wrong with that request. Please try again.