inspec/test
jtimberman d7fad68541 add "packages" resource
This pull request adds a packages resource so that we can check for pattern matches against all the packages on a system. This initially implements only dpkg support for debian-based platforms so we can cover this use case:

```ruby
describe packages(/^xserver-xorg.*/) do
  its("list") { should be_empty }
end
```

This uses FilterTable so we can supply additional queries, too.

```ruby
describe packages(/vi.+/).where { status != 'installed' } do
  its('statuses') { should be_empty }
end
```

Users can specify the name as a string or a regular expression. If it is a string, we will escape it and convert it to a regular expression to use in matching against the full returned list of packages. If it is a regular expression, we take that as is and use it to filter the results.

While some package management systems such as `dpkg` can take a shell glob argument to filter their results, we eschew this and require a regular expression to match multiple package names because we will need this to work across other platforms in the future. This means that the following:

```ruby
packages("vim")
```

Will return *all* the "vim" packages on the system. The `packages` resource will take `"vim"`, turn it into `/vim/`, and greedily match anything with "vim" in the name. To match only a single package named `vim`, it needs to be an anchored regular expression.

```ruby
packages(/^vim$/)
```

Signed-off-by: Joshua Timberman <joshua@chef.io>

Use entries instead of list

Added a few more tests and non installed package in output
Signed-off-by: Alex Pop <apop@chef.io>

fix lint

Signed-off-by: Alex Pop <apop@chef.io>

Signed-off-by: Joshua Timberman <joshua@chef.io>
2017-02-07 10:29:11 +00:00
..
cookbooks/os_prepare call ssh cookbook from prepare cookbook 2017-01-03 11:40:09 +01:00
functional use new devsec baseline 2017-01-25 20:22:38 +01:00
integration/default add fallback syntax for serverspec tests 2016-12-15 16:16:17 +01:00
resource promote cmp usage as it provides results with octal mode 2016-08-30 18:23:47 +01:00
unit add "packages" resource 2017-02-07 10:29:11 +00:00
docker_run.rb travis experiment: lower docker concurrency 2016-08-10 12:52:21 +01:00
docker_test.rb Load all dependent libraries, even if include_context isn't called 2016-09-04 20:55:20 +02:00
helper.rb add "packages" resource 2017-02-07 10:29:11 +00:00
test-extra.yaml split up tests for travis 2015-09-23 01:51:51 +02:00
test.yaml split up tests for travis 2015-09-23 01:51:51 +02:00