Last active
August 24, 2018 07:26
-
-
Save minimum2scp/6e7fcc0eff8326b098f5ec17184acf39 to your computer and use it in GitHub Desktop.
serverspec で debian パッケージが最新になっているかどうかのテスト。apt-get update を済ませている前提。 https://twitter.com/minimum2scp/status/1032832037625847808
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
%w[ | |
base-files | |
openssl | |
openssh-server | |
].each do |pkg| | |
describe command("LANG=C apt-cache policy #{pkg}") do | |
its(:stdout) { | |
should match /\A#{Regexp.quote(pkg)}:\n Installed: (\S+)\n Candidate: \1\n/ | |
} | |
=begin | |
its(:stdout){ | |
should match( | |
/\A#{Regexp.quote(pkg)}:\n Installed: (?<installed_version>\S+)\n Candidate: (?<candidate_version>\S+)\n/ | |
).with_captures( | |
a_hash_including( | |
installed_version: be_truthy, | |
candidate_version: be_truthy | |
).and(satisfy{|m| | |
m[:installed_version] == m[:candidate_version] | |
}) | |
) | |
} | |
=end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment