1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
---
layout: base
title: Testing Types
icon: fa fa-puzzle-piece
breadcrumbs:
-
name: Documentation
path: /documentation/
---
## Basic Test Structure
Tests for types should be placed in files under `spec/types`. For example, the
tests for the `sudoers_entry` type should be in
`spec/types/sudoers_entry_spec.rb`.
{% highlight ruby %}
require 'spec_helper'
describe '<type name>' do
# tests go here
end
{% endhighlight %}
## Configuring The Tests
{% include non_host_inputs.md %}
{% include facts_inputs.md %}
## Testing The Type
All type testing is currently done with the `be_valid_type` matcher.
### Testing Provider Selection
The automatic provider selection can be tested by chaining the `with_provider`
method on to the `be_valid_type` matcher.
{% highlight ruby %}
it { is_expected.to be_valid_type.with_provider('foo') }
{% endhighlight %}
### Testing Properties
Property names can be tested by chaining the `with_properties` method on to the
`be_valid_type` matcher.
{% highlight ruby %}
it { is_expected.to be_valid_type.with_properties('ensure') }
{% endhighlight %}
### Testing Parameters
Parameter names can be tested by chaining the `with_parameters` method on to
the `be_valid_type` matcher.
{% highlight ruby %}
it { is_expected.to be_valid_type.with_parameters('command', 'unless') }
{% endhighlight %}
### Testing provider features
Provider features can be tested by chaining the `with_features` method on to
the `be_valid_type` matcher.
{% highlight ruby %}
it { is_expected.to be_valid_type.with_features('refreshable') }
{% endhighlight %}
|