rubychef-infraserverspec

How do I test for the value of a variable in serverspec


I have a fairly simple task to complete. I'm writing a number of tests for a Chef project I'm working on. Serverspec gives you resources such as command, file, etc. What I want to do is simply check for the value of a variable, ie:

someVar = "some value dynamically determined"
describe someVar do
   someVar.nil?
end

I'm sort of new to ruby, and I'm not exactly sure how to proceed.


Solution

  • This would just be standard RSpec:

    describe someVar do
      it { is_expected.to be_nil }
    end