When writing tests where a parameter is an array, we end up writing out a string version of the array. This breaks tests like package. Here are some example failures related to this issue:
Arrays should be treated like arrays, not strings:
9) blp-chef-workstation::_os installs package "mysql-connector-python"
Failure/Error: expect(chef_run).to install_package('mysql-connector-python').with(package_name: '["mysql-connector-python"]')
expected "yum_package[mysql-connector-python]" to have parameters:
package_name "[\"mysql-connector-python\"]", was ["mysql-connector-python"]
# ./spec/umami/unit/recipes/_os_spec.rb:39:in `block (2 levels) in <top (required)>'
10) blp-chef-workstation::_os installs package "ksh, lsof, procps, psmisc, strace, sysstat, tcpdump, telnet, unzip, zsh"
Failure/Error: expect(chef_run).to install_package('ksh, lsof, procps, psmisc, strace, sysstat, tcpdump, telnet, unzip, zsh').with(package_name: '["ksh", "lsof", "procps", "psmisc", "strace", "sysstat", "tcpdump", "telnet", "unzip", "zsh"]')
expected "yum_package[ksh, lsof, procps, psmisc, strace, sysstat, tcpdump, telnet, unzip, zsh]" to have parameters:
package_name "[\"ksh\", \"lsof\", \"procps\", \"psmisc\", \"strace\", \"sysstat\", \"tcpdump\", \"telnet\", \"unzip\", \"zsh\"]", was ["ksh", "lsof", "procps", "psmisc", "strace", "sysstat", "tcpdump", "telnet", "unzip", "zsh”]
The likely behavior we want is that if we encounter an array (say, of packages), we write a looping test, like so:
%w(httpd ntpd).each do |pkg|
describe package(pkg) do
it { should be_installed }
end
end
When writing tests where a parameter is an array, we end up writing out a string version of the array. This breaks tests like
package
. Here are some example failures related to this issue:The likely behavior we want is that if we encounter an array (say, of packages), we write a looping test, like so: