Skip to content

Instantly share code, notes, and snippets.

@minimum2scp
Last active August 24, 2018 07:26
Show Gist options
  • Save minimum2scp/6e7fcc0eff8326b098f5ec17184acf39 to your computer and use it in GitHub Desktop.
Save minimum2scp/6e7fcc0eff8326b098f5ec17184acf39 to your computer and use it in GitHub Desktop.
serverspec で debian パッケージが最新になっているかどうかのテスト。apt-get update を済ませている前提。 https://twitter.com/minimum2scp/status/1032832037625847808
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