How to test if my ServerSpec command condition written in Ruby works?

304 views Asked by At

I'm using the following ruby script

describe command('curl -s -k - i %{http_code} https://localhost/xx/xxx') do
  its(:stdout) { should match /200/ }
end

But I'm unsure if this script works or not. How can I make sure this script works?

2

There are 2 answers

0
coderanger On

Generally Serverspec is used with Chef via the Test Kitchen integration testing framework (though these days InSpec is more popular). You run your tests using the kitchen verify command.

0
Alex Harvey On

It looks to me like what you want is:

describe command('curl -s -k -I https://localhost/xx/xxx') do
  its(:stdout) { should match /200/ }
end