diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-08-21 22:09:29 +0200 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-08-21 22:09:29 +0200 |
commit | 27514d58573ce1f844af4ea60afa72c7f58f1cd7 (patch) | |
tree | 4b16c31f73cb72435d03d5e105261143f8ca135f /Spec Testing.md | |
parent | 22675cd8dc75d8b8d4b0f818f5b093efbc364802 (diff) |
Diffstat (limited to 'Spec Testing.md')
-rw-r--r-- | Spec Testing.md | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Spec Testing.md b/Spec Testing.md new file mode 100644 index 0000000..5728aeb --- /dev/null +++ b/Spec Testing.md @@ -0,0 +1,41 @@ +[[Puppet]] +[Rspec Puppet](https://rspec-puppet.com/) + +--- + +```ruby +require 'spec_helper' + +describe '<name of the thing being tested>' do + # Your tests go in here +end +``` + +--- + +`is_expected.to` or `is_expected.to_not` + +defined types need a title: `let(:title) { 'title' }` +parameters: `let(:params) { { 'a' => 'b' } }` + +`contain_class('name')` or `contain_name` + +`contain_` < can be suffixed with anything, ie `contain_file`, `contain_exec`, `contain_class` or just `contain_apache__params` for defined types. +`::` in `apache::params` -> `apache__params` of a defined type. + +To test parameters chain `.with()` which contains a hash of expected paremeters. With can also be suffixed with the name of the param, ie `.with_ensure()`. + +`only_with` for ensuring that a argument is the only argument being set on given resource. + +--- + +> If a class is an fully qualified class reference (start with`::`) then in the test **do not** include the double colon to reference the class only use its name. + +```puppet +// manifest +class { '::tempest': } + +// test +is_expected.to contain_class('tempest') <- valid +is_expected.to contain_class('::tempest') <- invalid +```
\ No newline at end of file |