简体   繁体   中英

Correct directory structure for Puppet RSpec testing

I'm having some issues creating unit tests for my Puppet control repository. I mostly work with roles and profiles with the following directory structure:

[root@puppet]# tree site
site
├── profile
│   ├── files
│   │   └── demo-website
│   │       └── index.html
│   └── manifests
│       ├── base.pp
│       ├── ci_runner.pp
│       ├── docker.pp
│       ├── gitlab.pp
│       ├── logrotate.pp
│       └── website.pp
├── role
│   └── manifests
│       ├── gitlab_server.pp
│       └── nginx_webserver.pp

Where do I need to place my spec files and what are the correct filenames? I tried placing them here:

[root@puppet]# cat spec/classes/profile_ci_runner_spec.rb

require 'spec_helper'

describe 'profile::ci_runner' do
...

But I get an error:

Could not find class ::profile::ci_runner

The conventional place for a module's spec tests is in the module , with the spec/ directory in the module root. So site/profile/spec/classes/ci_runner_spec.rb , for example.

You could consider installing PDK , which can help you set up the structure and run tests, among other things.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM