このレイアウトはシェフの仕様テスト用ですが、ルビーを利用してファイルの内容を取得します。ただし、このテストでは、実際にはファイルに対してテストしていないため、それを説明する方法を理解しようとしています。コードは次のとおりです。
%w(/etc/bashrc /etc/profile).each do |path|
file(path).content.scan(/^\s*umask\s+(\d{3})\b/).flatten.each do |umask|
BASELINE = '0027'
(1..3).each do |i| # leading char is '0' octal indicator
describe umask[i].to_i do
it { should be <= BASELINE[i].to_i }
end
end
end
end
end
これが私に問題を引き起こしている行です
file(path).content.scan(/^\s*umask\s+(\d{3})\b/).flatten.each do |umask|