Information Technology Reference
In-Depth Information
The purpose of the describe block is to group tests in a meaningful manner and describe the
entity or thing being tested. The description is just a string passed as a parameter to de-
scribe . This string serves as documentation for human beings to read in the test output. In
Example 16-4 , we used the following describe form to note that we are testing our website:
describe 'web site' do
<tests here>
end
NOTE
Under the hood, the RSpec DSL creates a Ruby class in which to group tests.
The actual tests are contained within an it block inside a describe , which needs to be in the
following form:
describe '<entity>' do
it '<description>'
<examples here>
end
end
The it block also accepts a string for documentation on the specific check that will be per-
formed. For example, in Example 16-4 we supplied the string responds on port 80 to in-
dicate that our test will be checking to see if the website responds on port 80, the standard
HTTP port:
describe 'web site' do
it 'responds on port 80' do
...
end
end
As of RSpec 3.0, the version of RSpec that ships with current versions of the Chef Develop-
ment Kit and Chef Client, the tests themselves should be written in expect form . Here's what
expect form looks like:
Search WWH ::




Custom Search