diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..ecb10a80 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# editorconfig.org + +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +tab_width = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.fixtures.yml b/.fixtures.yml index 5985d6b8..f6fbc107 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,34 +1,16 @@ fixtures: repositories: - stdlib: - repo: git://github.com/puppetlabs/puppetlabs-stdlib.git - ref: 4.1.0 - augeasproviders_core: - repo: git://github.com/hercules-team/augeasproviders_core.git - augeasproviders_apache: - repo: git://github.com/hercules-team/augeasproviders_apache.git - augeasproviders_grub: - repo: git://github.com/hercules-team/augeasproviders_grub.git - mount_providers: - repo: git://github.com/puppetlabs/puppetlabs-mount_providers.git - ref: 0.0.2 - augeasproviders_mounttab: - repo: git://github.com/hercules-team/augeasproviders_mounttab.git - augeasproviders_nagios: - repo: git://github.com/hercules-team/augeasproviders_nagios.git - augeasproviders_pam: - repo: git://github.com/hercules-team/augeasproviders_pam.git - augeasproviders_postgresql: - repo: git://github.com/hercules-team/augeasproviders_postgresql.git - augeasproviders_puppet: - repo: git://github.com/hercules-team/augeasproviders_puppet.git - augeasproviders_shellvar: - repo: git://github.com/hercules-team/augeasproviders_shellvar.git - augeasproviders_ssh: - repo: git://github.com/hercules-team/augeasproviders_ssh.git - augeasproviders_sysctl: - repo: git://github.com/hercules-team/augeasproviders_sysctl.git - augeasproviders_syslog: - repo: git://github.com/hercules-team/augeasproviders_syslog.git - symlinks: - "augeasproviders": "#{source_dir}" + stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git + augeasproviders_core: https://github.com/voxpupuli/puppet-augeasproviders_core.git + augeasproviders_apache: https://github.com/voxpupuli/puppet-augeasproviders_apache.git + augeasproviders_grub: https://github.com/voxpupuli/puppet-augeasproviders_grub.git + mount_providers: https://github.com/puppetlabs/puppetlabs-mount_providers.git + augeasproviders_mounttab: https://github.com/voxpupuli/puppet-augeasproviders_mounttab.git + augeasproviders_nagios: https://github.com/voxpupuli/puppet-augeasproviders_nagios.git + augeasproviders_pam: https://github.com/voxpupuli/puppet-augeasproviders_pam.git + augeasproviders_postgresql: https://github.com/voxpupuli/puppet-augeasproviders_postgresql.git + augeasproviders_puppet: https://github.com/voxpupuli/puppet-augeasproviders_puppet.git + augeasproviders_shellvar: https://github.com/voxpupuli/puppet-augeasproviders_shellvar.git + augeasproviders_ssh: https://github.com/voxpupuli/puppet-augeasproviders_ssh.git + augeasproviders_sysctl: https://github.com/voxpupuli/puppet-augeasproviders_sysctl.git + augeasproviders_syslog: https://github.com/voxpupuli/puppet-augeasproviders_syslog.git diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..daceb642 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,272 @@ +# Contribution guidelines + +## Table of contents + +* [Contributing](#contributing) +* [Writing proper commits - short version](#writing-proper-commits-short-version) +* [Writing proper commits - long version](#writing-proper-commits-long-version) +* [Dependencies](#dependencies) + * [Note for OS X users](#note-for-os-x-users) +* [The test matrix](#the-test-matrix) +* [Syntax and style](#syntax-and-style) +* [Running the unit tests](#running-the-unit-tests) +* [Unit tests in docker](#unit-tests-in-docker) +* [Integration tests](#integration-tests) + +This module has grown over time based on a range of contributions from +people using it. If you follow these contributing guidelines your patch +will likely make it into a release a little more quickly. + +## Contributing + +Please note that this project is released with a Contributor Code of Conduct. +By participating in this project you agree to abide by its terms. +[Contributor Code of Conduct](https://voxpupuli.org/coc/). + +* Fork the repo. +* Create a separate branch for your change. +* We only take pull requests with passing tests, and documentation. [GitHub Actions](https://docs.github.com/en/actions) run the tests for us. You can also execute them locally. This is explained [in a later section](#the-test-matrix). +* Checkout [our docs](https://voxpupuli.org/docs/reviewing_pr/) we use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html). They provide some guidance for new code that might help you before you submit a pull request. +* Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, please add a test. +* Squash your commits down into logical components. Make sure to rebase against our current master. +* Push the branch to your fork and submit a pull request. + +Please be prepared to repeat some of these steps as our contributors review your code. + +Also consider sending in your profile code that calls this component module as an acceptance test or provide it via an issue. This helps reviewers a lot to test your use case and prevents future regressions! + +## Writing proper commits - short version + +* Make commits of logical units. +* Check for unnecessary whitespace with "git diff --check" before committing. +* Commit using Unix line endings (check the settings around "crlf" in git-config(1)). +* Do not check in commented out code or unneeded files. +* The first line of the commit message should be a short description (50 characters is the soft limit, excluding ticket number(s)), and should skip the full stop. +* Associate the issue in the message. The first line should include the issue number in the form "(#XXXX) Rest of message". +* The body should provide a meaningful commit message, which: + *uses the imperative, present tense: `change`, not `changed` or `changes`. + * includes motivation for the change, and contrasts its implementation with the previous behavior. + * Make sure that you have tests for the bug you are fixing, or feature you are adding. + * Make sure the test suites passes after your commit: + * When introducing a new feature, make sure it is properly documented in the README.md + +## Writing proper commits - long version + + 1. Make separate commits for logically separate changes. + + Please break your commits down into logically consistent units + which include new or changed tests relevant to the rest of the + change. The goal of doing this is to make the diff easier to + read for whoever is reviewing your code. In general, the easier + your diff is to read, the more likely someone will be happy to + review it and get it into the code base. + + If you are going to refactor a piece of code, please do so as a + separate commit from your feature or bug fix changes. + + We also really appreciate changes that include tests to make + sure the bug is not re-introduced, and that the feature is not + accidentally broken. + + Describe the technical detail of the change(s). If your + description starts to get too long, that is a good sign that you + probably need to split up your commit into more finely grained + pieces. + + Commits which plainly describe the things which help + reviewers check the patch and future developers understand the + code are much more likely to be merged in with a minimum of + bike-shedding or requested changes. Ideally, the commit message + would include information, and be in a form suitable for + inclusion in the release notes for the version of Puppet that + includes them. + + Please also check that you are not introducing any trailing + whitespace or other "whitespace errors". You can do this by + running "git diff --check" on your changes before you commit. + + 2. Sending your patches + + To submit your changes via a GitHub pull request, we _highly_ + recommend that you have them on a topic branch, instead of + directly on `master`. + It makes things much easier to keep track of, especially if + you decide to work on another thing before your first change + is merged in. + + GitHub has some pretty good + [general documentation](http://help.github.com/) on using + their site. They also have documentation on + [creating pull requests](http://help.github.com/send-pull-requests/). + + In general, after pushing your topic branch up to your + repository on GitHub, you can switch to the branch in the + GitHub UI and click "Pull Request" towards the top of the page + in order to open a pull request. + + + 3. Update the related GitHub issue. + + If there is a GitHub issue associated with the change you + submitted, then you should update the ticket to include the + location of your branch, along with any other commentary you + may wish to make. + +## Dependencies + +The testing and development tools have a bunch of dependencies, +all managed by [bundler](http://bundler.io/) according to the +[Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions). + +By default the tests use a baseline version of Puppet. + +If you have Ruby 2.x or want a specific version of Puppet, +you must set an environment variable such as: + +```sh +export PUPPET_GEM_VERSION="~> 6.1.0" +``` + +You can install all needed gems for spec tests into the modules directory by +running: + +```sh +bundle config set --local path '.vendor/' +bundle config set --local without 'development system_tests release' +bundle install --jobs "$(nproc)" +``` + +If you also want to run acceptance tests: + +```sh +bundle config set --local path '.vendor/' +bundle config set --local without 'development release' +bundle config set --local with 'system_tests' +bundle install --jobs "$(nproc)" +``` + +Our all in one solution if you don't know if you need to install or update gems: + +```sh +bundle config set --local path '.vendor/' +bundle config set --local without 'development release' +bundle config set --local with 'system_tests' +bundle install --jobs "$(nproc)" +bundle update +bundle clean +``` + +As an alternative to the `--jobs "$(nproc)` parameter, you can set an +environment variable: + +```sh +BUNDLE_JOBS="$(nproc)" +``` + +### Note for OS X users + +`nproc` isn't a valid command under OS x. As an alternative, you can do: + +```sh +--jobs "$(sysctl -n hw.ncpu)" +``` + +## The test matrix + +### Syntax and style + +The test suite will run [Puppet Lint](http://puppet-lint.com/) and +[Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to +check various syntax and style things. You can run these locally with: + +```sh +bundle exec rake lint +bundle exec rake validate +``` + +It will also run some [Rubocop](http://batsov.com/rubocop/) tests +against it. You can run those locally ahead of time with: + +```sh +bundle exec rake rubocop +``` + +### Running the unit tests + +The unit test suite covers most of the code, as mentioned above please +add tests if you're adding new functionality. If you've not used +[rspec-puppet](http://rspec-puppet.com/) before then feel free to ask +about how best to test your new feature. + +To run the linter, the syntax checker and the unit tests: + +```sh +bundle exec rake test +``` + +To run your all the unit tests + +```sh +bundle exec rake spec +``` + +To run a specific spec test set the `SPEC` variable: + +```sh +bundle exec rake spec SPEC=spec/foo_spec.rb +``` + +#### Unit tests in docker + +Some people don't want to run the dependencies locally or don't want to install +ruby. We ship a Dockerfile that enables you to run all unit tests and linting. +You only need to run: + +```sh +docker build . +``` + +Please ensure that a docker daemon is running and that your user has the +permission to talk to it. You can specify a remote docker host by setting the +`DOCKER_HOST` environment variable. it will copy the content of the module into +the docker image. So it will not work if a Gemfile.lock exists. + +### Integration tests + +The unit tests just check the code runs, not that it does exactly what +we want on a real machine. For that we're using +[beaker](https://github.com/puppetlabs/beaker). + +This fires up a new virtual machine (using vagrant) and runs a series of +simple tests against it after applying the module. You can run this +with: + +```sh +BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker +``` + +or + +```sh +BEAKER_PUPPET_COLLECTION=none BEAKER_setfile=archlinux-64 bundle exec rake beaker +``` + +This latter example will use the distribution's own version of Puppet. + +You can replace the string `debian11` with any common operating system. +The following strings are known to work: + +* ubuntu2004 +* ubuntu2204 +* debian11 +* debian12 +* centos9 +* archlinux +* almalinux8 +* almalinux9 +* fedora36 + +For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests). + +The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb) +repository. diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..593e7aa8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,26 @@ + + +## Affected Puppet, Ruby, OS and module versions/distributions + +- Puppet: +- Ruby: +- Distribution: +- Module version: + +## How to reproduce (e.g Puppet code you use) + +## What are you seeing + +## What behaviour did you expect instead + +## Output log + +## Any additional information you'd like to impart diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..342807bc --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,20 @@ + +#### Pull Request (PR) description + + +#### This Pull Request (PR) fixes the following issues + diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000..f2d08d6b --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,6 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +skip-changelog: + - head-branch: ['^release-*', 'release'] diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 00000000..f5b5d7a9 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,42 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes + +changelog: + exclude: + labels: + - duplicate + - invalid + - modulesync + - question + - skip-changelog + - wont-fix + - wontfix + + categories: + - title: Breaking Changes 🛠 + labels: + - backwards-incompatible + + - title: New Features 🎉 + labels: + - enhancement + + - title: Bug Fixes 🐛 + labels: + - bug + + - title: Documentation Updates 📚 + labels: + - documentation + - docs + + - title: Dependency Updates ⬆️ + labels: + - dependencies + + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..8c32acf9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: CI + +# yamllint disable-line rule:truthy +on: + pull_request: {} + push: + branches: + - main + - master + +concurrency: + group: ${{ github.ref_name }} + cancel-in-progress: true + +jobs: + puppet: + name: Puppet + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v3 diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 00000000..73be88dc --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,18 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: "Pull Request Labeler" + +# yamllint disable-line rule:truthy +on: + pull_request_target: {} + +jobs: + labeler: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..4adf65cd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: Release + +# yamllint disable-line rule:truthy +on: + push: + tags: + - '*' + +jobs: + release: + name: Release + uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v3 + with: + allowed_owner: 'voxpupuli' + secrets: + # Configure secrets here: + # https://docs.github.com/en/actions/security-guides/encrypted-secrets + username: ${{ secrets.PUPPET_FORGE_USERNAME }} + api_key: ${{ secrets.PUPPET_FORGE_API_KEY }} + + create-github-release: + name: Create GitHub Release + runs-on: ubuntu-latest + steps: + - name: Create GitHub release + uses: voxpupuli/gha-create-a-github-release@v1 diff --git a/.gitignore b/.gitignore index 94145ab0..adea1b01 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,25 @@ -pkg -coverage -.bundle/ -.librarian/ -.tmp/ -modules/ -_site/ -spec/fixtures/manifests -spec/fixtures/modules -yardoc/ -.yardoc/ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -## Ruby -.rvmrc* -.rbenv* -.ruby-* - -## MAC OS -.DS_Store - -## TEXTMATE -*.tmproj -tmtags - -## EMACS -*~ -\#* -.\#* - -## VIM -*.swp -tags +/pkg/ +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/ +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.librarian/ +/Puppetfile.lock +*.iml +.*.sw? +/.yardoc/ +/Guardfile +bolt-debug.log +.rerun.json diff --git a/.msync.yml b/.msync.yml new file mode 100644 index 00000000..ac84b45d --- /dev/null +++ b/.msync.yml @@ -0,0 +1,5 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +modulesync_config_version: '9.3.0' diff --git a/.overcommit.yml b/.overcommit.yml new file mode 100644 index 00000000..4ed994cc --- /dev/null +++ b/.overcommit.yml @@ -0,0 +1,67 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ +# +# Hooks are only enabled if you take action. +# +# To enable the hooks run: +# +# ``` +# bundle exec overcommit --install +# # ensure .overcommit.yml does not harm to you and then +# bundle exec overcommit --sign +# ``` +# +# (it will manage the .git/hooks directory): +# +# Examples howto skip a test for a commit or push: +# +# ``` +# SKIP=RuboCop git commit +# SKIP=PuppetLint git commit +# SKIP=RakeTask git push +# ``` +# +# Don't invoke overcommit at all: +# +# ``` +# OVERCOMMIT_DISABLE=1 git commit +# ``` +# +# Read more about overcommit: https://github.com/brigade/overcommit +# +# To manage this config yourself in your module add +# +# ``` +# .overcommit.yml: +# unmanaged: true +# ``` +# +# to your modules .sync.yml config +--- +PreCommit: + RuboCop: + enabled: true + description: 'Runs rubocop on modified files only' + command: ['bundle', 'exec', 'rubocop'] + RakeTarget: + enabled: true + description: 'Runs lint on modified files only' + targets: + - 'lint' + command: ['bundle', 'exec', 'rake'] + YamlSyntax: + enabled: true + JsonSyntax: + enabled: true + TrailingWhitespace: + enabled: true + +PrePush: + RakeTarget: + enabled: true + description: 'Run rake targets' + targets: + - 'validate' + - 'test' + - 'rubocop' + command: ['bundle', 'exec', 'rake'] diff --git a/.pmtignore b/.pmtignore new file mode 100644 index 00000000..a9d37aa0 --- /dev/null +++ b/.pmtignore @@ -0,0 +1,39 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +/docs/ +/pkg/ +/Gemfile +/Gemfile.lock +/Gemfile.local +/vendor/ +/.vendor/ +/spec/ +/Rakefile +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.github/ +/.librarian/ +/Puppetfile.lock +/Puppetfile +*.iml +/.editorconfig +/.fixtures.yml +/.gitignore +/.msync.yml +/.overcommit.yml +/.pmtignore +/.rspec +/.rspec_parallel +/.rubocop.yml +/.sync.yml +.*.sw? +/.yardoc/ +/.yardopts +/Dockerfile +/HISTORY.md diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 00000000..05d28a26 --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1,6 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +--fail-on-warnings +--no-parameter_documentation-check +--no-parameter_types-check diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..53ac1898 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,6 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +inherit_gem: + voxpupuli-test: rubocop.yml diff --git a/.sync.yml b/.sync.yml new file mode 100644 index 00000000..c74bf2ef --- /dev/null +++ b/.sync.yml @@ -0,0 +1,6 @@ +--- +spec/spec_helper_acceptance.rb: + unmanaged: false +spec/spec_helper.rb: + spec_overrides: + - "Dir[\"#{__dir__}/support/**/*.rb\"].sort.each { |f| require f }" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 25b0d39e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,68 +0,0 @@ -language: ruby -rvm: - - 2.0.0 -notifications: - email: - - dcleal@redhat.com - - raphael.pinson@camptocamp.com -env: - # Most tests with oldest supported ruby-augeas - - PUPPET=2.7.0 RUBY_AUGEAS=0.3.0 AUGEAS=1.1.0 - - PUPPET=3.0.0 RUBY_AUGEAS=0.3.0 AUGEAS=1.1.0 - - PUPPET=3.2.0 RUBY_AUGEAS=0.3.0 AUGEAS=1.1.0 - - PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=1.1.0 - # Test the latest ruby-augeas (~>) - - PUPPET=3.2.0 RUBY_AUGEAS=0.5 - - PUPPET=3.4 RUBY_AUGEAS=0.5 - # Test other versions of Augeas - - PUPPET=2.7.0 RUBY_AUGEAS=0.3.0 AUGEAS=0.10.0 - - PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=0.10.0 - - PUPPET=2.7.0 RUBY_AUGEAS=0.3.0 AUGEAS=1.0.0 - - PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=1.0.0 - - PUPPET=2.7.0 RUBY_AUGEAS=0.3.0 AUGEAS=1.1.0 - - PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=1.1.0 - - PUPPET=2.7.0 RUBY_AUGEAS=0.3.0 AUGEAS=1.2.0 - - PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=1.2.0 - # Issue #83: test old Augeas with new lenses - - PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=1.0.0 LENSES=HEAD - - PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=1.1.0 LENSES=HEAD - - PUPPET=3.4 RUBY_AUGEAS=0.5 AUGEAS=1.0.0 LENSES=HEAD - - PUPPET=3.4 RUBY_AUGEAS=0.5 AUGEAS=1.1.0 LENSES=HEAD -matrix: - fast_finish: true - exclude: - # No support for Ruby 2.0 before Puppet 3.2.0 and ruby-augeas 0.5 - - rvm: 2.0.0 - env: PUPPET=2.7.0 RUBY_AUGEAS=0.3.0 AUGEAS=1.1.0 - - rvm: 2.0.0 - env: PUPPET=3.0.0 RUBY_AUGEAS=0.3.0 - - rvm: 2.0.0 - env: PUPPET=3.2.0 RUBY_AUGEAS=0.3.0 - - rvm: 2.0.0 - env: PUPPET=3.4 RUBY_AUGEAS=0.3.0 - - rvm: 2.0.0 - env: PUPPET=2.7.0 RUBY_AUGEAS=0.3.0 AUGEAS=0.10.0 - - rvm: 2.0.0 - env: PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=0.10.0 - - rvm: 2.0.0 - env: PUPPET=2.7.0 RUBY_AUGEAS=0.3.0 AUGEAS=1.0.0 - - rvm: 2.0.0 - env: PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=1.0.0 - - rvm: 2.0.0 - env: PUPPET=2.7.0 RUBY_AUGEAS=0.3.0 AUGEAS=1.1.0 - - rvm: 2.0.0 - env: PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=1.1.0 - - rvm: 2.0.0 - env: PUPPET=2.7.0 RUBY_AUGEAS=0.3.0 AUGEAS=1.2.0 - - rvm: 2.0.0 - env: PUPPET=3.0.0 RUBY_AUGEAS=0.3.0 AUGEAS=1.1.0 - - rvm: 2.0.0 - env: PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=1.2.0 - - rvm: 2.0.0 - env: PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=1.0.0 LENSES=HEAD - - rvm: 2.0.0 - env: PUPPET=3.4 RUBY_AUGEAS=0.3.0 AUGEAS=1.1.0 LENSES=HEAD -install: - - "travis_retry ./.travis.sh" -script: - - AUGEAS_LENS_LIB=augeas/lenses bundle exec rake diff --git a/.yardopts b/.yardopts deleted file mode 100644 index ae42c20b..00000000 --- a/.yardopts +++ /dev/null @@ -1,17 +0,0 @@ ---protected ---private ---verbose ---markup markdown ---readme README.md ---tag status ---transitive-tag status ---tag comment ---hide-tag comment ---tag dsl:"DSL" ---no-transitive-tag api ---template-path yardoc/templates ---api public ---api private ---hide-void-return ---output-dir yardoc/ -lib/augeasproviders/**/*.rb diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 5e3dff24..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,56 +0,0 @@ -# Contributing to augeasproviders - -[![Build Status](https://secure.travis-ci.org/hercules-team/augeasproviders.png?branch=master)](http://travis-ci.org/hercules-team/augeasproviders) - -## Writing tests - -Tests for a `typename` provider live at `spec/unit/puppet/typename_spec.rb` and -their corresponding fixture (starting file) under -`spec/fixture/unit/puppet/typename/`. - -Use an rspec context section per fixture and have multiple examples within the -section using it. - -Tests use real resources which are applied via the -`AugeasSpec::Fixtures::apply` method to a temporary file created from the -original fixture. Once applied, the temporary file is tested using one of -two methods: - -1. Load file with ruby-augeas (`aug_open` helper) and perform match/get queries -to test particular features of the tree. -1. Define whole or part of the tree in augparse `{ }` syntax and use `augparse` -or `augparse_filter` helpers to compare the file against the expected tree. - -The latter will be much easier and more robust as it will compare all aspects -of the tree, while the first might be needed for some edge cases (empty files -etc). - -See also this writeup on [testing techniques for Puppet providers using -Augeas](http://m0dlx.com/blog/Testing_techniques_for_Puppet_providers_using_Augeas.html) -which shows this process for augeasproviders. - -Execute `rake spec` in the root directory to run all tests. - -## Thoughts about testing methods - -After applying the resource, there are a few ways we could test the results of -the file. - -* use augparse? No API today, could generate module file and shell out. -* use Config::Augeas::Validator? Need to write separate rules, no rootdir - support and is Perl, not Ruby. -* use XML comparison? No ruby-augeas support for aug_to_xml. -* use ruby-augeas? Using this as we can test for specific nodes, values etc - and compare with rspec. -* use File.read + rspec? Comparing the whole file will be a problem if Augeas - lenses change whitespace. - -## Requirements - -Install bundler and run `bundle install` to get all gems required for -development or see the contents of Gemfile. - -## Patches - -Please send pull requests via GitHub, or patches via git send-email to the -author. diff --git a/Gemfile b/Gemfile index dff3d52e..2ac98f89 100644 --- a/Gemfile +++ b/Gemfile @@ -1,37 +1,32 @@ -source 'https://rubygems.org' +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -if ENV.key?('PUPPET') - puppetversion = "~> #{ENV['PUPPET']}" -else - puppetversion = ['>= 2.7'] -end -gem 'puppet', puppetversion - -if ENV.key?('RUBY_AUGEAS') - if ENV['RUBY_AUGEAS'] == '0.3.0' - # pre-0.4.1 versions aren't available on rubygems - rbaugversion = {:git => 'git://github.com/domcleal/ruby-augeas.git', :branch => '0.3.0-gem'} - else - rbaugversion = "~> #{ENV['RUBY_AUGEAS']}" - end -else - rbaugversion = ['~> 0.3'] +source ENV['GEM_SOURCE'] || 'https://rubygems.org' + +group :test do + gem 'voxpupuli-test', '~> 9.0', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false + gem 'puppet_metadata', '~> 4.0', :require => false end -gem 'ruby-augeas', rbaugversion group :development do - gem 'puppet-lint' - gem 'puppet-syntax' - gem 'puppetlabs_spec_helper', '>= 0.4.1' - gem 'rake' - gem 'rspec-puppet', :git => 'https://github.com/rodjek/rspec-puppet.git', :ref => '544b168' - gem 'simplecov' - gem 'yard' - gem 'redcarpet', '~> 2.0' - gem 'pry' - gem 'beaker', :require => false, :git => 'https://github.com/puppetlabs/beaker', :ref => 'dbac20fe9' - gem 'beaker-rspec', :require => false - gem 'vagrant-wrapper', :require => false - - gem 'coveralls' unless RUBY_VERSION =~ /^1\.8/ + gem 'guard-rake', :require => false + gem 'overcommit', '>= 0.39.1', :require => false end + +group :system_tests do + gem 'voxpupuli-acceptance', '~> 3.0', :require => false +end + +group :release do + gem 'voxpupuli-release', '~> 3.0', :require => false +end + +gem 'rake', :require => false +gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] + +puppetversion = ENV['PUPPET_GEM_VERSION'] || [">= 7.24", "< 9"] +gem 'puppet', puppetversion, :require => false, :groups => [:test] + +# vim: syntax=ruby diff --git a/README.md b/README.md index 2797711a..cce1225f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ # Features This module provides is a meta module which gathers all official augeasproviders -modules as dependencies. +modules as dependencies. Augeasproviders modules provide alternative Augeas-based providers for Puppet providers around config files, using the Augeas configuration library to read and modify them. @@ -46,7 +46,7 @@ The following example is the same as above but using a top-scope variable. $augeasproviders_sysctl_hash = { 'net.ipv4.ip_forward' => { 'value' => '1' }, } - + include augeasproviders::instances } diff --git a/Rakefile b/Rakefile index 8490143a..fc01f6b3 100644 --- a/Rakefile +++ b/Rakefile @@ -1,30 +1,44 @@ -require 'rubygems' -require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-syntax/tasks/puppet-syntax' -require 'puppet-lint/tasks/puppet-lint' -require 'yard' +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -exclude_paths = [ - "pkg/**/*", - "vendor/**/*", - "spec/**/*", -] - -task :default => [:spec, :yard, :syntax, :lint] +# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper), +# otherwise attempt to load it directly. +begin + require 'voxpupuli/test/rake' +rescue LoadError + begin + require 'puppetlabs_spec_helper/rake_tasks' + rescue LoadError + end +end -desc "Run acceptance tests" -RSpec::Core::RakeTask.new(:acceptance) do |t| - t.pattern = 'spec/acceptance' +# load optional tasks for acceptance +# only available if gem group releases is installed +begin + require 'voxpupuli/acceptance/rake' +rescue LoadError end -YARD::Rake::YardocTask.new do |t| - t.options = [] +# load optional tasks for releases +# only available if gem group releases is installed +begin + require 'voxpupuli/release/rake_tasks' +rescue LoadError + # voxpupuli-release not present +else + GCGConfig.user = 'voxpupuli' + GCGConfig.project = 'puppet-augeasproviders' end -# Disable puppet-lint checks -PuppetLint.configuration.send("disable_80chars") -PuppetLint.configuration.send("disable_class_inherits_from_params_class") +desc "Run main 'test' task and report merged results to coveralls" +task test_with_coveralls: [:test] do + if Dir.exist?(File.expand_path('../lib', __FILE__)) + require 'coveralls/rake/task' + Coveralls::RakeTask.new + Rake::Task['coveralls:push'].invoke + else + puts 'Skipping reporting to coveralls. Module has no lib dir' + end +end -# Ignore files outside this module -PuppetLint.configuration.ignore_paths = exclude_paths -PuppetSyntax.exclude_paths = exclude_paths +# vim: syntax=ruby diff --git a/docs/development.md b/docs/development.md index c46a73d2..f9815452 100644 --- a/docs/development.md +++ b/docs/development.md @@ -57,7 +57,7 @@ In the event that you need information from the resource itself in order to dete lens do |resource| resource[:lens] end - + ## Confining your provider @@ -74,7 +74,7 @@ The `augeasproviders` library can take care of automatically declaring some prov "$target/#{resource[:name]}" end -Using the `resource_path` method will automatically declare two provider methods: +Using the `resource_path` method will automatically declare two provider methods: * `exists?` (which checks if the resource path exists) * `destroy` (which removes the resource path and saves the tree) @@ -223,7 +223,7 @@ Augeas has two ways of representing array values in its trees, using either fix For this reason, property accessors offer 3 ways to manage arrays, using the `sublabel` option: * the values are all the nodes matching the path with the given label (`sublabel` not set), e.g. for `foo => ["bar", "baz"]`: - + attr_aug_accessor(:foo, :type => :array ) @@ -235,7 +235,7 @@ For this reason, property accessors offer 3 ways to manage arrays, using the `su { "foo" = "baz" } } * the values are sub-nodes of the path with the given label (`sublabel` set to the label of the sub-nodes), e.g. for `foo => ["bar", "baz"]`: - + attr_aug_accessor(:foo, :type => :array, :sublabel => 'sub' @@ -249,7 +249,7 @@ For this reason, property accessors offer 3 ways to manage arrays, using the `su { "sub" = "baz" } } } * the values are sequential entries under the path with the given label (`sublabel` set to `:seq`), e.g. for `foo => ["bar", "baz"]`: - + attr_aug_accessor(:foo, :type => :array, :sublabel => :seq @@ -267,7 +267,7 @@ In all cases, all existing values are purged before setting the target values. ##### Hash value -In the Augeas tree, hash values are represented by sub-nodes, with optional values (the `:sublabel` option is used to set the value node name). When no value is found in the tree, the accessor method will default to the value of the `:default` option. +In the Augeas tree, hash values are represented by sub-nodes, with optional values (the `:sublabel` option is used to set the value node name). When no value is found in the tree, the accessor method will default to the value of the `:default` option. For example, given `foo => { "a" => "bar", "b" => "baz" }`, with: diff --git a/manifests/instances.pp b/manifests/instances.pp index 39cdcb64..a3ab2830 100644 --- a/manifests/instances.pp +++ b/manifests/instances.pp @@ -20,7 +20,6 @@ Hash[String, Hash] $syslog_hash = {}, Hash[String, Hash] $resource_defaults = $augeasproviders::params::resource_defaults, ) inherits augeasproviders::params { - create_resources(apache_directive, $apache_directive_hash, $resource_defaults['apache_directive']) create_resources(apache_setenv, $apache_setenv_hash, $resource_defaults['apache_setenv']) create_resources(host, $host_hash, $resource_defaults['host']) @@ -37,5 +36,4 @@ create_resources(sshd_config_subsystem, $sshd_config_subsystem_hash, $resource_defaults['sshd_config_subsystem']) create_resources(sysctl, $sysctl_hash, $resource_defaults['sysctl']) create_resources(syslog, $syslog_hash, $resource_defaults['syslog']) - } diff --git a/manifests/params.pp b/manifests/params.pp index c7ed41d6..59f84060 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -12,7 +12,7 @@ 'apache_directive' => $defaults, 'apache_setenv' => $defaults, 'host' => $defaults, - 'kernel_parameter' => merge($defaults, {'provider' => undef}), + 'kernel_parameter' => merge($defaults, { 'provider' => undef }), 'mailalias' => $defaults, 'mounttab' => $defaults, 'nrpe_command' => $defaults, @@ -26,5 +26,4 @@ 'sysctl' => $defaults, 'syslog' => $defaults, } - } diff --git a/metadata.json b/metadata.json index 8ab6d8d5..052f597a 100644 --- a/metadata.json +++ b/metadata.json @@ -66,34 +66,27 @@ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "7", - "8", - "9" + "10", + "11" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "14.04", - "16.04", "18.04", - "18.10", "20.04" ] }, { "operatingsystem": "RedHat", "operatingsystemrelease": [ - "6", "7", - "8", - "9" + "8" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ - "6", "7", "8", "9" @@ -122,7 +115,6 @@ { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ - "6", "7", "8" ] diff --git a/spec/acceptance/augeasproviders_instances_spec.rb b/spec/acceptance/augeasproviders_instances_spec.rb index 3bb0a350..3c2f87b3 100644 --- a/spec/acceptance/augeasproviders_instances_spec.rb +++ b/spec/acceptance/augeasproviders_instances_spec.rb @@ -1,36 +1,40 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' describe 'augeasproviders::instances class' do context 'when sysctl_hash is defined' do - it 'should run successfully' do - pp =<<-EOS + it 'runs successfully' do + pp = <<-EOS class { 'augeasproviders::instances': sysctl_hash => { 'net.ipv4.ip_forward' => { 'value' => '1' } }, } EOS - apply_manifest(pp, :catch_failures => true) - expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + apply_manifest(pp, catch_failures: true) + expect(apply_manifest(pp, catch_failures: true).exit_code).to be_zero end describe linux_kernel_parameter('net.ipv4.ip_forward') do - its(:value) { should eq 1 } + its(:value) { is_expected.to eq 1 } end end context 'when augeasproviders_sysctl_hash is defined' do - it 'should run successfully' do - pp =<<-EOS + it 'runs successfully' do + pp = <<-EOS $augeasproviders_sysctl_hash = { 'net.ipv4.ip_forward' => { 'value' => '0' } } - class { 'augeasproviders::instances': } + class { 'augeasproviders::instances': + sysctl_hash => $augeasproviders_sysctl_hash, + } EOS - apply_manifest(pp, :catch_failures => true) - expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + apply_manifest(pp, catch_failures: true) + expect(apply_manifest(pp, catch_failures: true).exit_code).to be_zero end describe linux_kernel_parameter('net.ipv4.ip_forward') do - its(:value) { should eq 0 } + its(:value) { is_expected.to eq 0 } end end end diff --git a/spec/acceptance/nodesets/centos-65-x64.yml b/spec/acceptance/nodesets/centos-65-x64.yml deleted file mode 100644 index 1ef6615e..00000000 --- a/spec/acceptance/nodesets/centos-65-x64.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - centos-65-x64: - roles: - - master - platform: el-6-x86_64 - box : centos-65-x64-virtualbox-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box - hypervisor : vagrant -CONFIG: - log_level: debug - type: foss diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml deleted file mode 100644 index 1ef6615e..00000000 --- a/spec/acceptance/nodesets/default.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - centos-65-x64: - roles: - - master - platform: el-6-x86_64 - box : centos-65-x64-virtualbox-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box - hypervisor : vagrant -CONFIG: - log_level: debug - type: foss diff --git a/spec/classes/augeasproviders_instances_spec.rb b/spec/classes/augeasproviders_instances_spec.rb index ac1b5f30..5a4cb56d 100644 --- a/spec/classes/augeasproviders_instances_spec.rb +++ b/spec/classes/augeasproviders_instances_spec.rb @@ -1,30 +1,33 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'augeasproviders::instances' do - it { should create_class('augeasproviders::instances') } - it { should contain_class('augeasproviders::params') } + it { is_expected.to create_class('augeasproviders::instances') } + it { is_expected.to contain_class('augeasproviders::params') } context "when resource_defaults => 'foo'" do - let(:params) {{ :resource_defaults => 'foo' }} - it { expect { should create_class('augeasproviders::instances') }.to raise_error(Puppet::Error, /is not a Hash/) } + let(:params) { { resource_defaults: 'foo' } } + + it { is_expected.to compile.and_raise_error(%r{expects a Hash value, got String}) } end - [ - 'apache_directive', - 'apache_setenv', - 'host', - 'kernel_parameter', - 'mailalias', - 'mounttab', - 'nrpe_command', - 'pam', - 'pg_hba', - 'puppet_auth', - 'shellvar', - 'sshd_config', - 'sshd_config_subsystem', - 'sysctl', - 'syslog', + %w[ + apache_directive + apache_setenv + host + kernel_parameter + mailalias + mounttab + nrpe_command + pam + pg_hba + puppet_auth + shellvar + sshd_config + sshd_config_subsystem + sysctl + syslog ].each do |type| describe "#{type} instances" do include_context type diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 index 91cd6427..00000000 --- a/spec/spec.opts +++ /dev/null @@ -1,6 +0,0 @@ ---format -s ---colour ---loadby -mtime ---backtrace diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 95b4c2b8..5a5a9b3d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,44 +1,26 @@ -require 'pathname' -dir = Pathname.new(__FILE__).parent -$LOAD_PATH.unshift(dir, File.join(dir, 'fixtures/modules/augeasproviders_core/spec/lib'), File.join(dir, '..', 'lib')) +# frozen_string_literal: true -require 'rubygems' +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -require 'simplecov' -unless RUBY_VERSION =~ /^1\.8/ - require 'coveralls' - SimpleCov.formatter = Coveralls::SimpleCov::Formatter -end -SimpleCov.start do - add_group "AugeasProviders Libs", "/lib/augeasproviders/" - add_group "Puppet Types", "/lib/puppet/type/" - add_group "Puppet Providers", "/lib/puppet/provider/" - add_group "Augeas Spec Lib", "/spec/lib/" +# puppetlabs_spec_helper will set up coverage if the env variable is set. +# We want to do this if lib exists and it hasn't been explicitly set. +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__)) - add_filter "/spec/fixtures/" - add_filter "/spec/unit/" - add_filter "/spec/support/" -end +require 'voxpupuli/test/spec_helper' -require 'puppetlabs_spec_helper/module_spec_helper' -require 'augeas_spec' +RSpec.configure do |c| + c.facterdb_string_keys = false +end -Puppet[:modulepath] = File.join(dir, 'fixtures', 'modules') +add_mocked_facts! -# There's no real need to make this version dependent, but it helps find -# regressions in Puppet -# -# 1. Workaround for issue #16277 where default settings aren't initialised from -# a spec and so the libdir is never initialised (3.0.x) -# 2. Workaround for 2.7.20 that now only loads types for the current node -# environment (#13858) so Puppet[:modulepath] seems to get ignored -# 3. Workaround for 3.5 where context hasn't been configured yet, -# ticket https://tickets.puppetlabs.com/browse/MODULES-823 -# -ver = Gem::Version.new(Puppet.version.split('-').first) -if Gem::Requirement.new("~> 2.7.20") =~ ver || Gem::Requirement.new("~> 3.0.0") =~ ver || Gem::Requirement.new("~> 3.5") =~ ver - Dir["#{dir}/fixtures/modules/*/lib"].each { |l| $LOAD_PATH.unshift(l) } +if File.exist?(File.join(__dir__, 'default_module_facts.yml')) + facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) + facts&.each do |name, value| + add_custom_fact name.to_sym, value + end end -# Load all shared contexts and shared examples -Dir["#{dir}/support/**/*.rb"].sort.each {|f| require f} +Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f } +Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f } diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 5ab57b6d..2681792e 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,25 +1,10 @@ -require 'beaker-rspec/spec_helper' -require 'beaker-rspec/helpers/serverspec' +# frozen_string_literal: true -hosts.each do |host| - # Install Puppet - install_puppet -end +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) +require 'voxpupuli/acceptance/spec_helper_acceptance' - # Readable test descriptions - c.formatter = :documentation +configure_beaker(modules: :metadata) - # Configure all nodes in nodeset - c.before :suite do - # Install module and dependencies - puppet_module_install(:source => proj_root, :module_name => 'augeasproviders') - - hosts.each do |host| - on host, puppet('module', 'install', 'puppetlabs/stdlib'), { :acceptable_exit_codes => [0,1] } - end - end -end \ No newline at end of file +Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f } diff --git a/spec/support/apache_directive.rb b/spec/support/apache_directive.rb index 8d02eff2..ca704877 100644 --- a/spec/support/apache_directive.rb +++ b/spec/support/apache_directive.rb @@ -1,35 +1,36 @@ +# frozen_string_literal: true + shared_examples_for 'apache_directive resource' do - it { should have_apache_directive_resource_count(1) } + it { is_expected.to have_apache_directive_resource_count(1) } it do - should contain_apache_directive('StartServers').only_with({ - 'name' => 'StartServers', - 'ensure' => 'present', - 'args' => '3', - 'target' => '/etc/httpd/conf/httpd.conf', - 'provider' => 'augeas', - }) + expect(subject).to contain_apache_directive('StartServers').only_with({ + 'name' => 'StartServers', + 'ensure' => 'present', + 'args' => '3', + 'target' => '/etc/httpd/conf/httpd.conf', + 'provider' => 'augeas', + }) end end shared_context 'apache_directive' do - it { should have_apache_directive_resource_count(0) } + it { is_expected.to have_apache_directive_resource_count(0) } let :example_params do - {'StartServers' => {'args' => '3', 'target' => '/etc/httpd/conf/httpd.conf'}} + { 'StartServers' => { 'args' => '3', 'target' => '/etc/httpd/conf/httpd.conf' } } end - context "when apache_directive_hash is a Hash" do - let(:params) {{ :apache_directive_hash => example_params }} - let(:facts) {{}} + context 'when apache_directive_hash is a Hash' do + let(:params) { { apache_directive_hash: example_params } } + let(:facts) { {} } include_examples 'apache_directive resource' end - context "when ::augeasproviders_apache_directive_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_apache_directive_hash => example_params }} - + context 'when ::augeasproviders_apache_directive_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_apache_directive_hash: example_params } } include_examples 'apache_directive resource' end diff --git a/spec/support/apache_setenv.rb b/spec/support/apache_setenv.rb index 5f4dcd95..50db5a9c 100644 --- a/spec/support/apache_setenv.rb +++ b/spec/support/apache_setenv.rb @@ -1,34 +1,35 @@ +# frozen_string_literal: true + shared_examples_for 'apache_setenv resource' do - it { should have_apache_setenv_resource_count(1) } + it { is_expected.to have_apache_setenv_resource_count(1) } it do - should contain_apache_setenv('FOO').only_with({ - 'name' => 'FOO', - 'ensure' => 'present', - 'value' => 'bar', - 'provider' => 'augeas', - }) + expect(subject).to contain_apache_setenv('FOO').only_with({ + 'name' => 'FOO', + 'ensure' => 'present', + 'value' => 'bar', + 'provider' => 'augeas', + }) end end shared_context 'apache_setenv' do - it { should have_apache_setenv_resource_count(0) } + it { is_expected.to have_apache_setenv_resource_count(0) } let :example_params do - {'FOO' => {'value' => 'bar'}} + { 'FOO' => { 'value' => 'bar' } } end - context "when apache_setenv_hash is a Hash" do - let(:params) {{ :apache_setenv_hash => example_params }} - let(:facts) {{}} + context 'when apache_setenv_hash is a Hash' do + let(:params) { { apache_setenv_hash: example_params } } + let(:facts) { {} } include_examples 'apache_setenv resource' end - context "when ::augeasproviders_apache_setenv_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_apache_setenv_hash => example_params }} - + context 'when ::augeasproviders_apache_setenv_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_apache_setenv_hash: example_params } } include_examples 'apache_setenv resource' end diff --git a/spec/support/host.rb b/spec/support/host.rb index 1de346d9..d712cd47 100644 --- a/spec/support/host.rb +++ b/spec/support/host.rb @@ -1,33 +1,35 @@ +# frozen_string_literal: true + shared_examples_for 'host resource' do - it { should have_host_resource_count(1) } + it { is_expected.to have_host_resource_count(1) } it do - should contain_host('foo').only_with({ - 'name' => 'foo', - 'ensure' => 'present', - 'ip' => '192.168.1.1', - 'provider' => 'augeas', - }) + expect(subject).to contain_host('foo').only_with({ + 'name' => 'foo', + 'ensure' => 'present', + 'ip' => '192.168.1.1', + 'provider' => 'augeas', + }) end end shared_context 'host' do - it { should have_host_resource_count(0) } + it { is_expected.to have_host_resource_count(0) } let :example_params do - {'foo' => {'ip' => '192.168.1.1'}} + { 'foo' => { 'ip' => '192.168.1.1' } } end - context "when host_hash is a Hash" do - let(:params) {{ :host_hash => example_params }} - let(:facts) {{}} + context 'when host_hash is a Hash' do + let(:params) { { host_hash: example_params } } + let(:facts) { {} } include_examples 'host resource' end - context "when ::augeasproviders_host_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_host_hash => example_params }} + context 'when ::augeasproviders_host_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_host_hash: example_params } } include_examples 'host resource' end diff --git a/spec/support/kernel_parameter.rb b/spec/support/kernel_parameter.rb index cfe8961d..3ae9e7b9 100644 --- a/spec/support/kernel_parameter.rb +++ b/spec/support/kernel_parameter.rb @@ -1,32 +1,34 @@ +# frozen_string_literal: true + shared_examples_for 'kernel_parameter resource' do - it { should have_kernel_parameter_resource_count(1) } + it { is_expected.to have_kernel_parameter_resource_count(1) } it do - should contain_kernel_parameter('elevator').only_with({ - 'name' => 'elevator', - 'ensure' => 'present', - 'value' => 'deadline', - }) + expect(subject).to contain_kernel_parameter('elevator').only_with({ + 'name' => 'elevator', + 'ensure' => 'present', + 'value' => 'deadline', + }) end end shared_context 'kernel_parameter' do - it { should have_kernel_parameter_resource_count(0) } + it { is_expected.to have_kernel_parameter_resource_count(0) } let :example_params do - {'elevator' => {'value' => 'deadline'}} + { 'elevator' => { 'value' => 'deadline' } } end - context "when kernel_parameter_hash is a Hash" do - let(:params) {{ :kernel_parameter_hash => example_params }} - let(:facts) {{}} + context 'when kernel_parameter_hash is a Hash' do + let(:params) { { kernel_parameter_hash: example_params } } + let(:facts) { {} } include_examples 'kernel_parameter resource' end - context "when ::augeasproviders_kernel_parameter_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_kernel_parameter_hash => example_params }} + context 'when ::augeasproviders_kernel_parameter_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_kernel_parameter_hash: example_params } } include_examples 'kernel_parameter resource' end diff --git a/spec/support/mailalias.rb b/spec/support/mailalias.rb index 6363716d..8af62300 100644 --- a/spec/support/mailalias.rb +++ b/spec/support/mailalias.rb @@ -1,33 +1,35 @@ +# frozen_string_literal: true + shared_examples_for 'mailalias resource' do - it { should have_mailalias_resource_count(1) } + it { is_expected.to have_mailalias_resource_count(1) } it do - should contain_mailalias('foo').only_with({ - 'name' => 'foo', - 'ensure' => 'present', - 'recipient' => 'bar', - 'provider' => 'augeas', - }) + expect(subject).to contain_mailalias('foo').only_with({ + 'name' => 'foo', + 'ensure' => 'present', + 'recipient' => 'bar', + 'provider' => 'augeas', + }) end end shared_context 'mailalias' do - it { should have_mailalias_resource_count(0) } + it { is_expected.to have_mailalias_resource_count(0) } let :example_params do - {'foo' => {'recipient' => 'bar'}} + { 'foo' => { 'recipient' => 'bar' } } end - context "when mailalias_hash is a Hash" do - let(:params) {{ :mailalias_hash => example_params }} - let(:facts) {{}} + context 'when mailalias_hash is a Hash' do + let(:params) { { mailalias_hash: example_params } } + let(:facts) { {} } include_examples 'mailalias resource' end - context "when ::augeasproviders_mailalias_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_mailalias_hash => example_params }} + context 'when ::augeasproviders_mailalias_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_mailalias_hash: example_params } } include_examples 'mailalias resource' end diff --git a/spec/support/mounttab.rb b/spec/support/mounttab.rb index 1118a6ed..baf4a965 100644 --- a/spec/support/mounttab.rb +++ b/spec/support/mounttab.rb @@ -1,35 +1,37 @@ +# frozen_string_literal: true + shared_examples_for 'mounttab resource' do - it { should have_mounttab_resource_count(1) } + it { is_expected.to have_mounttab_resource_count(1) } it do - should contain_mounttab('/mnt').only_with({ - 'name' => '/mnt', - 'ensure' => 'present', - 'device' => '/dev/myvg/mytest', - 'fstype' => 'ext4', - 'options' => 'defaults', - 'provider' => 'augeas', - }) + expect(subject).to contain_mounttab('/mnt').only_with({ + 'name' => '/mnt', + 'ensure' => 'present', + 'device' => '/dev/myvg/mytest', + 'fstype' => 'ext4', + 'options' => 'defaults', + 'provider' => 'augeas', + }) end end shared_context 'mounttab' do - it { should have_mounttab_resource_count(0) } + it { is_expected.to have_mounttab_resource_count(0) } let :example_params do - {'/mnt' => {'device' => '/dev/myvg/mytest', 'fstype' => 'ext4', 'options' => 'defaults'}} + { '/mnt' => { 'device' => '/dev/myvg/mytest', 'fstype' => 'ext4', 'options' => 'defaults' } } end - context "when mounttab_hash is a Hash" do - let(:params) {{ :mounttab_hash => example_params }} - let(:facts) {{}} + context 'when mounttab_hash is a Hash' do + let(:params) { { mounttab_hash: example_params } } + let(:facts) { {} } include_examples 'mounttab resource' end - context "when ::augeasproviders_mounttab_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_mounttab_hash => example_params }} + context 'when ::augeasproviders_mounttab_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_mounttab_hash: example_params } } include_examples 'mounttab resource' end diff --git a/spec/support/nrpe_command.rb b/spec/support/nrpe_command.rb index 259f6119..a639654b 100644 --- a/spec/support/nrpe_command.rb +++ b/spec/support/nrpe_command.rb @@ -1,33 +1,35 @@ +# frozen_string_literal: true + shared_examples_for 'nrpe_command resource' do - it { should have_nrpe_command_resource_count(1) } + it { is_expected.to have_nrpe_command_resource_count(1) } it do - should contain_nrpe_command('check_foo').only_with({ - 'name' => 'check_foo', - 'ensure' => 'present', - 'command' => '/usr/bin/check_foo', - 'provider' => 'augeas', - }) + expect(subject).to contain_nrpe_command('check_foo').only_with({ + 'name' => 'check_foo', + 'ensure' => 'present', + 'command' => '/usr/bin/check_foo', + 'provider' => 'augeas', + }) end end shared_context 'nrpe_command' do - it { should have_nrpe_command_resource_count(0) } + it { is_expected.to have_nrpe_command_resource_count(0) } let :example_params do - {'check_foo' => {'command' => '/usr/bin/check_foo'}} + { 'check_foo' => { 'command' => '/usr/bin/check_foo' } } end - context "when nrpe_command_hash is a Hash" do - let(:params) {{ :nrpe_command_hash => example_params }} - let(:facts) {{}} + context 'when nrpe_command_hash is a Hash' do + let(:params) { { nrpe_command_hash: example_params } } + let(:facts) { {} } include_examples 'nrpe_command resource' end - context "when ::augeasproviders_nrpe_command_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_nrpe_command_hash => example_params }} + context 'when ::augeasproviders_nrpe_command_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_nrpe_command_hash: example_params } } include_examples 'nrpe_command resource' end diff --git a/spec/support/pam.rb b/spec/support/pam.rb index 59ac2f9c..bbe28eff 100644 --- a/spec/support/pam.rb +++ b/spec/support/pam.rb @@ -1,39 +1,41 @@ +# frozen_string_literal: true + shared_examples_for 'pam resource' do - it { should have_pam_resource_count(1) } + it { is_expected.to have_pam_resource_count(1) } it do - should contain_pam('Add pam_test.so to auth for system-auth').only_with({ - 'name' => 'Add pam_test.so to auth for system-auth', - 'service' => 'system-auth', - 'type' => 'auth', - 'control' => 'sufficient', - 'module' => 'pam_test.so', - 'arguments' => 'test_me_out', - 'position' => 'before module pam_deny.so', - 'target' => '/etc/pam.d/system-auth', - 'provider' => 'augeas', - 'ensure' => 'present', - }) + expect(subject).to contain_pam('Add pam_test.so to auth for system-auth').only_with({ + 'name' => 'Add pam_test.so to auth for system-auth', + 'service' => 'system-auth', + 'type' => 'auth', + 'control' => 'sufficient', + 'module' => 'pam_test.so', + 'arguments' => 'test_me_out', + 'position' => 'before module pam_deny.so', + 'target' => '/etc/pam.d/system-auth', + 'provider' => 'augeas', + 'ensure' => 'present', + }) end end shared_context 'pam' do - it { should have_pam_resource_count(0) } + it { is_expected.to have_pam_resource_count(0) } let :example_params do - { 'Add pam_test.so to auth for system-auth' => {'service' => 'system-auth', 'type' => 'auth', 'control' => 'sufficient', 'module' => 'pam_test.so', 'arguments' => 'test_me_out', 'position' => 'before module pam_deny.so', 'target' => '/etc/pam.d/system-auth', 'provider' => 'augeas', 'ensure' => 'present'}} + { 'Add pam_test.so to auth for system-auth' => { 'service' => 'system-auth', 'type' => 'auth', 'control' => 'sufficient', 'module' => 'pam_test.so', 'arguments' => 'test_me_out', 'position' => 'before module pam_deny.so', 'target' => '/etc/pam.d/system-auth', 'provider' => 'augeas', 'ensure' => 'present' } } end - context "when pam_hash is a Hash" do - let(:params) {{ :pam_hash => example_params }} - let(:facts) {{}} + context 'when pam_hash is a Hash' do + let(:params) { { pam_hash: example_params } } + let(:facts) { {} } include_examples 'pam resource' end - context "when ::augeasproviders_pam_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_pam_hash => example_params }} + context 'when ::augeasproviders_pam_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_pam_hash: example_params } } include_examples 'pam resource' end diff --git a/spec/support/pg_hba.rb b/spec/support/pg_hba.rb index 3b5aed84..e9fae481 100644 --- a/spec/support/pg_hba.rb +++ b/spec/support/pg_hba.rb @@ -1,37 +1,39 @@ +# frozen_string_literal: true + shared_examples_for 'pg_hba resource' do - it { should have_pg_hba_resource_count(1) } + it { is_expected.to have_pg_hba_resource_count(1) } it do - should contain_pg_hba('Default entry').only_with({ - 'name' => 'Default entry', - 'type' => 'local', - 'user' => 'all', - 'database' => 'all', - 'ensure' => 'present', - 'method' => 'md5', - 'target' => '/etc/postgresql/9.1/main/pg_hba.conf', - 'provider' => 'augeas', - }) + expect(subject).to contain_pg_hba('Default entry').only_with({ + 'name' => 'Default entry', + 'type' => 'local', + 'user' => 'all', + 'database' => 'all', + 'ensure' => 'present', + 'method' => 'md5', + 'target' => '/etc/postgresql/9.1/main/pg_hba.conf', + 'provider' => 'augeas', + }) end end shared_context 'pg_hba' do - it { should have_pg_hba_resource_count(0) } + it { is_expected.to have_pg_hba_resource_count(0) } let :example_params do - {'Default entry' => {'type' => 'local', 'user' => 'all', 'database' => 'all', 'method' => 'md5', 'target' => '/etc/postgresql/9.1/main/pg_hba.conf'}} + { 'Default entry' => { 'type' => 'local', 'user' => 'all', 'database' => 'all', 'method' => 'md5', 'target' => '/etc/postgresql/9.1/main/pg_hba.conf' } } end - context "when pg_hba_hash is a Hash" do - let(:params) {{ :pg_hba_hash => example_params }} - let(:facts) {{}} + context 'when pg_hba_hash is a Hash' do + let(:params) { { pg_hba_hash: example_params } } + let(:facts) { {} } include_examples 'pg_hba resource' end - context "when ::augeasproviders_pg_hba_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_pg_hba_hash => example_params }} + context 'when ::augeasproviders_pg_hba_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_pg_hba_hash: example_params } } include_examples 'pg_hba resource' end diff --git a/spec/support/puppet_auth.rb b/spec/support/puppet_auth.rb index 84ee0147..3632fdb1 100644 --- a/spec/support/puppet_auth.rb +++ b/spec/support/puppet_auth.rb @@ -1,34 +1,36 @@ +# frozen_string_literal: true + shared_examples_for 'puppet_auth resource' do - it { should have_puppet_auth_resource_count(1) } + it { is_expected.to have_puppet_auth_resource_count(1) } it do - should contain_puppet_auth('Deny /facts').only_with({ - 'name' => 'Deny /facts', - 'ensure' => 'present', - 'path' => '/facts', - 'authenticated' => 'any', - 'provider' => 'augeas', - }) + expect(subject).to contain_puppet_auth('Deny /facts').only_with({ + 'name' => 'Deny /facts', + 'ensure' => 'present', + 'path' => '/facts', + 'authenticated' => 'any', + 'provider' => 'augeas', + }) end end shared_context 'puppet_auth' do - it { should have_puppet_auth_resource_count(0) } + it { is_expected.to have_puppet_auth_resource_count(0) } let :example_params do - {'Deny /facts' => {'path' => '/facts', 'authenticated' => 'any'}} + { 'Deny /facts' => { 'path' => '/facts', 'authenticated' => 'any' } } end - context "when puppet_auth_hash is a Hash" do - let(:params) {{ :puppet_auth_hash => example_params }} - let(:facts) {{}} + context 'when puppet_auth_hash is a Hash' do + let(:params) { { puppet_auth_hash: example_params } } + let(:facts) { {} } include_examples 'puppet_auth resource' end - context "when ::augeasproviders_puppet_auth_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_puppet_auth_hash => example_params }} + context 'when ::augeasproviders_puppet_auth_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_puppet_auth_hash: example_params } } include_examples 'puppet_auth resource' end diff --git a/spec/support/shellvar.rb b/spec/support/shellvar.rb index 0095b3ef..c5ed98e4 100644 --- a/spec/support/shellvar.rb +++ b/spec/support/shellvar.rb @@ -1,35 +1,37 @@ +# frozen_string_literal: true + shared_examples_for 'shellvar resource' do - it { should have_shellvar_resource_count(1) } + it { is_expected.to have_shellvar_resource_count(1) } it do - should contain_shellvar('HOSTNAME').only_with({ - 'variable' => 'HOSTNAME', - 'name' => 'HOSTNAME', - 'ensure' => 'present', - 'target' => '/etc/sysconfig/network', - 'value' => 'host.example.com', - 'provider' => 'augeas', - }) + expect(subject).to contain_shellvar('HOSTNAME').only_with({ + 'variable' => 'HOSTNAME', + 'name' => 'HOSTNAME', + 'ensure' => 'present', + 'target' => '/etc/sysconfig/network', + 'value' => 'host.example.com', + 'provider' => 'augeas', + }) end end shared_context 'shellvar' do - it { should have_shellvar_resource_count(0) } + it { is_expected.to have_shellvar_resource_count(0) } let :example_params do - {'HOSTNAME' => {'target' => '/etc/sysconfig/network', 'value' => 'host.example.com'}} + { 'HOSTNAME' => { 'target' => '/etc/sysconfig/network', 'value' => 'host.example.com' } } end - context "when shellvar_hash is a Hash" do - let(:params) {{ :shellvar_hash => example_params }} - let(:facts) {{}} + context 'when shellvar_hash is a Hash' do + let(:params) { { shellvar_hash: example_params } } + let(:facts) { {} } include_examples 'shellvar resource' end - context "when ::augeasproviders_shellvar_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_shellvar_hash => example_params }} + context 'when ::augeasproviders_shellvar_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_shellvar_hash: example_params } } include_examples 'shellvar resource' end diff --git a/spec/support/ssh_config.rb b/spec/support/ssh_config.rb index 0764ba25..23f0b462 100644 --- a/spec/support/ssh_config.rb +++ b/spec/support/ssh_config.rb @@ -1,33 +1,35 @@ +# frozen_string_literal: true + shared_examples_for 'ssh_config resource' do - it { should have_ssh_config_resource_count(1) } + it { is_expected.to have_ssh_config_resource_count(1) } it do - should contain_ssh_config('HashKnownHosts').only_with({ - 'name' => 'HashKnownHosts', - 'ensure' => 'present', - 'value' => 'yes', - 'provider' => 'augeas', - }) + expect(subject).to contain_ssh_config('HashKnownHosts').only_with({ + 'name' => 'HashKnownHosts', + 'ensure' => 'present', + 'value' => 'yes', + 'provider' => 'augeas', + }) end end shared_context 'ssh_config' do - it { should have_ssh_config_resource_count(0) } + it { is_expected.to have_ssh_config_resource_count(0) } let :example_params do - {'HashKnownHosts' => {'value' => 'yes'}} + { 'HashKnownHosts' => { 'value' => 'yes' } } end - context "when ssh_config_hash is a Hash" do - let(:params) {{ :ssh_config_hash => example_params }} - let(:facts) {{}} + context 'when ssh_config_hash is a Hash' do + let(:params) { { ssh_config_hash: example_params } } + let(:facts) { {} } include_examples 'ssh_config resource' end - context "when ::augeasproviders_ssh_config_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_ssh_config_hash => example_params }} + context 'when ::augeasproviders_ssh_config_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_ssh_config_hash: example_params } } include_examples 'ssh_config resource' end diff --git a/spec/support/sshd_config.rb b/spec/support/sshd_config.rb index fee7a34e..4961e415 100644 --- a/spec/support/sshd_config.rb +++ b/spec/support/sshd_config.rb @@ -1,33 +1,35 @@ +# frozen_string_literal: true + shared_examples_for 'sshd_config resource' do - it { should have_sshd_config_resource_count(1) } + it { is_expected.to have_sshd_config_resource_count(1) } it do - should contain_sshd_config('PermitRootLogin').only_with({ - 'name' => 'PermitRootLogin', - 'ensure' => 'present', - 'value' => 'yes', - 'provider' => 'augeas', - }) + expect(subject).to contain_sshd_config('PermitRootLogin').only_with({ + 'name' => 'PermitRootLogin', + 'ensure' => 'present', + 'value' => 'yes', + 'provider' => 'augeas', + }) end end shared_context 'sshd_config' do - it { should have_sshd_config_resource_count(0) } + it { is_expected.to have_sshd_config_resource_count(0) } let :example_params do - {'PermitRootLogin' => {'value' => 'yes'}} + { 'PermitRootLogin' => { 'value' => 'yes' } } end - context "when sshd_config_hash is a Hash" do - let(:params) {{ :sshd_config_hash => example_params }} - let(:facts) {{}} + context 'when sshd_config_hash is a Hash' do + let(:params) { { sshd_config_hash: example_params } } + let(:facts) { {} } include_examples 'sshd_config resource' end - context "when ::augeasproviders_sshd_config_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_sshd_config_hash => example_params }} + context 'when ::augeasproviders_sshd_config_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_sshd_config_hash: example_params } } include_examples 'sshd_config resource' end diff --git a/spec/support/sshd_config_subsystem.rb b/spec/support/sshd_config_subsystem.rb index 75848bba..3a1b0e6a 100644 --- a/spec/support/sshd_config_subsystem.rb +++ b/spec/support/sshd_config_subsystem.rb @@ -1,33 +1,35 @@ +# frozen_string_literal: true + shared_examples_for 'sshd_config_subsystem resource' do - it { should have_sshd_config_subsystem_resource_count(1) } + it { is_expected.to have_sshd_config_subsystem_resource_count(1) } it do - should contain_sshd_config_subsystem('sftp').only_with({ - 'name' => 'sftp', - 'ensure' => 'present', - 'command' => '/usr/lib/openssh/sftp-server', - 'provider' => 'augeas', - }) + expect(subject).to contain_sshd_config_subsystem('sftp').only_with({ + 'name' => 'sftp', + 'ensure' => 'present', + 'command' => '/usr/lib/openssh/sftp-server', + 'provider' => 'augeas', + }) end end shared_context 'sshd_config_subsystem' do - it { should have_sshd_config_subsystem_resource_count(0) } + it { is_expected.to have_sshd_config_subsystem_resource_count(0) } let :example_params do - {'sftp' => {'command' => '/usr/lib/openssh/sftp-server'}} + { 'sftp' => { 'command' => '/usr/lib/openssh/sftp-server' } } end - context "when sshd_config_subsystem_hash is a Hash" do - let(:params) {{ :sshd_config_subsystem_hash => example_params }} - let(:facts) {{}} + context 'when sshd_config_subsystem_hash is a Hash' do + let(:params) { { sshd_config_subsystem_hash: example_params } } + let(:facts) { {} } include_examples 'sshd_config_subsystem resource' end - context "when ::augeasproviders_sshd_config_subsystem_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_sshd_config_subsystem_hash => example_params }} + context 'when ::augeasproviders_sshd_config_subsystem_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_sshd_config_subsystem_hash: example_params } } include_examples 'sshd_config_subsystem resource' end diff --git a/spec/support/sysctl.rb b/spec/support/sysctl.rb index 316a589c..2a30961d 100644 --- a/spec/support/sysctl.rb +++ b/spec/support/sysctl.rb @@ -1,33 +1,35 @@ +# frozen_string_literal: true + shared_examples_for 'sysctl resource' do - it { should have_sysctl_resource_count(1) } + it { is_expected.to have_sysctl_resource_count(1) } it do - should contain_sysctl('vm.foo').only_with({ - 'name' => 'vm.foo', - 'ensure' => 'present', - 'value' => '0', - 'provider' => 'augeas', - }) + expect(subject).to contain_sysctl('vm.foo').only_with({ + 'name' => 'vm.foo', + 'ensure' => 'present', + 'value' => '0', + 'provider' => 'augeas', + }) end end shared_context 'sysctl' do - it { should have_sysctl_resource_count(0) } + it { is_expected.to have_sysctl_resource_count(0) } let :example_params do - {'vm.foo' => {'value' => '0'}} + { 'vm.foo' => { 'value' => '0' } } end - context "when sysctl_hash is a Hash" do - let(:params) {{ :sysctl_hash => example_params }} - let(:facts) {{}} + context 'when sysctl_hash is a Hash' do + let(:params) { { sysctl_hash: example_params } } + let(:facts) { {} } include_examples 'sysctl resource' end - context "when ::augeasproviders_sysctl_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_sysctl_hash => example_params }} + context 'when ::augeasproviders_sysctl_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_sysctl_hash: example_params } } include_examples 'sysctl resource' end diff --git a/spec/support/syslog.rb b/spec/support/syslog.rb index 9cbac7c8..1077baa2 100644 --- a/spec/support/syslog.rb +++ b/spec/support/syslog.rb @@ -1,36 +1,38 @@ +# frozen_string_literal: true + shared_examples_for 'syslog resource' do - it { should have_syslog_resource_count(1) } + it { is_expected.to have_syslog_resource_count(1) } it do - should contain_syslog('foo').only_with({ - 'name' => 'foo', - 'ensure' => 'present', - 'facility' => 'local2', - 'level' => '*', - 'action_type' => 'file', - 'action' => '/var/log/foo.log', - 'provider' => 'augeas', - }) + expect(subject).to contain_syslog('foo').only_with({ + 'name' => 'foo', + 'ensure' => 'present', + 'facility' => 'local2', + 'level' => '*', + 'action_type' => 'file', + 'action' => '/var/log/foo.log', + 'provider' => 'augeas', + }) end end shared_context 'syslog' do - it { should have_syslog_resource_count(0) } + it { is_expected.to have_syslog_resource_count(0) } let :example_params do - {'foo' => {'facility' => 'local2', 'level' => '*', 'action_type' => 'file', 'action' => '/var/log/foo.log'}} + { 'foo' => { 'facility' => 'local2', 'level' => '*', 'action_type' => 'file', 'action' => '/var/log/foo.log' } } end - context "when syslog_hash is a Hash" do - let(:params) {{ :syslog_hash => example_params }} - let(:facts) {{}} + context 'when syslog_hash is a Hash' do + let(:params) { { syslog_hash: example_params } } + let(:facts) { {} } include_examples 'syslog resource' end - context "when ::augeasproviders_syslog_hash is a Hash" do - let(:params) {{}} - let(:facts) {{ :augeasproviders_syslog_hash => example_params }} + context 'when ::augeasproviders_syslog_hash is a Hash' do + let(:params) { {} } + let(:facts) { { augeasproviders_syslog_hash: example_params } } include_examples 'syslog resource' end diff --git a/spec/support/validate_hash.rb b/spec/support/validate_hash.rb index 8ded9a93..ba10d715 100644 --- a/spec/support/validate_hash.rb +++ b/spec/support/validate_hash.rb @@ -1,15 +1,19 @@ +# frozen_string_literal: true + shared_examples_for 'validate_hash param' do |hash_param_name| context "when #{hash_param_name} => 'FOO'" do - let(:params) {{ hash_param_name.to_sym => 'FOO' }} - let(:facts) {{}} - it { expect { should create_class('augeasproviders') }.to raise_error(Puppet::Error, /is not a Hash/) } + let(:params) { { hash_param_name.to_sym => 'FOO' } } + let(:facts) { {} } + + it { expect { is_expected.to create_class('augeasproviders') }.to raise_error(Puppet::Error, %r{expects a Hash value, got String}) } end end shared_examples_for 'validate_hash top-scope param' do |hash_variable_name| context "when ::#{hash_variable_name} => 'FOO'" do - let(:params) {{}} - let(:facts) {{ hash_variable_name.to_sym => 'FOO' }} - it { expect { should create_class('augeasproviders') }.to raise_error(Puppet::Error, /is not a Hash/) } + let(:params) { {} } + let(:facts) { { hash_variable_name.to_sym => 'FOO' } } + + it { expect { is_expected.to create_class('augeasproviders') }.to raise_error(Puppet::Error, %r{expects a Hash value, got String}) } end end