Chef spec rake spec test


#1

Hi Experts,
I have created a method below
provides :cms_mysql_password, platform_family: 'rhel'
action :create do
script 'set database password' do
interpreter 'bash'
user 'root'
cwd '/tmp'
code <<-EOH
root_temp_pass=$(grep 'A temporary password' /mysql/log/mysqld.log |tail -1 |awk '{split($0,a,": "); print a[2]}')
mysql -uroot -p"$root_temp_pass" --connect-expired-password -Be "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Czt';"
EOH
end
end
------------------------------------------------------------------------------------------------------------------------------------------Below is my Recipe
cms_mysql_password 'create-password' do
action :create
not_if "mysql -u root -p'#{pw}'"
end

How to write spec test for this create password , Can you pls guide me how to write a spec test .