Information Technology Reference
In-Depth Information
expect ( port 80 ) . to be_listening 'tcp'
end
end
end
end
Rerun kitchen verify . You should notice no net change in the tests. It should still report
that one example succeeded.
$ kitchen verify
Although it is a little silly to use a spec_helper.rb file in this contrived example, we hope you
see how this file could be used to contain any duplicate code between multiple files with
tests.
You can add more than one example with tests in a describe block. Normally, there will a
handful to perhaps a dozen. Let's add one more example to default_spec.rb .
Although we've written one example that checks to see that our website is responding on
port 80, we don't really know if it is serving up the correct content. Let's write an example
that inspects the website output to see if it seems OK.
If you look at the Serverspec documentation, you'll find that there isn't an obvious resource
that seems to do what we want. In cases like this, Serverspec lets you run arbitrary command
lines via the command resource as shown in Figure 16-10 . We'll use the command resource to
run a curl command to inspect the website output, just as we did in Chapter 7 .
Search WWH ::




Custom Search