Alex Cohen Alex Cohen - 28 days ago 6x
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?


Use a compound matcher.

its(:exit_status) { should eq(0).or eq(1) }