Alex Cohen
Alex Cohen

Reputation: 6226

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 }   
end

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?

Upvotes: 1

Views: 635

Answers (1)

coderanger
coderanger

Reputation: 54251

Use a compound matcher.

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

Upvotes: 2

Related Questions