Alex Cohen Alex Cohen - 1 year ago 101
Ruby Question

Chef serverspec `describe command` using an or statement

I would like to use a serverspec check and run it against two acceptable outcomes, so that if either passes then the check passes. I want my check to pass if the exit status of the command is either 0 or 1. Here is my check:

describe command("rm /var/tmp/*.test") do
its(:exit_status) { should eq 0 }

Right now it can only check if the exit status is 0. How can I change my check to use either 0 or 1 as an acceptable exit status?

Answer Source

Use a compound matcher.

its(:exit_status) { should eq(0).or eq(1) }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download