Information Technology Reference
In-Depth Information
describe
'<entity>'
do
it
'<description>'
expect(
resource
).to
matcher matcher_parameter
end
end
A
resource
(also known as a
subject
or
command
) is the first argument for an
expect
block,
and it expresses the “thing” to be tested. Testing frameworks such as Serverspec and
ChefSpec supply custom resource class implementations that perform a wide variety of
checks.
A
matcher
is used to define positive or negative expectations on a resource, via the
ex-
pect(…).to
and
expect(…).not_to
forms, respectively. These are also supplied as custom
class implementations in testing frameworks.
meter
tcp
to check to see if the website is listening on port 80 over TCP:
describe 'web site' do
it 'responsponds on port 80' do
expect(port 80).to be_listening 'tcp'
end
end
How did we know about this
port
resource and the
be_listening
matcher? We referred to
the Serverspec test framework documentation listing the resource and matcher classes it
provides. See the
Serverspec documentation
. As of this writing, click on the
Resource Types
link at the top of the page, and you will see links to all the Serverspec custom resources, as
shown in
Figure 16-7
.