Docs: Clarify Matchers page to speak about Universal matchers (#2754)

* Distinguish between universal and specialized matchers
* Make the table of contents clickable
* Add note about RSpec matchers, possibly regrettable

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
Signed-off-by: kgarmoe <kgarmoe@chef.io>
This commit is contained in:
Clinton Wolfe 2018-03-01 09:20:20 -05:00 committed by Jared Quick
parent f4ea53c3a5
commit 154ab8b05d

View file

@ -1,18 +1,21 @@
---
title: InSpec Matchers Reference
title: InSpec Universal Matchers Reference
---
# InSpec Matchers Reference
# InSpec Universal Matchers Reference
Inspec uses matchers to help compare resource values to expectations.
The following matchers are available:
InSpec uses matchers to help compare resource values to expectations. Matchers may be dedicated to a specific resource (such as the `aws_iam_root_user` resource's [`have_mfa_enabled`](https://www.inspec.io/docs/reference/resources/aws_iam_root_user/#have_mfa_enabled) matcher). If a matcher may be used on any resource type, it is _universal_.
* `be`
* `be_in`
* `cmp`
* `eq`
* `include`
* `match`
You may also use any matcher provided by [RSpec::Expectations](https://relishapp.com/rspec/rspec-expectations/docs), but those matchers are outside of InSpec's [scope of support](https://www.inspec.io/docs/reference/inspec_and_friends/#rspec).
The following InSpec-supported universal matchers are available:
* [`be`](#be) - make numeric comparisons
* [`be_in`](#be_in) - look for the property value in a list
* [`cmp`](#cmp) - general-use equality (try this first)
* [`eq`](#eq) - type-specific equality
* [`include`](#include) - look for an expected value in a list-valued property
* [`match`](#match) - look for patterns in text using regular expressions
<br>
@ -32,7 +35,7 @@ end
## cmp
Unlike `eq`, cmp is a matcher for less-restrictive comparisons. It will
Unlike `eq`, `cmp` is a matcher for less-restrictive comparisons. It will
try to fit the actual value to the type you are comparing it to. This is
meant to relieve the user from having to write type-casts and
resolutions.
@ -116,7 +119,7 @@ describe sshd_config do
end
```
It fails if types don't match. Please keep this in mind, when comparing
`eq` fails if types don't match. Please keep this in mind, when comparing
configuration entries that are numbers:
```ruby