pax_global_header00006660000000000000000000000064145613717350014526gustar00rootroot0000000000000052 comment=e3b7546758ab5a3062bec799691007fcd7d57234 puppetlabs_spec_helper-7.0.5/000077500000000000000000000000001456137173500162675ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/.github/000077500000000000000000000000001456137173500176275ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/.github/dependabot.yml000066400000000000000000000005411456137173500224570ustar00rootroot00000000000000version: 2 updates: # raise PRs for gem updates - package-ecosystem: bundler directory: "/" schedule: interval: daily time: "13:00" open-pull-requests-limit: 10 # Maintain dependencies for GitHub Actions - package-ecosystem: github-actions directory: "/" schedule: interval: daily time: "13:00" open-pull-requests-limit: 10 puppetlabs_spec_helper-7.0.5/.github/pull_request_template.md000066400000000000000000000006701456137173500245730ustar00rootroot00000000000000## Summary Provide a detailed description of all the changes present in this pull request. ## Additional Context Add any additional context about the problem here. - [ ] Root cause and the steps to reproduce. (If applicable) - [ ] Thought process behind the implementation. ## Related Issues (if any) Mention any related issues or pull requests. ## Checklist - [ ] 🟢 Spec tests. - [ ] 🟢 Acceptance tests. - [ ] Manually verified. puppetlabs_spec_helper-7.0.5/.github/workflows/000077500000000000000000000000001456137173500216645ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/.github/workflows/ci.yml000066400000000000000000000020261456137173500230020ustar00rootroot00000000000000name: "ci" on: push: branches: - "main" pull_request: branches: - "main" workflow_dispatch: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} jobs: spec: strategy: fail-fast: false matrix: ruby_version: - '2.7' - '3.2' name: "spec (ruby ${{ matrix.ruby_version }})" uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main" secrets: "inherit" with: rake_task: "spec:coverage" ruby_version: ${{ matrix.ruby_version }} acceptance: needs: spec strategy: fail-fast: false matrix: ruby_version: - '2.7' - '3.2' include: - ruby_version: '2.7' puppet_version: '~> 7.0' - ruby_version: '3.2' puppet_version: '~> 8.0' uses: "puppetlabs/cat-github-actions/.github/workflows/gem_acceptance.yml@main" secrets: "inherit" with: ruby_version: ${{ matrix.ruby_version }} puppet_version: ${{ matrix.puppet_version }} puppetlabs_spec_helper-7.0.5/.github/workflows/labeller.yml000066400000000000000000000010151456137173500241660ustar00rootroot00000000000000name: Labeller on: issues: types: - opened - labeled - unlabeled pull_request_target: types: - opened - labeled - unlabeled jobs: label: runs-on: ubuntu-latest steps: - uses: puppetlabs/community-labeller@v1.0.1 name: Label issues or pull requests with: label_name: community label_color: '5319e7' org_membership: puppetlabs fail_if_member: 'true' token: ${{ secrets.IAC_COMMUNITY_LABELER }} puppetlabs_spec_helper-7.0.5/.github/workflows/mend.yml000066400000000000000000000004161456137173500233330ustar00rootroot00000000000000name: "mend" on: pull_request_target: types: - opened - synchronize schedule: - cron: "0 0 * * *" workflow_dispatch: jobs: mend: uses: "puppetlabs/cat-github-actions/.github/workflows/tooling_mend_ruby.yml@main" secrets: "inherit" puppetlabs_spec_helper-7.0.5/.github/workflows/nightly.yml000066400000000000000000000015441456137173500240710ustar00rootroot00000000000000name: "nightly" on: schedule: - cron: "0 0 * * *" workflow_dispatch: jobs: spec: strategy: fail-fast: false matrix: ruby_version: - '2.7' - '3.2' uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main" secrets: "inherit" with: ruby_version: ${{ matrix.ruby_version }} acceptance: needs: spec strategy: fail-fast: false matrix: ruby_version: - '2.7' - '3.2' include: - ruby_version: '2.7' puppet_version: '~> 7.0' - ruby_version: '3.2' puppet_version: '~> 8.0' uses: "puppetlabs/cat-github-actions/.github/workflows/gem_acceptance.yml@main" secrets: "inherit" with: ruby_version: ${{ matrix.ruby_version }} puppet_version: ${{ matrix.puppet_version }} puppetlabs_spec_helper-7.0.5/.github/workflows/release.yml000066400000000000000000000005721456137173500240330ustar00rootroot00000000000000name: "Release" on: workflow_dispatch: inputs: target: description: "The target for the release. This can be a commit sha or a branch." required: false default: "main" jobs: release: uses: "puppetlabs/cat-github-actions/.github/workflows/gem_release.yml@main" with: target: "${{ github.event.inputs.target }}" secrets: "inherit" puppetlabs_spec_helper-7.0.5/.github/workflows/release_prep.yml000066400000000000000000000010231456137173500250510ustar00rootroot00000000000000name: "Release Prep" on: workflow_dispatch: inputs: target: description: "The target for the release. This can be a commit sha or a branch." required: false default: "main" version: description: "Version of gem to be released." required: true jobs: release_prep: uses: "puppetlabs/cat-github-actions/.github/workflows/gem_release_prep.yml@main" with: target: "${{ github.event.inputs.target }}" version: "${{ github.event.inputs.version }}" secrets: "inherit" puppetlabs_spec_helper-7.0.5/.gitignore000066400000000000000000000001401456137173500202520ustar00rootroot00000000000000/.bundle/ /.yardoc /Gemfile.lock /_yardoc/ /coverage/ /doc/ /pkg/ /spec/reports/ /tmp/ /vendor/ puppetlabs_spec_helper-7.0.5/.rspec000066400000000000000000000000441456137173500174020ustar00rootroot00000000000000--format documentation --order rand puppetlabs_spec_helper-7.0.5/.rubocop.yml000066400000000000000000000005321456137173500205410ustar00rootroot00000000000000inherit_from: .rubocop_todo.yml require: - rubocop-performance - rubocop-rspec AllCops: Exclude: - Gemfile - Rakefile - spec/fixtures/**/* - vendor/bundle/**/* NewCops: enable SuggestExtensions: false TargetRubyVersion: '2.7' # Disabled Style/ClassAndModuleChildren: Enabled: false Layout/LineLength: Max: 200 puppetlabs_spec_helper-7.0.5/.rubocop_todo.yml000066400000000000000000000066521456137173500215770ustar00rootroot00000000000000# This configuration was generated by # `rubocop --auto-gen-config` # on 2024-02-09 08:47:26 UTC using RuboCop version 1.50.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Severity, Include. # Include: **/*.gemspec Gemspec/RequireMFA: Exclude: - 'puppetlabs_spec_helper.gemspec' # Offense count: 5 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 60 # Offense count: 3 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. # AllowedMethods: refine Metrics/BlockLength: Max: 33 # Offense count: 4 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: Max: 19 # Offense count: 11 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Max: 65 # Offense count: 1 # Configuration parameters: CountComments, CountAsOne. Metrics/ModuleLength: Max: 277 # Offense count: 3 # Configuration parameters: CountKeywordArgs. Metrics/ParameterLists: MaxOptionalParameters: 4 Max: 7 # Offense count: 3 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: Max: 22 # Offense count: 1 # Configuration parameters: IgnoredMetadata. RSpec/DescribeClass: Exclude: - '**/spec/features/**/*' - '**/spec/requests/**/*' - '**/spec/routing/**/*' - '**/spec/system/**/*' - '**/spec/views/**/*' - 'spec/acceptance/smoke_spec.rb' # Offense count: 6 # Configuration parameters: CountAsOne. RSpec/ExampleLength: Max: 13 # Offense count: 5 # Configuration parameters: . # SupportedStyles: have_received, receive RSpec/MessageSpies: EnforcedStyle: receive # Offense count: 5 RSpec/MultipleExpectations: Max: 3 # Offense count: 7 # Configuration parameters: AllowedGroups. RSpec/NestedGroups: Max: 5 # Offense count: 5 RSpec/StubbedMock: Exclude: - 'spec/unit/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals_spec.rb' - 'spec/unit/puppetlabs_spec_helper/tasks/fixture_helpers_spec.rb' # Offense count: 2 Security/Eval: Exclude: - 'lib/puppetlabs_spec_helper/tasks/fixtures.rb' # Offense count: 1 Style/CombinableLoops: Exclude: - 'lib/puppetlabs_spec_helper/tasks/fixtures.rb' # Offense count: 7 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns. # SupportedStyles: annotated, template, unannotated Style/FormatStringToken: EnforcedStyle: unannotated # Offense count: 4 # Configuration parameters: AllowedVariables. Style/GlobalVars: Exclude: - 'lib/puppetlabs_spec_helper/puppetlabs_spec/files.rb' # Offense count: 1 Style/MixinUsage: Exclude: - 'lib/puppetlabs_spec_helper/tasks/fixtures.rb' # Offense count: 9 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma Style/TrailingCommaInArguments: Exclude: - 'lib/puppetlabs_spec_helper/tasks/fixtures.rb' - 'spec/unit/puppetlabs_spec_helper/tasks/fixture_helpers_spec.rb' puppetlabs_spec_helper-7.0.5/CHANGELOG.md000066400000000000000000001174331456137173500201110ustar00rootroot00000000000000 # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). ## [v7.0.5](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v7.0.5) - 2024-02-09 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v7.0.4...v7.0.5) ### Fixed - (bug) - check for empty fixtures array, as well as nil [#435](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/435) ([jordanbreen28](https://github.com/jordanbreen28)) ## [v7.0.4](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v7.0.4) - 2024-02-08 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v7.0.3...v7.0.4) ### Fixed - puppet-syntax: Require 4.x [#433](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/433) ([bastelfreak](https://github.com/bastelfreak)) - (GH-397) - Honour default symlink when additional symlinks delcared [#431](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/431) ([jordanbreen28](https://github.com/jordanbreen28)) - (GH-422) - Allow `ref` to be optional in fixtures [#430](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/430) ([jordanbreen28](https://github.com/jordanbreen28)) ## [v7.0.3](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v7.0.3) - 2024-01-24 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v7.0.2...v7.0.3) ### Fixed - (CAT-1688) Upgrade Rubocop to `~> 1.50.0` [#426](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/426) ([LukasAud](https://github.com/LukasAud)) - (maint) - Make codecov gem support optional - changes to spec:simplecov rake task [#424](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/424) ([jordanbreen28](https://github.com/jordanbreen28)) ## [v7.0.2](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v7.0.2) - 2023-12-12 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v7.0.1...v7.0.2) ### Fixed - Skip non-existing paths in $MODULEPATH silently [#419](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/419) ([kjetilho](https://github.com/kjetilho)) ## [v7.0.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v7.0.1) - 2023-11-22 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v7.0.0...v7.0.1) ### Fixed - (CAT-1603) - Revert back to puppet-lint and rspec-puppet [#417](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/417) ([jordanbreen28](https://github.com/jordanbreen28)) ## [v7.0.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v7.0.0) - 2023-10-18 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v6.0.3...v7.0.0) ### Changed - (CAT-1222) - Require puppetlabs-rspec-puppet over rspec-puppet [#415](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/415) ([jordanbreen28](https://github.com/jordanbreen28)) - (CAT-1256)- Require puppetlabs-puppet-lint over puppet-lint [#411](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/411) ([GSPatton](https://github.com/GSPatton)) ## [v6.0.3](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v6.0.3) - 2023-10-09 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v6.0.2...v6.0.3) ### Fixed - (bug) - remove obselete manfiest dir config setting & require rspec-puppet 4.x [#412](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/412) ([jordanbreen28](https://github.com/jordanbreen28)) ## [v6.0.2](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v6.0.2) - 2023-09-25 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v6.0.1...v6.0.2) ### Fixed - (CAT-1430) - Require puppet-lint ~> 4.0 [#409](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/409) ([jordanbreen28](https://github.com/jordanbreen28)) ## [v6.0.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v6.0.1) - 2023-04-25 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v6.0.0...v6.0.1) ### Fixed - (MAINT) Bump lint and rspec-puppet dependencies [#395](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/395) ([chelnak](https://github.com/chelnak)) ## [v6.0.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v6.0.0) - 2023-04-25 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v6.0.0.rc.1...v6.0.0) ### Added - Use rspec-puppet settings to configure Puppet [#389](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/389) ([ekohl](https://github.com/ekohl)) ## [v6.0.0.rc.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v6.0.0.rc.1) - 2023-04-19 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v5.0.3...v6.0.0.rc.1) ### Changed - (CONT-807) Add Ruby 3.2 support [#390](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/390) ([GSPatton](https://github.com/GSPatton)) ### Added - (CONT-807) Ruby 3 / Puppet 8 Additions [#393](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/393) ([chelnak](https://github.com/chelnak)) ## [v5.0.3](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v5.0.3) - 2023-01-25 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v5.0.2...v5.0.3) ## [v5.0.2](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v5.0.2) - 2023-01-25 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v5.0.1...v5.0.2) ### Fixed - (CONT-515) Fix uninitialized constant error [#379](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/379) ([chelnak](https://github.com/chelnak)) - puppet-lint: Allow 3.x [#378](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/378) ([bastelfreak](https://github.com/bastelfreak)) - pathspec: Allow 1.x [#377](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/377) ([bastelfreak](https://github.com/bastelfreak)) ## [v5.0.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v5.0.1) - 2023-01-23 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v5.0.0...v5.0.1) ### Fixed - (GH-372) Reset min Ruby requirement [#373](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/373) ([chelnak](https://github.com/chelnak)) ## [v5.0.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v5.0.0) - 2023-01-23 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v4.0.1...v5.0.0) ### Changed - (CONT-237) Deprecation and legacy version support removal [#364](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/364) ([chelnak](https://github.com/chelnak)) - (CONT-237) Bump minimum Ruby version requirement [#358](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/358) ([chelnak](https://github.com/chelnak)) - Drop outdated future parser support [#348](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/348) ([binford2k](https://github.com/binford2k)) ### Added - Add rspec-github integration [#353](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/353) ([ekohl](https://github.com/ekohl)) - Run the `strings:validate:reference` task during `validate` [#352](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/352) ([smortex](https://github.com/smortex)) - Configure puppet-lint to fail on warnings again [#347](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/347) ([ekohl](https://github.com/ekohl)) ### Fixed - (CONT-237) Rubocop updates [#360](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/360) ([chelnak](https://github.com/chelnak)) - Fix check:git_ignore rake task for git >= 2.32.0 [#346](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/346) ([ekohl](https://github.com/ekohl)) ## [v4.0.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v4.0.1) - 2021-08-23 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v4.0.0...v4.0.1) ### Fixed - (PDK-1717) Add guard clause to module path dir enum loop [#342](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/342) ([sanfrancrisko](https://github.com/sanfrancrisko)) ## [v4.0.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v4.0.0) - 2021-07-26 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v3.0.0...v4.0.0) ### Added - Use Rubocop's Github Actions formatter if possible [#340](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/340) ([ekohl](https://github.com/ekohl)) - Remove beaker integration [#338](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/338) ([ekohl](https://github.com/ekohl)) ## [v3.0.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v3.0.0) - 2021-02-10 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.16.0...v3.0.0) ### Added - Restructure PuppetLint rake tasks so they can be configurable [#330](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/330) ([nmaludy](https://github.com/nmaludy)) ## [v2.16.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.16.0) - 2021-01-18 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.15.0...v2.16.0) ### Added - Add a check task [#327](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/327) ([ekohl](https://github.com/ekohl)) - Update fixtures from forge when the module version doesn't match; fix git < 2.7 compatibility [#269](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/269) ([nabertrand](https://github.com/nabertrand)) - Add all spec/lib directories from fixtures to LOAD_PATH [#233](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/233) ([nabertrand](https://github.com/nabertrand)) ## [v2.15.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.15.0) - 2020-06-12 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.14.1...v2.15.0) ### Added - Add Ruby 2.6/Puppet6 to CI matrix [#311](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/311) ([bastelfreak](https://github.com/bastelfreak)) - (GH-297) Don't allow git refs with forward slashes [#299](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/299) ([glennsarti](https://github.com/glennsarti)) - Support git fixture branches containing slashes [#297](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/297) ([trevor-vaughan](https://github.com/trevor-vaughan)) - Accept `:tag` for consistency with r10k [#296](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/296) ([binford2k](https://github.com/binford2k)) - Ignore plans folder and any subfolder [#294](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/294) ([cyberious](https://github.com/cyberious)) - Download forge modules in parallel [#284](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/284) ([logicminds](https://github.com/logicminds)) - (maint) migrate the changelog task from pdk-templates [#278](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/278) ([DavidS](https://github.com/DavidS)) ### Fixed - (MAINT) Fix initialize of Gettext call [#292](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/292) ([ThoughtCrhyme](https://github.com/ThoughtCrhyme)) ## [v2.14.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.14.1) - 2019-03-26 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.14.0...v2.14.1) ### Fixed - Revert "(feat) dont load the beaker if litmus is there" [#286](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/286) ([pmcmaw](https://github.com/pmcmaw)) ## [v2.14.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.14.0) - 2019-03-25 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.13.1...v2.14.0) ### Added - (feat) dont load the beaker if litmus is there [#281](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/281) ([tphoney](https://github.com/tphoney)) - (maint) load rake tasks from optional libraries [#279](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/279) ([DavidS](https://github.com/DavidS)) - Document how to set default values for fixture loading [#277](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/277) ([Felixoid](https://github.com/Felixoid)) ### Fixed - Remove `--color` from everywhere, use RSpec default detection instead [#280](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/280) ([DavidS](https://github.com/DavidS)) ## [v2.13.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.13.1) - 2019-01-15 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.13.0...v2.13.1) ### Fixed - Revert "(MODULES-8242) - Fix CI_SPEC_OPTIONS failing" [#275](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/275) ([rodjek](https://github.com/rodjek)) ## [v2.13.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.13.0) - 2019-01-11 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.12.0...v2.13.0) ### Added - (PDK-1199) Honour .{pdk,git}ignore in check:symlinks rake task [#267](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/267) ([rodjek](https://github.com/rodjek)) - (PDK-1137) Determine module name from metadata when possible [#265](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/265) ([rodjek](https://github.com/rodjek)) ### Fixed - (MODULES-8242) - Fix CI_SPEC_OPTIONS failing [#268](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/268) ([stamm](https://github.com/stamm)) - (PDK-997) Remove Dir.chdir call from check:test_file task [#266](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/266) ([rodjek](https://github.com/rodjek)) ## [v2.12.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.12.0) - 2018-11-08 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.11.0...v2.12.0) ### Added - Added tasks to rspec pattern. [#261](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/261) ([dylanratcliffe](https://github.com/dylanratcliffe)) - (PDK-1100) Use PDK to build module packages [#260](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/260) ([rodjek](https://github.com/rodjek)) ### Fixed - (bugfix) ignore bundle directory, for symlinks [#263](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/263) ([tphoney](https://github.com/tphoney)) - (MODULES-7273) - Raise error when fixture ref invalid [#262](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/262) ([eimlav](https://github.com/eimlav)) ## [v2.11.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.11.0) - 2018-09-26 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.10.0...v2.11.0) ### Added - (MODULES-7856) Allow optional repositories based on puppet version [#258](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/258) ([joshcooper](https://github.com/joshcooper)) ### Fixed - Fix example conversion from mocha to rspec mocks. [#257](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/257) ([vStone](https://github.com/vStone)) ## [v2.10.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.10.0) - 2018-08-30 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.9.1...v2.10.0) ### Added - (feat) add puppet lint fix task [#255](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/255) ([tphoney](https://github.com/tphoney)) - add support to override the allowed test tiers [#253](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/253) ([b4ldr](https://github.com/b4ldr)) ## [v2.9.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.9.1) - 2018-06-20 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.9.0...v2.9.1) ### Fixed - (PDK-1031) Remove thread-unsafe Dir.chdir usage [#249](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/249) ([rodjek](https://github.com/rodjek)) - (PDK-1033) Use `--unshallow` when fetching a ref [#247](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/247) ([DavidS](https://github.com/DavidS)) ## [v2.9.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.9.0) - 2018-06-18 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.8.0...v2.9.0) ### Added - (maint) adding ruby code coverage setup and rake task [#245](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/245) ([tphoney](https://github.com/tphoney)) ## [v2.8.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.8.0) - 2018-05-31 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.7.0...v2.8.0) ### Added - minor edits to mock_with section [#243](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/243) ([jbondpdx](https://github.com/jbondpdx)) - (PDK-636) Groundwork to allow PDK to persist downloaded fixtures [#242](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/242) ([rodjek](https://github.com/rodjek)) - (PDK-636) Always remove symlink fixtures. Only remove downloaded fixtures if tests pass. [#241](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/241) ([rodjek](https://github.com/rodjek)) ## [v2.7.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.7.0) - 2018-04-12 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.6.2...v2.7.0) ### Added - (PDK-916) Default to mocha if mock_framework isn't set [#239](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/239) ([MikaelSmith](https://github.com/MikaelSmith)) - Break out beaker and fixture tasks into separate files [#238](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/238) ([DavidS](https://github.com/DavidS)) - (BOLT-397) add spec/plans/**/*_spec.rb to spec discovery pattern [#235](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/235) ([adreyer](https://github.com/adreyer)) ### Fixed - Allow module_spec_helper to work with mocha 1.5.0 and rspec mocking [#237](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/237) ([DavidS](https://github.com/DavidS)) - (FM-6813) fix parsing for test tiers [#231](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/231) ([ThoughtCrhyme](https://github.com/ThoughtCrhyme)) ## [v2.6.2](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.6.2) - 2018-02-12 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.6.1...v2.6.2) ### Added - (MODULES-6606) change to initialize_config [#225](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/225) ([eputnam](https://github.com/eputnam)) ## [v2.6.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.6.1) - 2017-12-12 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.6.0...v2.6.1) ### Added - Fix fixtures defaults and add tests [#223](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/223) ([hunner](https://github.com/hunner)) ## [v2.6.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.6.0) - 2017-12-08 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.5.1...v2.6.0) ## [v2.5.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.5.1) - 2017-11-22 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.5.0...v2.5.1) ### Fixed - bugfix - parallel_spec fails with no files to test [#216](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/216) ([tphoney](https://github.com/tphoney)) ## [v2.5.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.5.0) - 2017-11-15 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.4.0...v2.5.0) ### Added - (PDK-429) add tests argument to rake spec [#209](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/209) ([8675309](https://github.com/8675309)) ### Fixed - (WIN-6) trim whitespace from test_tiers before parsing [#214](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/214) ([ThoughtCrhyme](https://github.com/ThoughtCrhyme)) ## [v2.4.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.4.0) - 2017-10-17 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.3.2...v2.4.0) ### Added - (MODULES-5503) Add support for repository targets [#210](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/210) ([trevor-vaughan](https://github.com/trevor-vaughan)) - Mercurial branch support [#208](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/208) ([pegasd](https://github.com/pegasd)) ### Fixed - (WIN-6) Add test_tiers env var parsing to support test tiering. [#212](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/212) ([ThoughtCrhyme](https://github.com/ThoughtCrhyme)) - Fix release_checks without parallel_tests [#211](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/211) ([sean797](https://github.com/sean797)) - Fix 'abort: please specify just one revision' mercurial error [#206](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/206) ([pegasd](https://github.com/pegasd)) ## [v2.3.2](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.3.2) - 2017-08-11 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.3.1...v2.3.2) ### Added - (PDK-409) Make directory junction targets relative to the junction [#203](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/203) ([rodjek](https://github.com/rodjek)) ### Fixed - (PDK-381) Ensure spec fixtures are cleaned up, even if the test fails [#204](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/204) ([rodjek](https://github.com/rodjek)) ## [v2.3.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.3.1) - 2017-08-02 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.3.0...v2.3.1) ### Fixed - (PDK-373) Add rake task to list spec tests [#201](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/201) ([james-stocks](https://github.com/james-stocks)) ## [v2.3.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.3.0) - 2017-07-20 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.2.0...v2.3.0) ### Added - Support CI options for parallel_spec [#199](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/199) ([austb](https://github.com/austb)) ## [v2.2.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.2.0) - 2017-06-22 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.1.5...v2.2.0) ### Added - Change default logger output to STDERR. [#197](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/197) ([scotje](https://github.com/scotje)) - Update default fixture path calculation to be Windows safe. [#196](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/196) ([scotje](https://github.com/scotje)) - Adding a parent rake task for i18n of a module [#194](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/194) ([HelenCampbell](https://github.com/HelenCampbell)) ## [v2.1.5](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.1.5) - 2017-06-07 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.1.4...v2.1.5) ## [v2.1.4](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.1.4) - 2017-06-07 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.1.3...v2.1.4) ### Added - (SDK-168) Replace check:symlinks with platform independent alternative [#193](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/193) ([rodjek](https://github.com/rodjek)) - (SDK-268) Create directory junctions instead of symlinks on windows [#192](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/192) ([rodjek](https://github.com/rodjek)) ## [v2.1.3](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.1.3) - 2017-05-31 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.1.2...v2.1.3) ### Added - (FM-6170) Addition of branch check for build number creation [#190](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/190) ([HelenCampbell](https://github.com/HelenCampbell)) ### Fixed - (maint) Properly escape paths [#191](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/191) ([samuelson](https://github.com/samuelson)) ## [v2.1.2](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.1.2) - 2017-04-17 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.1.1...v2.1.2) ## [v2.1.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.1.1) - 2017-03-29 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.1.0...v2.1.1) ### Added - Add dependency on parallel_tests [#186](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/186) ([ekohl](https://github.com/ekohl)) ## [v2.1.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.1.0) - 2017-03-06 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.0.2...v2.1.0) ### Added - (MODULES-4471) Add CI_SPEC_OPTIONS environment variable to modify rspec [#182](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/182) ([glennsarti](https://github.com/glennsarti)) ### Fixed - (maint) fix load order for gettext-setup tasks [#183](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/183) ([eputnam](https://github.com/eputnam)) ## [v2.0.2](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.0.2) - 2017-02-23 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.0.1...v2.0.2) ### Fixed - (maint) fix gettext rake tasks [#180](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/180) ([eputnam](https://github.com/eputnam)) ## [v2.0.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.0.1) - 2017-02-08 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v2.0.0...v2.0.1) ## [v2.0.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v2.0.0) - 2017-02-07 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v1.2.2...v2.0.0) ### Added - (MODULES-4394) Make the module_working_dir configurable [#175](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/175) ([glennsarti](https://github.com/glennsarti)) - Add type_aliases directory [#174](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/174) ([domcleal](https://github.com/domcleal)) - (MODULES-3212) change to parallel_spec [#173](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/173) ([eputnam](https://github.com/eputnam)) - (FM-5989) add i18n tools [#172](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/172) ([eputnam](https://github.com/eputnam)) - (maint) Module install - ensure paths use / [#171](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/171) ([ferventcoder](https://github.com/ferventcoder)) ## [v1.2.2](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v1.2.2) - 2016-08-26 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/v1.2.1...v1.2.2) ### Added - Only set strict_variables setting when required [#168](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/168) ([domcleal](https://github.com/domcleal)) ## [v1.2.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/v1.2.1) - 2016-08-24 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/1.2.0...v1.2.1) ## [1.2.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/1.2.0) - 2016-08-23 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/1.1.1...1.2.0) ### Changed - Deprecate PuppetInternals.scope [#108](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/108) ([DavidS](https://github.com/DavidS)) ### Added - Update puppet-lint and puppet-syntax default ignore paths [#165](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/165) ([DavidS](https://github.com/DavidS)) ## [1.1.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/1.1.1) - 2016-03-02 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/1.1.0...1.1.1) ### Fixed - Re-add the missing metadata task with a depreciation warning [#131](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/131) ([DavidS](https://github.com/DavidS)) ## [1.1.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/1.1.0) - 2016-02-24 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/1.0.1...1.1.0) ## [1.0.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/1.0.1) - 2015-11-06 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/1.0.0...1.0.1) ### Fixed - Should use Errno, not Error [#119](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/119) ([kristvanbesien](https://github.com/kristvanbesien)) ## [1.0.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/1.0.0) - 2015-11-04 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.10.3...1.0.0) ### Fixed - Add more info to the `abort()` on malformed YAML [#111](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/111) ([daenney](https://github.com/daenney)) - (MODULES-2090) fixes bug in rake_tasks config [#106](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/106) ([bmjen](https://github.com/bmjen)) ## [0.10.3](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.10.3) - 2015-05-11 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.10.2...0.10.3) ### Added - Update Lint to default to Puppet Approved criteria [#80](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/80) ([cyberious](https://github.com/cyberious)) ### Fixed - Don't set settings removed in puppet4 if testing against puppet4 [#102](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/102) ([underscorgan](https://github.com/underscorgan)) ## [0.10.2](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.10.2) - 2015-04-14 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.10.1...0.10.2) ### Added - Updates for puppet 4 [#100](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/100) ([hunner](https://github.com/hunner)) ## [0.10.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.10.1) - 2015-03-17 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.10.0...0.10.1) ### Added - Only use --depth 1 if ref is not used [#96](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/96) ([treydock](https://github.com/treydock)) ## [0.10.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.10.0) - 2015-03-16 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.9.1...0.10.0) ### Added - Use faster shallow git clone [#94](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/94) ([sbadia](https://github.com/sbadia)) - Exclude vendor/ files [#86](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/86) ([domcleal](https://github.com/domcleal)) ## [0.9.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.9.1) - 2015-02-24 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.9.0...0.9.1) ## [0.9.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.9.0) - 2015-02-24 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.8.2...0.9.0) ### Added - Enable future parser testing [#91](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/91) ([cmurphy](https://github.com/cmurphy)) - Stub root? method so spec tests can test execs [#88](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/88) ([cmurphy](https://github.com/cmurphy)) - (MODULES-1576) Use Puppet FileSystem abstraction for symlinks to support Windows [#84](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/84) ([Iristyle](https://github.com/Iristyle)) - Run metadata-json-lint under validate rake task [#82](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/82) ([domcleal](https://github.com/domcleal)) ### Fixed - fix load issue with puppet filesystem and windows symlinks [#87](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/87) ([logicminds](https://github.com/logicminds)) - (MODULES-1576) Fix symlink support for older Puppet versions [#85](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/85) ([Iristyle](https://github.com/Iristyle)) ## [0.8.2](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.8.2) - 2014-10-01 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.8.0...0.8.2) ### Fixed - (MODULES-1353) Correct the puppet-lint tasks path [#78](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/78) ([3flex](https://github.com/3flex)) ## [0.8.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.8.0) - 2014-08-25 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.7.0...0.8.0) ### Added - Allow relative paths and params [#76](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/76) ([hunner](https://github.com/hunner)) - Replace syntax checks with puppet-syntax [#73](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/73) ([dcarley](https://github.com/dcarley)) ### Fixed - Fix rspec 3.0 error when loading spec_helper [#74](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/74) ([jeffmccune](https://github.com/jeffmccune)) ## [0.7.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.7.0) - 2014-07-17 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.6.0...0.7.0) ### Added - (MODULES-1214) Allow .fixtures.yml to specify a git branch [#71](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/71) ([treydock](https://github.com/treydock)) - MODULES-1202 - add module_spec_helper support for 3.6 config items [#70](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/70) ([jantman](https://github.com/jantman)) - (MODULES-1190) respect puppet-lint ignore paths in Rakefile [#69](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/69) ([mmickan](https://github.com/mmickan)) ## [0.6.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.6.0) - 2014-07-02 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.5.2...0.6.0) ### Added - (MODULES-1189) force module install in spec_prep [#67](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/67) ([3flex](https://github.com/3flex)) - Add :validate as a rake task [#66](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/66) ([cmurphy](https://github.com/cmurphy)) - Add future parser and strict variable test support [#65](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/65) ([hunner](https://github.com/hunner)) ### Fixed - avoid name clash with Object.clone method [#64](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/64) ([ehaselwanter](https://github.com/ehaselwanter)) ## [0.5.2](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.5.2) - 2014-06-19 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.5.1...0.5.2) ## [0.5.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.5.1) - 2014-06-09 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.5.0...0.5.1) ### Added - Add mocha mocking back [#60](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/60) ([hunner](https://github.com/hunner)) ## [0.5.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.5.0) - 2014-06-06 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.4.2...0.5.0) ### Added - Remove mocha dependency and rspec pinning [#59](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/59) ([hunner](https://github.com/hunner)) ## [0.4.2](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.4.2) - 2014-06-06 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.4.1...0.4.2) ### Added - Only clean up site.pp fixture if zero length [#50](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/50) ([wcooley](https://github.com/wcooley)) - Add beaker and beaker_nodes tasks [#47](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/47) ([blkperl](https://github.com/blkperl)) - Add support for "forge_modules" in fixtures. [#46](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/46) ([wcooley](https://github.com/wcooley)) - spec_clean does not fail if it has already been run [#44](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/44) ([hawknewton](https://github.com/hawknewton)) - Changed to forced symlinks in the event that symlink is old a spec_prep ... [#43](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/43) ([tehmaspc](https://github.com/tehmaspc)) - support more than just git in fixtures [#41](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/41) ([igalic](https://github.com/igalic)) - be more ignorant [#40](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/40) ([igalic](https://github.com/igalic)) - Remove gemspec - it's superseded by our Rakefile [#39](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/39) ([igalic](https://github.com/igalic)) - Do not lint fixtures directory. [#38](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/38) ([nanliu](https://github.com/nanliu)) - Add syntax checking task [#36](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/36) ([dalen](https://github.com/dalen)) - (#21602) Updated rake_tasks.rb to include 'integration' folder when running spec tests. [#35](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/35) ([fatmcgav](https://github.com/fatmcgav)) ### Fixed - Fix for empty repository list in .fixtures.yml file [#42](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/42) ([tehmaspc](https://github.com/tehmaspc)) - Fix issue with aborted rake task when packaging gem. [#34](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/34) ([AlexCline](https://github.com/AlexCline)) - Fix Puppet Labs Issue Tracker URL [#33](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/33) ([DavidS](https://github.com/DavidS)) - Don't reset when target is missing [#30](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/30) ([hunner](https://github.com/hunner)) ## [0.4.1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.4.1) - 2013-02-08 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.4.0...0.4.1) ## [0.4.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.4.0) - 2012-12-26 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.4.0-rc1...0.4.0) ## [0.4.0-rc1](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.4.0-rc1) - 2012-12-14 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.3.0...0.4.0-rc1) ### Fixed - Rake should fail if git can't clone repository [#28](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/28) ([hunner](https://github.com/hunner)) - Fix Mocha deprecations [#26](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/26) ([mitchellh](https://github.com/mitchellh)) - Only remove the site.pp if it is empty [#24](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/24) ([hunner](https://github.com/hunner)) ## [0.3.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.3.0) - 2012-08-14 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.2.0...0.3.0) ### Fixed - Revert "Merge pull request #15 from ghoneycutt/add_hiera_support" [#16](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/16) ([branan](https://github.com/branan)) ## [0.2.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.2.0) - 2012-07-05 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.1.0...0.2.0) ### Fixed - fix broken coverage rake task. [#10](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/10) ([mafalb](https://github.com/mafalb)) - Create missing spec/fixtures/manifests [#9](https://github.com/puppetlabs/puppetlabs_spec_helper/pull/9) ([mafalb](https://github.com/mafalb)) ## [0.1.0](https://github.com/puppetlabs/puppetlabs_spec_helper/tree/0.1.0) - 2012-06-08 [Full Changelog](https://github.com/puppetlabs/puppetlabs_spec_helper/compare/5d2e3a6da74c351e3f0619acc0e1684089ad01a2...0.1.0) puppetlabs_spec_helper-7.0.5/CODEOWNERS000066400000000000000000000001201456137173500176530ustar00rootroot00000000000000# Setting ownership to the tooling team and Tim * @puppetlabs/devx @bastelfreak puppetlabs_spec_helper-7.0.5/CONTRIBUTING.md000066400000000000000000000011621456137173500205200ustar00rootroot00000000000000# DEVELOPMENT NOTES ## Building Gemspec To keep the gem accessible to people running older rubies, the gemspec may only contain dependencies on gems that are available to all supported rubies. Features that need gems compatible only to some versions of ruby need to be coded in a way that is optional, and specify their gem dependencies in the Gemfile, conditional on the ruby version. Add a note to the README about those. ## Releasing To release the gem run the following things. ### 1. Update the version update the version file: `lib/puppetlabs_spec_helper/version.rb` ### 2. Release the gem rake release[remote] puppetlabs_spec_helper-7.0.5/Gemfile000066400000000000000000000021471456137173500175660ustar00rootroot00000000000000# frozen_string_literal: true source ENV['GEM_SOURCE'] || 'https://rubygems.org' gemspec def location_for(place_or_version, fake_version = nil) git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} file_url_regex = %r{\Afile:\/\/(?.*)} if place_or_version && (git_url = place_or_version.match(git_url_regex)) [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] else [place_or_version, { require: false }] end end group :development do gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) gem 'simplecov' gem 'simplecov-console' gem 'pry', require: false gem 'pry-byebug', require: false gem 'pry-stack_explorer', require: false gem 'rake' gem 'rspec', '~> 3.1' gem 'rspec-its', '~> 1.0' gem 'rubocop', '~> 1.50.0', require: false gem 'rubocop-rspec', '~> 2.19', require: false gem 'rubocop-performance', '~> 1.16', require: false gem 'fakefs' gem 'yard' end puppetlabs_spec_helper-7.0.5/LICENSE000066400000000000000000000011461456137173500172760ustar00rootroot00000000000000Copyright (C) 2012 Puppet Labs Inc Puppet Labs can be contacted at: info@puppetlabs.com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.puppetlabs_spec_helper-7.0.5/README.md000066400000000000000000000445031456137173500175540ustar00rootroot00000000000000Puppet Labs Spec Helper ======================= [![Code Owners](https://img.shields.io/badge/owners-DevX--team-blue)](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/main/CODEOWNERS) ![ci](https://github.com/puppetlabs/puppetlabs_spec_helper/actions/workflows/ci.yml/badge.svg) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/puppetlabs/puppetlabs_spec_helper) The Short Version ----------------- This repository is meant to provide a single source of truth for how to initialize different Puppet versions for spec testing. The common use case is a module such as [stdlib](http://forge.puppetlabs.com/puppetlabs/stdlib) that works with many versions of Puppet. The stdlib module should require the spec helper in this repository, which will in turn automatically figure out the version of Puppet being tested against and perform version specific initialization. Other "customers" that should use this module are: * [Facter](https://github.com/puppetlabs/facter) * [PuppetDB](https://github.com/puppetlabs/puppetdb) * [Mount Providers](https://github.com/puppetlabs/puppetlabs-mount_providers) Usage ===== When developing or testing modules, simply clone this repository and install the gem it contains. The recommended way to do this is using [bundler](http://bundler.io/#getting-started). Example Gemfile: source 'https://rubygems.org' gem 'puppetlabs_spec_helper' Add this to your project's spec\_helper.rb: require 'puppetlabs_spec_helper/module_spec_helper' Add this to your project's Rakefile: require 'puppetlabs_spec_helper/rake_tasks' And run the spec tests: $ cd $modulename $ rake spec ### Parallel Fixture Downloads Fixture downloads will now execute in parallel to speed up the testing process. Which can represent >= 600% speed increase (depending on number of threads). You can control the amount of threads by setting the `MAX_FIXTURE_THREAD_COUNT` environment variable to a positive integer, the default is currently 10. We don't suggest going higher than 25 as the gains are marginal due to some repos taking a long time to download. Please be aware that your internal VCS system may not be able to handle a high load in which case the server would fail to clone the repository. Because of this issue, this setting is tunable via `MAX_FIXTURE_THREAD_COUNT`. Additionally, you can also speed up cloning when using the ssh protocol by multiplexing ssh sessions. Add something similar to your ssh config. Note: you may need to change the host if you're using an internal git server. ```shell Host github.com ControlMaster auto ControlPath ~/.ssh/ssh-%r@%h:%p ControlPersist yes ``` Note: parallel downloads are available for repositories and forge modules. ### Parallel tests It is also possible to use the `parallel_tests` Gem via the `:parallel_spec` Rake task to run rspec commands in parallel on groups of spec files. Use of parallelization at this level can result in large performance benefits when the Rspec examples tend to cause a number of large, CPU-intensive catalog compilations to occur. An example of where this might be the case is in a complex module with a lot of tests or a control repo with many hosts. Be aware however that in other circumstances this parallelization can result in the tests actually taking longer to run. The best thing to do is time `rspec spec` and `rspec parallel_spec` and use the parallelization only when there is a clear benefit. To enable this feature, add the `parallel_tests` Gem to your project's Gemfile: gem 'parallel_tests' And then to run spec tests in parallel: $ rake parallel_spec Issues ====== Please file issues against this project at the [Puppet Labs Issue Tracker](https://tickets.puppetlabs.com/browse/MODULES) The Long Version ---------------- Purpose of this Project ======================= This project is intended to serve two purposes: 1. To serve as a bridge between external projects and multiple versions of puppet; in other words, if your project has a dependency on puppet, you shouldn't need to need to worry about the details of how to initialize puppet's state for testing, no matter what version of puppet you are testing against. 2. To provide some convenience classes / methods for doing things like creating tempfiles, common rspec matchers, etc. These classes are in the puppetlabs\_spec directory. 3. To provide a common set of Rake tasks so that the procedure for testing modules is unified. To Use this Project =================== The most common usage scenario is that you will check out the 'main' branch of this project from github, and install it as a rubygem. There should be few or no cases where you would want to have any other branch of this project besides main/HEAD. Running on non-current ruby versions ------------------------------------ Since gem and bundler, ruby's package management tools, do not take the target ruby version into account when downloading packages, the puppetlabs_spec_helper gem can only depend on gems that are available for all supported ruby versions. If you can/want to use features from other packages, install those additional packages manually, or have a look at the Gemfile, which provides code to specify those dependencies in a more "friendly" way. This currently affects the following gems: * puppet * rubocop * rubocop-rspec * json_pure * rack Initializing Puppet for Testing =============================== In most cases, your project should be able to define a spec\_helper.rb that includes just this one simple line: require 'puppetlabs_spec_helper/puppet_spec_helper' Then, as long as the gem is installed, you should be all set. If you are using rspec-puppet for module testing, you will want to include a different library: require 'puppetlabs_spec_helper/module_spec_helper' NOTE that this is specifically for initializing Puppet's core. If your project does not have any dependencies on puppet and you just want to use the utility classes, see the next section. A number of the Puppet parser features, controlled via configuration during a normal puppet run, can be controlled by exporting specific environment variables for the spec run. These are: * ``STRICT_VARIABLES`` - Set to "no" to disable strict variable checking. See [strict_variables](http://docs.puppetlabs.com/references/latest/configuration.html#strictvariables) in puppet.conf for details. * ``ORDERING`` - set to the desired ordering method ("title-hash", "manifest", or "random") to set the order of unrelated resources when applying a catalog. Leave unset for the default behavior, currently "random". This is equivalent to setting [ordering](http://docs.puppetlabs.com/references/latest/configuration.html#ordering) in puppet.conf. As an example, to run spec tests with the future parser, strict variable checking, and manifest ordering, you would: ORDERING=manifest rake spec Using Utility Classes ===================== If you'd like to use the Utility classes (PuppetlabsSpec::Files, PuppetlabsSpec::Fixtures), you just need to add this to your project's spec\_helper.rb: require 'puppetlabs_spec_helper/puppetlabs_spec_helper' NOTE that the above line happens automatically if you've required 'puppetlabs\_spec\_helper/puppet\_spec\_helper', so you don't need to do both. In either case, you'll have all of the functionality of Puppetlabs::Files, Puppetlabs::Fixtures, etc., mixed-in to your rspec context. Using Fixtures ============== `puppetlabs_spec_helper` has the ability to populate the `spec/fixtures/modules` directory with dependent modules when `rake spec` or `rake spec_prep` is run. To do so, all required modules should be listed in a file named `.fixtures.yml` in the root of the project. You can specify a alternate location for that file in the `FIXTURES_YML` environment variable. You can use the `MODULE_WORKING_DIR` environment variable to specify a diffent location when installing module fixtures via the forge. By default the working directory is `/spec/fixtures/work-dir`. When specifying the repo source of the fixture you have a few options as to which revision of the codebase you wish to use, and optionally, the puppet versions where the fixture is needed. * `repo` - the url to the repo * `scm` - options include git or hg. This is an optional step as the helper code will figure out which scm is used. ```yaml scm: git scm: hg ``` * `target` - the directory name to clone the repo into ie. `target: mymodule` defaults to the repo name (Optional) * `subdir` - directory to be removed from the cloned repo. Its contents will be moved to the root directory (Optional) * `ref` - used to specify the tag name (like version) or commit hash to be checked out (Optional). Branch names should use the `branch` option instead. ```yaml ref: 1.0.0 ref: 880fca52c ``` * `branch` - used to specify the branch name you want to use ie. `branch: development` * `flags` - additional flags passed to the module installer (both puppet and scm) ```yaml flags: --verbose ``` * `puppet_version` - versions of puppet for which the fixture should be installed. Ruby version constraints are supported. Only works when the `semantic_puppet` gem is available (shipped with puppet 4.0 and up, by default). ```yaml puppet_version: '>= 6.0.0' ``` **Notes:** * `ref` and `branch` can be used together to get a specific revision on a specific branch * Top level `defaults` option could be used to set global options Fixtures Examples ----------------- Basic fixtures that will symlink `spec/fixtures/modules/my_modules` to the project root: ```yaml fixtures: symlinks: my_module: "#{source_dir}" ``` This is the same as specifying no symlinks fixtures at all. Add `firewall` and `stdlib` as required module fixtures: ```yaml fixtures: repositories: firewall: "https://github.com/puppetlabs/puppetlabs-firewall.git" stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" ``` Put a supplementary repository at a different location ```yaml fixtures: repositories: firewall: "https://github.com/puppetlabs/puppetlabs-firewall.git" stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" control_repo: repo: "https://github.com/puppetlabs/control-repo" target: "spec/fixtures/control_repos" ``` Specify that the git tag `2.4.2` of `stdlib` should be checked out: ```yaml fixtures: repositories: firewall: "https://github.com/puppetlabs/puppetlabs-firewall.git" stdlib: repo: "https://github.com/puppetlabs/puppetlabs-stdlib.git" ref: "2.6.0" ``` Only install the `yumrepo_core` module when testing against Puppet 7 or greater: ```yaml fixtures: repositories: yumrepo_core: repo: "https://github.com/puppetlabs/puppetlabs-yumrepo_core.git" puppet_version: ">= 6.0.0" ``` Move manifests and siblings to root directory when they are inside a `code` directory: ```yaml fixtures: repositories: stdlib: repo: "https://github.com/puppetlabs/puppetlabs-extradirectory.git" subdir: "code" ``` Install modules from Puppet Forge: ```yaml fixtures: forge_modules: firewall: "puppetlabs/firewall" stdlib: repo: "puppetlabs/stdlib" ref: "2.6.0" ``` Pass additional flags to module installation: ```yaml fixtures: forge_modules: stdlib: repo: "puppetlabs/stdlib" ref: "2.6.0" flags: "--module_repository https://my_repo.com" repositories: firewall: repo: "https://github.com/puppetlabs/puppetlabs-firewall.git" ref: "2.6.0" flags: "--verbose" ``` Use `defaults` to define global parameters: ```yaml defaults: forge_modules: flags: "--module_repository https://my_repo.com" fixtures: forge_modules: stdlib: repo: "puppetlabs/stdlib" ref: "2.6.0" repositories: firewall: repo: "https://github.com/puppetlabs/puppetlabs-firewall.git" ref: "2.6.0" ``` Fixture Loading --------------- Any module that has a `spec/lib` directory will be available on the ruby `LOAD_PATH` for tests to consume. This allows modules to provide additional helper code to be supplied. The [augeasprovider_core](https://github.com/hercules-team/augeasproviders_core) module has [some examples](https://github.com/hercules-team/augeasproviders_core/tree/master/spec/lib). Testing Parser Functions ======================== This whole section is superseded by improved support of accessing the scope in rspec-puppet. Modify rspec behavior ================================ #### Running Rspec with additional settings You can add command line options to rspec using the `CI_SPEC_OPTIONS` environment variable. Any text in the `CI_SPEC_OPTIONS` environment variable is added as an rspec option. For example: If you wanted to output JUnit test reports for a Jenkins CI server you could use; Bash ``` bash export CI_SPEC_OPTIONS = "-r yarjuf -f JUnit -o result.xml" ``` PowerShell ``` bash $ENV:CI_SPEC_OPTIONS = '-r yarjuf -f JUnit -o result.xml' ``` And then run ``` bundle exec rake spec ``` This would cause rspec to load the `yarjuf` gem and output the results in JUnit format to the file `result.xml` #### Running specs in parallel When executing tests in a matrix CI environment, tests can be split up to run a share of specs per CI node in parallel. Set the ``CI_NODE_TOTAL`` environment variable to the total number of nodes, and the ``CI_NODE_INDEX`` to a number between 1 and the ``CI_NODE_TOTAL``. If using Travis CI, add new lines to the "env" section of .travis.yml per node, remembering to duplicate any existing environment variables: env: - FUTURE_PARSER=yes CI_NODE_TOTAL=2 CI_NODE_INDEX=1 - FUTURE_PARSER=yes CI_NODE_TOTAL=2 CI_NODE_INDEX=2 #### Running tests tagged with test tiers To run tests tagged with risk levels set the ``TEST_TIERS`` environment variable to a comma-separated list of the appropriate tiers. For example: to run tests marked ``tier_high => true`` and ``tier_medium => true`` in the same test run set the environment variable``TEST_TIERS=high,medium`` By default ``TEST_TIERS`` only accepts low, medium and high as valid tiers. If you would like to use your own keywords to set the environment variable ``TEST_TIERS_ALLOWED``. For example: to use the keywords dev, rnd, staging and production you can set ``TEST_TIERS_ALLOWED=dev,rnd,staging,production``. Then you would be able to run tests marked ``tier_dev => true``, ``tier_production => true`` with ``TEST_TIERS=dev,production`` Note, if the ``TEST_TIERS`` environment variable is set to empty string or nil, all tiers will be executed. Generating code coverage reports ================================ This section describes how to add code coverage reports for Ruby files (types, providers, ...). See the documentation of [RSpec-Puppet](https://github.com/rodjek/rspec-puppet) for Puppet manifest coverage reports. Starting with Ruby 1.9, the *de facto* standard for Ruby code coverage is [SimpleCov](https://github.com/colszowka/simplecov). It is implemented as a Rake task in this gem. To run code coverage: $ rake spec:simplecov Reports are written to `/coverage/`, which you should add to `.gitignore`. The reports can be generated every time you invoke RSpec, e.g. via `rake spec`, You can enable it, set the following environment variable:s ``SIMPLECOV=yes`` Remember to add the simplecov-console gem to your `Gemfile`. If you run `spec:simplecov` on Travis-CI or any of the other supported CI services, reports get generated which can then be uploaded to [codecov.io](https://codecov.io) with the recommended [codecov uploader](https://docs.codecov.com/docs/codecov-uploader). Some Notes for Windows Users ============================ A windows users may need to do one of two things to execute `rake spec`. Although things may appear to work, the init.pp may not transfer to the fixtures folder as needed or may transfer as an empty file. This is related to a registry security setting requiring elevated privileges to create symbolic links. Currently, there are two known approaches to get around this problem. - run your windows shell (cmd) as an Administrator or - modify the registry entry settings to allow symbolic links to be created. The following links may give you some insight into why... [Server Fault Post](http://serverfault.com/questions/582944/puppet-file-link-doesnt-create-target-under-windows) [Stack Overflow Post](http://stackoverflow.com/questions/229643/how-do-i-overcome-the-the-symbolic-link-cannot-be-followed-because-its-type-is) [Microsoft TechNet](https://technet.microsoft.com/en-us/library/cc754077.aspx) mock_with ========= There are two major mocking frameworks in modules test suites today: [mocha](https://rubygems.org/gems/mocha) and [rspec-mocks](https://rubygems.org/gems/rspec-mocks). We recommend that you choose rspec-mocks explicitly by specifying `mock_with`, either in your `spec_helper.rb` like so: ``` RSpec.configure do |c| c.mock_with :rspec end require 'puppetlabs_spec_helper/module_spec_helper' ``` or by using Puppet Development Kit's [`mock_with` option in `.sync.yml`](https://github.com/puppetlabs/pdk-templates#specspec_helperrb) and `pdk update`. You can also continue to use mocha by explicitly specifying `:mocha`, following the [mocha documentation](http://gofreerange.com/mocha/docs/). Migration --------- To migrate from mocha to rspec-mocks, in many simple cases the following two kinds of changes are all you need: Translate all stubs: ``` context.stubs(:some_method).with(arguments).returns('value') ``` to this: ``` allow(context).to receive(:some_method).with(arguments).and_return('value') ``` Translate all expectations: ``` context.expects(:some_method).with(arguments).returns('value') ``` to this: ``` expect(context).to receive(:some_method).with(arguments).and_return('value') ``` Rationale --------- * As a part of the RSpec project, rspec-mocks integration is better. * mocha is extending base ruby objects with its `stubs`, and `expects` methods, polluting the global namespace, with a potential for subtle and gnarly errors. * Currently both rspec-mocks and mocha get loaded, leading to test suites that use both. * puppetlabs_spec_helper loads and configures mocha unconditionally, causing friction when a different mocking framework is wanted. * mocha is an additional dependency to carry. EOF ## License This codebase is licensed under Apache 2.0. However, the open source dependencies included in this codebase might be subject to other software licenses such as AGPL, GPL2.0, and MIT. puppetlabs_spec_helper-7.0.5/Rakefile000066400000000000000000000007501456137173500177360ustar00rootroot00000000000000# frozen_string_literal: true require 'bundler/gem_tasks' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) do |t| t.exclude_pattern = "spec/acceptance/**/*.rb" end namespace :spec do desc 'Run RSpec code examples with coverage collection' task :coverage do ENV['COVERAGE'] = 'yes' Rake::Task['spec'].execute end end RSpec::Core::RakeTask.new(:acceptance) do |t| t.pattern = "spec/acceptance/**/*.rb" end require 'yard' YARD::Rake::YardocTask.new puppetlabs_spec_helper-7.0.5/lib/000077500000000000000000000000001456137173500170355ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/000077500000000000000000000000001456137173500235655ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/module_spec_helper.rb000066400000000000000000000052541456137173500277560ustar00rootroot00000000000000# frozen_string_literal: true require 'rspec-puppet' require 'puppetlabs_spec_helper/puppet_spec_helper' require 'puppetlabs_spec_helper/puppetlabs_spec/puppet_internals' def param_value(subject, type, title, param) subject.resource(type, title).send(:parameters)[param.to_sym] end def verify_contents(subject, title, expected_lines) content = subject.resource('file', title).send(:parameters)[:content] expect(content.split("\n") & expected_lines).to match_array expected_lines.uniq end spec_path = File.expand_path(File.join(Dir.pwd, 'spec')) fixture_path = File.join(spec_path, 'fixtures') env_module_path = ENV.fetch('MODULEPATH', nil) module_path = File.join(fixture_path, 'modules') module_path = [module_path, env_module_path].join(File::PATH_SEPARATOR) if env_module_path if ENV['SIMPLECOV'] == 'yes' begin require 'simplecov' require 'simplecov-console' rescue LoadError raise 'Add the simplecov and simplecov-console gems to Gemfile to enable this task' end SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::Console ] begin require 'codecov' SimpleCov.formatters << SimpleCov::Formatter::Codecov rescue LoadError # continue without codecov, we could warn here but we want to avoid its use if possible end SimpleCov.start do track_files 'lib/**/*.rb' add_filter '/spec' # do not track vendored files add_filter '/vendor' add_filter '/.vendor' # do not track gitignored files # this adds about 4 seconds to the coverage check # this could definitely be optimized add_filter do |f| # system returns true if exit status is 0, which with git-check-ignore means file is ignored system("git check-ignore --quiet #{f.filename}") end end end # Add all spec lib dirs to LOAD_PATH components = module_path.split(File::PATH_SEPARATOR).map do |dir| next unless Dir.exist? dir Dir.entries(dir).grep_v(/^\./).map { |f| File.join(dir, f, 'spec', 'lib') } end components.compact.flatten.each do |d| $LOAD_PATH << d if FileTest.directory?(d) && !$LOAD_PATH.include?(d) end RSpec.configure do |c| c.formatter = 'RSpec::Github::Formatter' if ENV['GITHUB_ACTIONS'] == 'true' c.environmentpath = spec_path c.module_path = module_path # https://github.com/puppetlabs/rspec-puppet#strict_variables c.strict_variables = ENV['STRICT_VARIABLES'] != 'no' # https://github.com/puppetlabs/rspec-puppet#ordering c.ordering = ENV['ORDERING'] if ENV['ORDERING'] c.before :each do if c.mock_framework.framework_name == :rspec allow(Puppet.features).to receive(:root?).and_return(true) else Puppet.features.stubs(:root?).returns(true) end end end puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/puppet_spec_helper.rb000066400000000000000000000074461456137173500300130ustar00rootroot00000000000000# frozen_string_literal: true require 'puppetlabs_spec_helper/puppetlabs_spec_helper' # Don't want puppet getting the command line arguments for rake or autotest ARGV.clear require 'puppet' require 'rspec/expectations' # Detect whether the module is overriding the choice of mocking framework # @mock_framework is used since more than seven years, and we need to avoid # `mock_framework`'s autoloading to distinguish between the default, and # the module's choice. # See also below in RSpec.configure if RSpec.configuration.instance_variable_get(:@mock_framework).nil? # This is needed because we're using mocha with rspec instead of Test::Unit or MiniTest ENV['MOCHA_OPTIONS'] = 'skip_integration' # Current versions of RSpec already load this for us, but who knows what's used out there? require 'mocha/api' end require 'pathname' require 'tmpdir' require 'puppetlabs_spec_helper/puppetlabs_spec/files' ###################################################################################### # WARNING # ###################################################################################### # # You should probably be frightened by this file. :) # # The goal of this file is to try to maximize spec-testing compatibility between # multiple versions of various external projects (which depend on puppet core) and # multiple versions of puppet core itself. This is accomplished via a series # of hacks and magical incantations that I am not particularly proud of. However, # after discussion it was decided that the goal of achieving compatibility was # a very worthy one, and that isolating the hacks to one place in a non-production # project was as good a solution as we could hope for. # # You may want to hold your nose before you proceed. :) # # Here we attempt to load the new TestHelper API, and print a warning if we are falling back # to compatibility mode for older versions of puppet. begin require 'puppet/test/test_helper' rescue LoadError # Continue gracefully end # And here is where we do the main rspec configuration / setup. RSpec.configure do |config| # Detect whether the module is overriding the choice of mocking framework # @mock_framework is used since more than seven years, and we need to avoid # `mock_framework`'s autoloading to distinguish between the default, and # the module's choice. config.mock_with :rspec if config.instance_variable_get(:@mock_framework).nil? # Here we do some general setup that is relevant to all initialization modes, regardless # of the availability of the TestHelper API. config.before :each do # Here we redirect logging away from console, because otherwise the test output will be # obscured by all of the log output. # # TODO: in a more sane world, we'd move this logging redirection into our TestHelper # class, so that it was not coupled with a specific testing framework (rspec in this # case). Further, it would be nicer and more portable to encapsulate the log messages # into an object somewhere, rather than slapping them on an instance variable of the # actual test class--which is what we are effectively doing here. # # However, because there are over 1300 tests that are written to expect # this instance variable to be available--we can't easily solve this problem right now. @logs = [] Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs)) @log_level = Puppet::Util::Log.level end config.after :each do # clean up after the logging changes that we made before each test. # TODO: this should be abstracted in the future--see comments above the '@logs' block in the # "before" code above. @logs.clear Puppet::Util::Log.close_all Puppet::Util::Log.level = @log_level end end puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/puppetlabs_spec/000077500000000000000000000000001456137173500267565ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/puppetlabs_spec/files.rb000077500000000000000000000025761456137173500304220ustar00rootroot00000000000000# frozen_string_literal: true require 'fileutils' require 'tempfile' require 'pathname' module PuppetlabsSpec # A support module for testing files. module Files # This code exists only to support tests that run as root, pretty much. # Once they have finally been eliminated this can all go... --daniel 2011-04-08 def self.in_tmp(path) tempdir = Dir.tmpdir Pathname.new(path).ascend do |dir| return true if File.identical?(tempdir, dir) end false end def self.cleanup $global_tempfiles ||= [] while (path = $global_tempfiles.pop) raise "Not deleting tmpfile #{path} outside regular tmpdir" unless in_tmp(path) begin FileUtils.rm_r path, secure: true rescue Errno::ENOENT # nothing to do end end end def make_absolute(path) path = File.expand_path(path) path[0] = 'c' if Puppet.features.microsoft_windows? path end def tmpfilename(name) # Generate a temporary file, just for the name... source = Tempfile.new(name) path = source.path source.close! # ...record it for cleanup, $global_tempfiles ||= [] $global_tempfiles << File.expand_path(path) # ...and bam. path end def tmpdir(name) path = tmpfilename(name) FileUtils.mkdir_p(path) path end end end puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/puppetlabs_spec/fixtures.rb000077500000000000000000000033321456137173500311600ustar00rootroot00000000000000# frozen_string_literal: true module PuppetlabsSpec # This module provides some helper methods to assist with fixtures. It's # methods are designed to help when you have a conforming fixture layout so we # get project consistency. module Fixtures # Returns the joined path of the global FIXTURE_DIR plus any path given to it def fixtures(*rest) File.join(PuppetlabsSpec::FIXTURE_DIR, *rest) end # Returns the path to your relative fixture dir. So if your spec test is # /spec/unit/facter/foo_spec.rb then your relative dir will be # /spec/fixture/unit/facter/foo def my_fixture_dir callers = caller while (line = callers.shift) next unless (found = line.match(%r{/spec/(.*)_spec\.rb:})) return fixtures(found[1]) end raise "sorry, I couldn't work out your path from the caller stack!" end # Given a name, returns the full path of a file from your relative fixture # dir as returned by my_fixture_dir. def my_fixture(name) file = File.join(my_fixture_dir, name) raise "fixture '#{name}' for #{my_fixture_dir} is not readable" unless File.readable? file file end # Return the contents of the file using read when given a name. Uses # my_fixture to work out the relative path. def my_fixture_read(name) File.read(my_fixture(name)) end # Provides a block mechanism for iterating across the files in your fixture # area. def my_fixtures(glob = '*', flags = 0, &block) files = Dir.glob(File.join(my_fixture_dir, glob), flags) raise "fixture '#{glob}' for #{my_fixture_dir} had no files!" if files.empty? block && files.each(&block) files end end end puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/puppetlabs_spec/matchers.rb000066400000000000000000000030751456137173500311160ustar00rootroot00000000000000# frozen_string_literal: true require 'stringio' require 'rspec/expectations' # Custom matchers... RSpec::Matchers.define :have_matching_element do |expected| match do |actual| actual.any? { |item| item =~ expected } end end RSpec::Matchers.define :exit_with do |expected| actual = nil match do |block| begin block.call rescue SystemExit => e actual = e.status end actual && actual == expected end failure_message_for_should do |_block| "expected exit with code #{expected} but " + (actual.nil? ? ' exit was not called' : "we exited with #{actual} instead") end failure_message_for_should_not do |_block| "expected that exit would not be called with #{expected}" end description do "expect exit with #{expected}" end end RSpec::Matchers.define :have_printed do |expected| match do |block| $stderr = $stdout = StringIO.new begin block.call ensure $stdout.rewind @actual = $stdout.read $stdout = STDOUT $stderr = STDERR end if @actual case expected when String @actual.include? expected when Regexp expected.match @actual else raise ArgumentError, "No idea how to match a #{@actual.class.name}" end end end failure_message_for_should do |actual| if actual.nil? "expected #{expected.inspect}, but nothing was printed" else "expected #{expected.inspect} to be printed; got:\n#{actual}" end end description do "expect #{expected.inspect} to be printed" end diffable end puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals.rb000066400000000000000000000030541456137173500327010ustar00rootroot00000000000000# frozen_string_literal: true # Initialize puppet for testing by loading the # 'puppetlabs_spec_helper/puppet_spec_helper' library require 'puppetlabs_spec_helper/puppet_spec_helper' module PuppetlabsSpec # PuppetInternals provides a set of methods that interface # with internal puppet implementations. module PuppetInternals def resource(parts = {}) resource_type = parts[:type] || :hostclass resource_name = parts[:name] || 'testing' Puppet::Resource::Type.new(resource_type, resource_name) end module_function :resource def compiler(parts = {}) compiler_node = parts[:node] || node Puppet::Parser::Compiler.new(compiler_node) end module_function :compiler def node(parts = {}) node_name = parts[:name] || 'testinghost' options = parts[:options] || {} node_environment = Puppet::Node::Environment.create(parts[:environment] || 'test', []) options[:environment] = node_environment Puppet::Node.new(node_name, options) end module_function :node # Return a method instance for a given function. This is primarily useful # for rspec-puppet def function_method(name, parts = {}) scope = parts[:scope] || scope() # Ensure the method instance is defined by side-effect of checking if it # exists. This is a hack, but at least it's a hidden hack and not an # exposed hack. return nil unless Puppet::Parser::Functions.function(name) scope.method("function_#{name}".to_sym) end module_function :function_method end end puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/puppetlabs_spec_helper.rb000066400000000000000000000020541456137173500306430ustar00rootroot00000000000000# frozen_string_literal: true # Define the main module namespace for use by the helper modules module PuppetlabsSpec # FIXTURE_DIR represents the standard locations of all fixture data. Normally # this represents /spec/fixtures. This will be used by the fixtures # library to find relative fixture data. FIXTURE_DIR = File.join('spec', 'fixtures') unless defined?(FIXTURE_DIR) end # Require all necessary helper libraries so they can be used later require 'puppetlabs_spec_helper/puppetlabs_spec/files' require 'puppetlabs_spec_helper/puppetlabs_spec/fixtures' require 'puppetlabs_spec_helper/puppetlabs_spec/puppet_internals' require 'puppetlabs_spec_helper/puppetlabs_spec/matchers' RSpec.configure do |config| # Include PuppetlabsSpec helpers so they can be called at convenience config.extend PuppetlabsSpec::Files config.extend PuppetlabsSpec::Fixtures config.include PuppetlabsSpec::Fixtures # This will cleanup any files that were created with tmpdir or tmpfile config.after :each do PuppetlabsSpec::Files.cleanup end end puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/rake_tasks.rb000066400000000000000000000315221456137173500262440ustar00rootroot00000000000000# frozen_string_literal: true require 'fileutils' require 'rake' require 'rspec/core/rake_task' require 'tmpdir' require 'pathname' require 'puppetlabs_spec_helper/version' require 'puppetlabs_spec_helper/tasks/fixtures' require 'puppetlabs_spec_helper/tasks/check_symlinks' require 'English' # optional gems begin require 'metadata-json-lint/rake_task' rescue LoadError # ignore end begin require 'puppet_blacksmith/rake_tasks' rescue LoadError # ignore end begin require 'github_changelog_generator/task' rescue LoadError # ignore end begin require 'puppet-strings/tasks' rescue LoadError # ignore end parallel_tests_loaded = false begin require 'parallel_tests' parallel_tests_loaded = true rescue LoadError # ignore end task default: [:help] pattern = 'spec/{aliases,classes,defines,functions,hosts,integration,plans,tasks,type_aliases,types,unit}/**/*_spec.rb' RSpec::Core::RakeTask.new(:spec_standalone) do |t, args| t.rspec_opts = [] t.rspec_opts << ENV['CI_SPEC_OPTIONS'] unless ENV['CI_SPEC_OPTIONS'].nil? if ENV['CI_NODE_TOTAL'] && ENV['CI_NODE_INDEX'] ci_total = ENV['CI_NODE_TOTAL'].to_i ci_index = ENV['CI_NODE_INDEX'].to_i raise "CI_NODE_INDEX must be between 1-#{ci_total}" unless ci_index >= 1 && ci_index <= ci_total files = Rake::FileList[pattern].to_a per_node = (files.size / ci_total.to_f).ceil t.pattern = if args.extras.nil? || args.extras.empty? files.each_slice(per_node).to_a[ci_index - 1] || files.first else args.extras.join(',') end else t.pattern = if args.extras.nil? || args.extras.empty? pattern else args.extras.join(',') end end end desc 'List spec tests in a JSON document' RSpec::Core::RakeTask.new(:spec_list_json) do |t| t.rspec_opts = ['--dry-run', '--format', 'json'] t.pattern = pattern end desc 'Run spec tests and clean the fixtures directory if successful' task :spec do |_t, args| Rake::Task[:spec_prep].invoke Rake::Task[:spec_standalone].invoke(*args.extras) Rake::Task[:spec_clean].invoke ensure Rake::Task[:spec_clean_symlinks].invoke end desc 'Run spec tests with ruby simplecov code coverage' namespace :spec do task :simplecov do ENV['SIMPLECOV'] = 'yes' Rake::Task['spec'].execute end end desc 'Run spec tests in parallel and clean the fixtures directory if successful' task :parallel_spec do |_t, args| Rake::Task[:spec_prep].invoke Rake::Task[:parallel_spec_standalone].invoke(*args.extras) Rake::Task[:spec_clean].invoke ensure Rake::Task[:spec_clean_symlinks].invoke end desc 'Parallel spec tests' task :parallel_spec_standalone do |_t, args| raise 'Add the parallel_tests gem to Gemfile to enable this task' unless parallel_tests_loaded if Rake::FileList[pattern].to_a.empty? warn 'No files for parallel_spec to run against' else args = ['-t', 'rspec'] args.push('--').concat(ENV['CI_SPEC_OPTIONS'].strip.split).push('--') unless ENV['CI_SPEC_OPTIONS'].nil? || ENV['CI_SPEC_OPTIONS'].strip.empty? args.concat(Rake::FileList[pattern].to_a) ParallelTests::CLI.new.run(args) end end desc 'Build puppet module package' task :build do Rake::Task['build:pdk'].invoke end namespace :build do desc 'Build Puppet module with PDK' task :pdk do require 'pdk/util' require 'pdk/module/build' path = PDK::Module::Build.invoke(force: true, 'target-dir': File.join(Dir.pwd, 'pkg')) puts "Module built: #{path}" rescue LoadError _ = `pdk --version` unless $CHILD_STATUS.success? warn 'Unable to build module. Please install PDK or add the `pdk` gem to your Gemfile.' abort end system('pdk build --force') end end desc 'Clean a built module package' task :clean do FileUtils.rm_rf('pkg/') end require 'puppet-lint/tasks/puppet-lint' # Must clear as it will not override the existing puppet-lint rake task since we require to import for # the PuppetLint::RakeTask Rake::Task[:lint].clear PuppetLint.configuration.fail_on_warnings = true # Utilize PuppetLint global configuration so that these settings can be tweaked by # spec_helper.rb in an individual module PuppetLint.configuration.relative = true PuppetLint.configuration.ignore_paths ||= [] PuppetLint.configuration.ignore_paths << '.vendor/**/*.pp' PuppetLint.configuration.ignore_paths << 'bundle/**/*.pp' PuppetLint.configuration.ignore_paths << 'pkg/**/*.pp' PuppetLint.configuration.ignore_paths << 'spec/**/*.pp' PuppetLint.configuration.ignore_paths << 'tests/**/*.pp' PuppetLint.configuration.ignore_paths << 'types/**/*.pp' PuppetLint.configuration.ignore_paths << 'vendor/**/*.pp' puppet_lint_disable_checks = %w[ 80chars 140chars class_inherits_from_params_class class_parameter_defaults disable_autoloader_layout documentation single_quote_string_with_variables ] puppet_lint_disable_checks.each do |check| PuppetLint.configuration.send(:"disable_#{check}") end PuppetLint::RakeTask.new(:lint) desc 'Run puppet-lint and fix issues automatically' PuppetLint::RakeTask.new(:lint_fix) do |config| config.fix = true end require 'puppet-syntax/tasks/puppet-syntax' PuppetSyntax.exclude_paths ||= [] PuppetSyntax.exclude_paths << 'spec/fixtures/**/*' PuppetSyntax.exclude_paths << 'pkg/**/*' PuppetSyntax.exclude_paths << 'vendor/**/*' PuppetSyntax.exclude_paths << '.vendor/**/*' PuppetSyntax.exclude_paths << 'plans/**/*' desc 'Check syntax of Ruby files and call :syntax and :metadata_lint' task :validate do Dir['lib/**/*.rb'].each do |lib_file| sh "ruby -c #{lib_file}" end Rake::Task[:syntax].invoke if File.exist?('metadata.json') if Rake::Task.task_defined?(:metadata_lint) Rake::Task[:metadata_lint].invoke else warn 'Skipping metadata validation; the metadata-json-lint gem was not found' end end if File.exist?('REFERENCE.md') if Rake::Task.task_defined?('strings:validate:reference') Rake::Task['strings:validate:reference'].invoke else warn 'Skipping reference documentation validation; the puppet-strings gem was not found' end end end desc 'Print development version of module' task :compute_dev_version do version = '' if File.exist?('metadata.json') require 'json' modinfo = JSON.parse(File.read('metadata.json')) version = modinfo['version'] elsif File.exist?('Modulefile') modfile = File.read('Modulefile') version = modfile.match(/\nversion +['"](.*)['"]/)[1] else raise 'Could not find a metadata.json or Modulefile! Cannot compute dev version without one or the other!' end sha = `git rev-parse HEAD`[0..7] branch = `git rev-parse --abbrev-ref HEAD` # If we're in a CI environment include our build number # If the branch is a release branch we append an 'r' into the new_version, # this is due to the release branch buildID conflicting with main branch when trying to push to the staging forge. # More info can be found at https://tickets.puppetlabs.com/browse/FM-6170 new_version = if (build = ENV.fetch('BUILD_NUMBER', nil)) if branch.eql? 'release' format('%s-%s%04d-%s', version, 'r', build, sha) # legacy support code else format('%s-%04d-%s', version, build, sha) # legacy support code end else "#{version}-#{sha}" end print new_version end desc 'Runs all necessary checks on a module in preparation for a release' task :release_checks do Rake::Task[:lint].invoke Rake::Task[:validate].invoke if parallel_tests_loaded Rake::Task[:parallel_spec].invoke else Rake::Task[:spec].invoke end Rake::Task[:check].invoke end namespace :check do desc 'Fails if symlinks are present in directory' task :symlinks do symlinks = PuppetlabsSpecHelper::Tasks::CheckSymlinks.new.check unless symlinks.empty? symlinks.each { |r| puts "Symlink found: #{r} => #{r.readlink}" } raise 'Symlink(s) exist within this directory' end end desc 'Fails if .pp files present in tests folder' task :test_file do ppfiles = Dir[File.join('tests', '**', '*.pp')] unless ppfiles.empty? puts ppfiles raise '.pp files present in tests folder; Move them to an examples folder following the new convention' end end desc 'Fails if any ._ files are present in directory' task :dot_underscore do dirs = Dir['._*'] unless dirs.empty? puts dirs raise '._ files are present in the directory' end end desc 'Fails if directories contain the files specified in .gitignore' task :git_ignore do matched = `git ls-files --ignored --exclude-standard --cached` raise 'git ls-files failed' unless $CHILD_STATUS.success? unless matched == '' puts matched raise 'File specified in .gitignore has been committed' end end end desc 'Run static pre release checks' task check: ['check:symlinks', 'check:test_file', 'check:dot_underscore', 'check:git_ignore'] desc 'Display the list of available rake tasks' task :help do system('rake -T') end begin require 'rubocop/rake_task' RuboCop::RakeTask.new(:rubocop) do |task| # These make the rubocop experience maybe slightly less terrible task.options = ['-D', '-S', '-E'] # Use Rubocop's Github Actions formatter if possible if ENV['GITHUB_ACTIONS'] == 'true' rubocop_spec = Gem::Specification.find_by_name('rubocop') task.formatters << 'github' if Gem::Version.new(rubocop_spec.version) >= Gem::Version.new('1.2') end end rescue LoadError desc 'rubocop is not available in this installation' task :rubocop do raise 'rubocop is not available in this installation' end end def create_gch_task(changelog_user = nil, changelog_project = nil, changelog_since_tag = nil, changelog_tag_pattern = 'v%s') if Bundler.rubygems.find_name('github_changelog_generator').any? # needed a place to hide these methods # rubocop:disable Lint/NestedMethodDefinition def changelog_user_from_metadata result = JSON.parse(File.read('metadata.json'))['author'] raise 'unable to find the changelog_user in .sync.yml, or the author in metadata.json' if result.nil? puts "GitHubChangelogGenerator user:#{result}" result end def changelog_project_from_metadata result = JSON.parse(File.read('metadata.json'))['name'] raise 'unable to find the changelog_project in .sync.yml or the name in metadata.json' if result.nil? puts "GitHubChangelogGenerator project:#{result}" result end def changelog_future_release return unless Rake.application.top_level_tasks.include? 'changelog' result = JSON.parse(File.read('metadata.json'))['version'] raise 'unable to find the future_release (version) in metadata.json' if result.nil? puts "GitHubChangelogGenerator future_release:#{result}" result end # rubocop:enable Lint/NestedMethodDefinition GitHubChangelogGenerator::RakeTask.new :changelog do |config| raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if ENV['CHANGELOG_GITHUB_TOKEN'].nil? config.user = changelog_user || changelog_user_from_metadata config.project = changelog_project || changelog_project_from_metadata config.since_tag = changelog_since_tag if changelog_since_tag config.future_release = changelog_tag_pattern % changelog_future_release.to_s config.exclude_labels = ['maintenance'] config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. " \ 'The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres ' \ 'to [Semantic Versioning](https://semver.org).' config.add_pr_wo_labels = true config.issues = false config.merge_prefix = '### UNCATEGORIZED PRS; GO LABEL THEM' config.configure_sections = { 'Changed' => { 'prefix' => '### Changed', 'labels' => ['backwards-incompatible'] }, 'Added' => { 'prefix' => '### Added', 'labels' => %w[feature enhancement] }, 'Fixed' => { 'prefix' => '### Fixed', 'labels' => ['bugfix'] } } end else desc 'Generate a Changelog from GitHub' task :changelog do raise <<~MESSAGE The changelog tasks depends on unreleased features of the github_changelog_generator gem. Please manually add it to your .sync.yml for now, and run `pdk update`: --- Gemfile: optional: ':development': - gem: 'github_changelog_generator' git: 'https://github.com/skywinder/github-changelog-generator' ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')" MESSAGE end end end puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/tasks/000077500000000000000000000000001456137173500247125ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/tasks/check_symlinks.rb000066400000000000000000000023171456137173500302500ustar00rootroot00000000000000# frozen_string_literal: true require 'pathspec' module PuppetlabsSpecHelper module Tasks # Helpers for validating symlinks. class CheckSymlinks DEFAULT_IGNORED = [ '/.git/', '/.bundle/', '/vendor/' ].freeze IGNORE_LIST_FILES = [ '.pdkignore', '.gitignore' ].freeze def check(dir = Dir.pwd) dir = Pathname.new(dir) unless dir.is_a?(Pathname) results = [] dir.each_child(true) do |child| next if ignored?(child.to_s) if child.symlink? results << child elsif child.directory? && child.basename.to_s !~ /^(\.git|\.?bundle)$/ results.concat(check(child)) end end results end def ignored?(path) path = "#{path}/" if File.directory?(path) !ignore_pathspec.match_paths([path], Dir.pwd).empty? end def ignore_pathspec @ignore_pathspec ||= PathSpec.new(DEFAULT_IGNORED).tap do |pathspec| IGNORE_LIST_FILES.each do |f| next unless File.file?(f) && File.readable?(f) File.open(f, 'r') { |fd| pathspec.add(fd) } end end end end end end puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/tasks/fixtures.rb000066400000000000000000000404041456137173500271120ustar00rootroot00000000000000# frozen_string_literal: true require 'yaml' require 'open3' require 'json' module PuppetlabsSpecHelper module Tasks # Helpers for working with fixtures. module FixtureHelpers # This is a helper for the self-symlink entry of fixtures.yml def source_dir Dir.pwd end # @return [String] - the name of current module def module_name raise ArgumentError unless File.file?('metadata.json') && File.readable?('metadata.json') metadata = JSON.parse(File.read('metadata.json')) metadata_name = metadata.fetch('name', nil) || '' raise ArgumentError if metadata_name.empty? metadata_name.split('-').last rescue JSON::ParserError, ArgumentError File.basename(Dir.pwd).split('-').last end def module_version(path) metadata_path = File.join(path, 'metadata.json') raise ArgumentError unless File.file?(metadata_path) && File.readable?(metadata_path) metadata = JSON.parse(File.read(metadata_path)) metadata.fetch('version', nil) || '0.0.1' rescue JSON::ParserError, ArgumentError logger.warn "Failed to find module version at path #{path}" '0.0.1' end # @return [Hash] - returns a hash of all the fixture repositories # @example # {"puppetlabs-stdlib"=>{"target"=>"https://gitlab.com/puppetlabs/puppet-stdlib.git", # "ref"=>nil, "branch"=>"main", "scm"=>nil, # }} def repositories @repositories ||= fixtures('repositories') || {} end # @return [Hash] - returns a hash of all the fixture forge modules # @example # {"puppetlabs-stdlib"=>{"target"=>"spec/fixtures/modules/stdlib", # "ref"=>nil, "branch"=>nil, "scm"=>nil, # "flags"=>"--module_repository=https://myforge.example.com/", "subdir"=>nil}} def forge_modules @forge_modules ||= fixtures('forge_modules') || {} end # @return [Hash] - a hash of symlinks specified in the fixtures file def symlinks @symlinks ||= fixtures('symlinks') || {} end # @return [Hash] - returns a hash with the module name and the source directory def auto_symlink { module_name => "\#{source_dir}" } end # @return [Boolean] - true if the os is a windows system def windows? !!File::ALT_SEPARATOR end def fixtures(category) fixtures_yaml = if ENV['FIXTURES_YML'] ENV['FIXTURES_YML'] elsif File.exist?('.fixtures.yml') '.fixtures.yml' elsif File.exist?('.fixtures.yaml') '.fixtures.yaml' else false end begin fixtures = if fixtures_yaml YAML.load_file(fixtures_yaml) || { 'fixtures' => {} } else { 'fixtures' => {} } end rescue Errno::ENOENT raise("Fixtures file not found: '#{fixtures_yaml}'") rescue Psych::SyntaxError => e raise("Found malformed YAML in '#{fixtures_yaml}' on line #{e.line} column #{e.column}: #{e.problem}") end unless fixtures.include?('fixtures') # File is non-empty, but does not specify fixtures raise("No 'fixtures' entries found in '#{fixtures_yaml}'; required") end fixture_defaults = if fixtures.include? 'defaults' fixtures['defaults'] else {} end fixtures = fixtures['fixtures'] fixtures['symlinks'] = fixtures['symlinks'].nil? || fixtures['symlinks'].empty? ? auto_symlink : auto_symlink.merge!(fixtures['symlinks']) result = {} if fixtures.include?(category) && !fixtures[category].nil? defaults = { 'target' => 'spec/fixtures/modules' } # load defaults from the `.fixtures.yml` `defaults` section # for the requested category and merge them into my defaults defaults = defaults.merge(fixture_defaults[category]) if fixture_defaults.include? category fixtures[category].each do |fixture, opts| # convert a simple string fixture to a hash, by # using the string fixture as the `repo` option of the hash. opts = { 'repo' => opts } if opts.instance_of?(String) # there should be a warning or something if it's not a hash... next unless opts.instance_of?(Hash) # merge our options into the defaults to get the # final option list opts = defaults.merge(opts) next unless include_repo?(opts['puppet_version']) real_target = eval("\"#{opts['target']}\"", binding, __FILE__, __LINE__) # evaluating target reference in this context (see auto_symlink) real_source = eval("\"#{opts['repo']}\"", binding, __FILE__, __LINE__) # evaluating repo reference in this context (see auto_symlink) result[real_source] = validate_fixture_hash!( 'target' => File.join(real_target, fixture), 'ref' => opts['ref'] || opts['tag'], 'branch' => opts['branch'], 'scm' => opts['scm'], 'flags' => opts['flags'], 'subdir' => opts['subdir'], ) end end result end def validate_fixture_hash!(hash) # Can only validate git based scm return hash unless hash['scm'] == 'git' # Forward slashes in the ref aren't allowed. And is probably a branch name. raise ArgumentError, "The ref for #{hash['target']} is invalid (Contains a forward slash). If this is a branch name, please use the 'branch' setting instead." if hash['ref']&.include?('/') hash end def include_repo?(version_range) if version_range && defined?(SemanticPuppet) puppet_spec = Gem::Specification.find_by_name('puppet') puppet_version = SemanticPuppet::Version.parse(puppet_spec.version.to_s) constraint = SemanticPuppet::VersionRange.parse(version_range) constraint.include?(puppet_version) else true end end def clone_repo(scm, remote, target, _subdir = nil, ref = nil, branch = nil, flags = nil) args = [] case scm when 'hg' args.push('clone') args.push('-b', branch) if branch args.push(flags) if flags args.push(remote, target) when 'git' args.push('clone') args.push('--depth 1') unless ref args.push('-b', branch) if branch args.push(flags) if flags args.push(remote, target) else raise "Unfortunately #{scm} is not supported yet" end result = system("#{scm} #{args.flatten.join ' '}") raise "Failed to clone #{scm} repository #{remote} into #{target}" unless File.exist?(target) result end def update_repo(scm, target) args = case scm when 'hg' ['pull'] when 'git' ['fetch'].tap do |git_args| git_args << '--unshallow' if shallow_git_repo? end else raise "Unfortunately #{scm} is not supported yet" end system("#{scm} #{args.flatten.join(' ')}", chdir: target) end def shallow_git_repo? File.file?(File.join('.git', 'shallow')) end def revision(scm, target, ref) args = [] case scm when 'hg' args.push('update', '--clean', '-r', ref) when 'git' args.push('reset', '--hard', ref) else raise "Unfortunately #{scm} is not supported yet" end result = system("#{scm} #{args.flatten.join ' '}", chdir: target) raise "Invalid ref #{ref} for #{target}" unless result end def valid_repo?(scm, target, remote) return false unless File.directory?(target) return true if scm == 'hg' return true if git_remote_url(target) == remote warn "Git remote for #{target} has changed, recloning repository" FileUtils.rm_rf(target) false end def git_remote_url(target) output, status = Open3.capture2e('git', '--git-dir', File.join(target, '.git'), 'ls-remote', '--get-url', 'origin') status.success? ? output.strip : nil end def remove_subdirectory(target, subdir) return if subdir.nil? Dir.mktmpdir do |tmpdir| FileUtils.mv(Dir.glob("#{target}/#{subdir}/{.[^.]*,*}"), tmpdir) FileUtils.rm_rf("#{target}/#{subdir}") FileUtils.mv(Dir.glob("#{tmpdir}/{.[^.]*,*}"), target.to_s) end end # creates a logger so we can log events with certain levels def logger unless @logger require 'logger' level = if ENV['ENABLE_LOGGER'] Logger::DEBUG else Logger::INFO end @logger = Logger.new($stderr) @logger.level = level end @logger end def module_working_directory # The problem with the relative path is that PMT doesn't expand the path properly and so passing in a relative path here # becomes something like C:\somewhere\backslashes/spec/fixtures/work-dir on Windows, and then PMT barfs itself. # This has been reported as https://tickets.puppetlabs.com/browse/PUP-4884 File.expand_path(ENV['MODULE_WORKING_DIR'] || 'spec/fixtures/work-dir') end # returns the current thread count that is currently active # a status of false or nil means the thread completed # so when anything else we count that as a active thread # @return [Integer] - current thread count def current_thread_count(items) active_threads = items.select do |_item, opts| if opts[:thread] opts[:thread].status else false end end logger.debug "Current thread count #{active_threads.count}" active_threads.count end # @summary Set a limit on the amount threads used, defaults to 10 # MAX_FIXTURE_THREAD_COUNT can be used to set this limit # @return [Integer] - returns the max_thread_count def max_thread_limit @max_thread_limit ||= (ENV['MAX_FIXTURE_THREAD_COUNT'] || 10).to_i end # @param items [Hash] - a hash of either repositories or forge modules # @param [Block] - the method you wish to use to download the item def download_items(items) items.each do |remote, opts| # get the current active threads that are alive count = current_thread_count(items) if count < max_thread_limit logger.debug "New Thread started for #{remote}" # start up a new thread and store it in the opts hash opts[:thread] = Thread.new do yield(remote, opts) end else # the last thread started should be the longest wait # Rubocop seems to push towards using select here.. however the implementation today relies on the result being # an array. Select returns a hash which makes it unsuitable so we need to use find_all.last. item, item_opts = items.find_all { |_i, o| o.key?(:thread) }.last # rubocop:disable Performance/Detect logger.debug "Waiting on #{item}" item_opts[:thread].join # wait for the thread to finish # now that we waited lets try again redo end end # wait for all the threads to finish items.each { |_remote, opts| opts[:thread].join } end # @param target [String] - the target directory # @param link [String] - the name of the link you wish to create # works on windows and linux def setup_symlink(target, link) link = link['target'] return if File.symlink?(link) logger.info("Creating symlink from #{link} to #{target}") if windows? target = File.join(File.dirname(link), target) unless Pathname.new(target).absolute? if Dir.respond_to?(:create_junction) Dir.create_junction(link, target) else system("call mklink /J \"#{link.tr('/', '\\')}\" \"#{target.tr('/', '\\')}\"") end else FileUtils.ln_sf(target, link) end end # @return [Boolean] - returns true if the module was downloaded successfully, false otherwise # @param [String] - the remote url or namespace/name of the module to download # @param [Hash] - list of options such as version, branch, ref def download_repository(remote, opts) scm = 'git' target = opts['target'] subdir = opts['subdir'] ref = opts['ref'] scm = opts['scm'] if opts['scm'] branch = opts['branch'] if opts['branch'] flags = opts['flags'] if valid_repo?(scm, target, remote) update_repo(scm, target) else clone_repo(scm, remote, target, subdir, ref, branch, flags) end revision(scm, target, ref) if ref remove_subdirectory(target, subdir) if subdir end # @return [String] - the spec/fixtures/modules directory in the module root folder def module_target_dir @module_target_dir ||= File.expand_path('spec/fixtures/modules') end # @return [Boolean] - returns true if the module was downloaded successfully, false otherwise # @param [String] - the remote url or namespace/name of the module to download # @param [Hash] - list of options such as version def download_module(remote, opts) ref = '' flags = '' if opts.instance_of?(String) target = opts elsif opts.instance_of?(Hash) target = opts['target'] ref = " --version #{opts['ref']}" unless opts['ref'].nil? flags = " #{opts['flags']}" if opts['flags'] end return false if File.directory?(target) && (ref.empty? || opts['ref'] == module_version(target)) # The PMT cannot handle multi threaded runs due to cache directory collisons # so we randomize the directory instead. # Does working_dir even need to be passed? Dir.mktmpdir do |working_dir| command = "puppet module install#{ref}#{flags} --ignore-dependencies " \ '--force ' \ "--module_working_dir \"#{working_dir}\" " \ "--target-dir \"#{module_target_dir}\" \"#{remote}\"" raise "Failed to install module #{remote} to #{module_target_dir}" unless system(command) end $CHILD_STATUS.success? end end end end include PuppetlabsSpecHelper::Tasks::FixtureHelpers # DSL include desc 'Create the fixtures directory' task :spec_prep do # Ruby only sets File::ALT_SEPARATOR on Windows and Rubys standard library # uses this to check for Windows if windows? begin require 'win32/dir' rescue LoadError warn 'win32-dir gem not installed, falling back to executing mklink directly' end end # git has a race condition creating that directory, that would lead to aborted clone operations FileUtils.mkdir_p('spec/fixtures/modules') symlinks.each { |target, link| setup_symlink(target, link) } download_items(repositories) { |remote, opts| download_repository(remote, opts) } download_items(forge_modules) { |remote, opts| download_module(remote, opts) } FileUtils.mkdir_p('spec/fixtures/manifests') FileUtils.touch('spec/fixtures/manifests/site.pp') end desc 'Clean up the fixtures directory' task :spec_clean do repositories.each do |_remote, opts| target = opts['target'] FileUtils.rm_rf(target) end forge_modules.each do |_remote, opts| target = opts['target'] FileUtils.rm_rf(target) end FileUtils.rm_rf(module_working_directory) Rake::Task[:spec_clean_symlinks].invoke FileUtils.rm_f('spec/fixtures/manifests/site.pp') if File.empty?('spec/fixtures/manifests/site.pp') end desc 'Clean up any fixture symlinks' task :spec_clean_symlinks do fixtures('symlinks').each do |_source, opts| target = opts['target'] FileUtils.rm_f(target) end end puppetlabs_spec_helper-7.0.5/lib/puppetlabs_spec_helper/version.rb000066400000000000000000000001231456137173500255730ustar00rootroot00000000000000# frozen_string_literal: true module PuppetlabsSpecHelper VERSION = '7.0.5' end puppetlabs_spec_helper-7.0.5/puppetlabs_spec_helper.gemspec000066400000000000000000000025601456137173500243670ustar00rootroot00000000000000# frozen_string_literal: true lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'puppetlabs_spec_helper/version' Gem::Specification.new do |spec| spec.name = 'puppetlabs_spec_helper' spec.version = PuppetlabsSpecHelper::VERSION spec.authors = ['Puppet, Inc.', 'Community Contributors'] spec.email = ['modules-team@puppet.com'] spec.summary = 'Standard tasks and configuration for module spec tests.' spec.description = 'Contains rake tasks and a standard spec_helper for running spec tests on puppet modules.' spec.homepage = 'http://github.com/puppetlabs/puppetlabs_spec_helper' spec.license = 'Apache-2.0' spec.files = Dir[ 'README.md', 'LICENSE', '.rubocop.yml', 'lib/**/*', 'bin/**/*', 'spec/**/*', ] spec.executables = Dir['bin/**/*'].map { |f| File.basename(f) } spec.require_paths = ['lib'] spec.required_ruby_version = Gem::Requirement.new('>= 2.7') spec.add_runtime_dependency 'mocha', '~> 1.0' spec.add_runtime_dependency 'pathspec', '>= 0.2', '< 2.0.0' spec.add_runtime_dependency 'puppet-lint', '~> 4.0' spec.add_runtime_dependency 'puppet-syntax', '~> 4.0' spec.add_runtime_dependency 'rspec-github', '~> 2.0' spec.add_runtime_dependency 'rspec-puppet', '~> 4.0' spec.requirements << 'puppet, >= 7.0.0' end puppetlabs_spec_helper-7.0.5/spec/000077500000000000000000000000001456137173500172215ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/spec/acceptance/000077500000000000000000000000001456137173500213075ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/spec/acceptance/fixtures/000077500000000000000000000000001456137173500231605ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/spec/acceptance/fixtures/Rakefile000066400000000000000000000001131456137173500246200ustar00rootroot00000000000000# frozen_string_literal: true require 'puppetlabs_spec_helper/rake_tasks' puppetlabs_spec_helper-7.0.5/spec/acceptance/smoke_spec.rb000066400000000000000000000005271456137173500237700ustar00rootroot00000000000000# frozen_string_literal: true require 'spec_helper' require 'open3' # some smoke tests to verify overall sanity RSpec.describe 'rake' do let(:output) do Open3.capture2e('rake', '--rakefile', 'spec/acceptance/fixtures/Rakefile', '-T') end it { expect(output[0]).to match(/spec_prep/) } it { expect(output[1]).to be_success } end puppetlabs_spec_helper-7.0.5/spec/spec_helper.rb000066400000000000000000000023571456137173500220460ustar00rootroot00000000000000# frozen_string_literal: true if ENV['COVERAGE'] == 'yes' begin require 'simplecov' require 'simplecov-console' rescue LoadError raise 'Add the simplecov and simplecov-console gems to Gemfile to enable this task' end SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::Console ] SimpleCov.start do track_files 'lib/**/*.rb' add_filter 'lib/puppetlabs_spec_helper/version.rb' add_filter '/spec' # do not track vendored files add_filter '/vendor' add_filter '/.vendor' end end require 'fakefs/spec_helpers' FakeFS::Pathname.class_eval do def symlink? File.symlink?(@path) end end require 'puppetlabs_spec_helper/puppet_spec_helper' require 'puppetlabs_spec_helper/puppetlabs_spec/puppet_internals' require 'puppetlabs_spec_helper/rake_tasks' RSpec.shared_context 'with a rake task', type: :task do subject(:task) { Rake::Task[task_name] } include FakeFS::SpecHelpers let(:task_name) { self.class.top_level_description.delete_prefix('rake ') } end # configure RSpec after including all the code RSpec.configure do |config| config.expect_with :rspec do |c| c.syntax = :expect end config.include_context 'with a rake task', type: :task end puppetlabs_spec_helper-7.0.5/spec/unit/000077500000000000000000000000001456137173500202005ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/spec/unit/puppetlabs_spec_helper/000077500000000000000000000000001456137173500247305ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/spec/unit/puppetlabs_spec_helper/puppetlabs_spec/000077500000000000000000000000001456137173500301215ustar00rootroot00000000000000puppet_internals_spec.rb000066400000000000000000000042521456137173500350000ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/spec/unit/puppetlabs_spec_helper/puppetlabs_spec# frozen_string_literal: true require 'spec_helper' require 'rspec-puppet' describe PuppetlabsSpec::PuppetInternals do before(:all) do # this is only needed once # rubocop:disable RSpec/BeforeAfterAll Puppet.initialize_settings end describe '.resource' do subject(:resource) { described_class.resource } it 'can have a defined type' do expect(described_class.resource(type: :node).type).to eq(:node) end it 'defaults to a type of hostclass' do expect(resource.type).to eq(:hostclass) end it 'can have a defined name' do expect(described_class.resource(name: 'testingrsrc').name).to eq('testingrsrc') end it 'defaults to a name of testing' do expect(resource.name).to eq('testing') end end describe '.compiler' do let(:node) { described_class.node } it 'can have a defined node' do expect(described_class.compiler(node: node).node).to be node end end describe '.node' do it 'can have a defined name' do expect(described_class.node(name: 'mine').name).to eq('mine') end it 'can have a defined environment' do expect(described_class.node(environment: 'mine').environment.name).to eq(:mine) end it 'defaults to a name of testinghost' do expect(described_class.node.name).to eq('testinghost') end it 'accepts facts via options for rspec-puppet' do fact_values = { 'fqdn' => 'jeff.puppetlabs.com' } node = described_class.node(options: { parameters: fact_values }) expect(node.parameters).to eq(fact_values) end end describe '.function_method', type: :puppet_function do it 'accepts an injected scope' do expect(Puppet::Parser::Functions).to receive(:function).with('my_func').and_return(true) expect(scope).to receive(:method).with(:function_my_func).and_return(:fake_method) expect(described_class.function_method('my_func', scope: scope)).to eq(:fake_method) end it "returns nil if the function doesn't exist" do expect(Puppet::Parser::Functions).to receive(:function).with('my_func').and_return(false) expect(described_class.function_method('my_func', scope: scope)).to be_nil end end end puppetlabs_spec_helper-7.0.5/spec/unit/puppetlabs_spec_helper/tasks/000077500000000000000000000000001456137173500260555ustar00rootroot00000000000000puppetlabs_spec_helper-7.0.5/spec/unit/puppetlabs_spec_helper/tasks/check_symlinks_spec.rb000066400000000000000000000072261456137173500324310ustar00rootroot00000000000000# frozen_string_literal: true require 'spec_helper' describe 'rake check:symlinks', type: :task do before do test_files.each do |f| FileUtils.mkdir_p(File.dirname(f)) FileUtils.touch(f) end symlinks.each do |link, target| FileUtils.mkdir_p(File.dirname(link)) FileUtils.ln_s(target, link) end end let(:test_files) { [] } let(:symlinks) { {} } let(:expected_output) do symlinks.map { |link, target| "Symlink found: #{link} => #{target}" }.join("\n") end context 'when there are no files' do it 'runs without raising an error' do expect { task.execute }.not_to raise_error end end context 'when there are regular files' do let(:test_files) do [ File.join(Dir.pwd, 'files', 'a_file.pp'), File.join(Dir.pwd, 'files', 'another_file.pp') ] end it 'runs without raising an error' do expect { task.execute }.not_to raise_error end end context 'when there is a symlink present' do let(:test_files) do [ File.join(Dir.pwd, 'files', 'a_file.pp') ] end let(:symlinks) do { File.join(Dir.pwd, 'files', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp') } end it 'raises an error' do expect { task.execute } .to raise_error(/symlink\(s\) exist/i) .and output(a_string_including(expected_output)).to_stdout end end context 'when there are symlinks under .git/' do let(:test_files) do [ File.join(Dir.pwd, 'files', 'a_file.pp') ] end let(:symlinks) do { File.join(Dir.pwd, '.git', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp') } end it 'runs without raising an error' do expect { task.execute }.not_to raise_error end end context 'when there are symlinks under .bundle/' do let(:test_files) do [ File.join(Dir.pwd, 'files', 'a_file.pp') ] end let(:symlinks) do { File.join(Dir.pwd, '.bundle', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp') } end it 'runs without raising an error' do expect { task.execute }.not_to raise_error end end context 'when there are symlinks under vendor/' do let(:test_files) do [ File.join(Dir.pwd, 'files', 'a_file.pp') ] end let(:symlinks) do { File.join(Dir.pwd, 'vendor', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp') } end it 'runs without raising an error' do expect { task.execute }.not_to raise_error end end context 'when there are symlinks under a directory listed in .gitignore' do before do File.write(File.join(Dir.pwd, '.gitignore'), "a_directory/\n") end let(:test_files) do [ File.join(Dir.pwd, 'files', 'a_file.pp') ] end let(:symlinks) do { File.join(Dir.pwd, 'a_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp') } end it 'runs without raising an error' do expect { task.execute }.not_to raise_error end end context 'when there are symlinks under a directory listed in .pdkignore' do before do File.open(File.join(Dir.pwd, '.pdkignore'), 'w') do |f| f.puts '/another_directory/' end end let(:test_files) do [ File.join(Dir.pwd, 'files', 'a_file.pp') ] end let(:symlinks) do { File.join(Dir.pwd, 'another_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp') } end it 'runs without raising an error' do expect { task.execute }.not_to raise_error end end end puppetlabs_spec_helper-7.0.5/spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb000066400000000000000000000021171456137173500325300ustar00rootroot00000000000000# frozen_string_literal: true require 'spec_helper' describe 'rake check:test_file', type: :task do context 'when there are .pp files under tests/' do before do test_files.each do |f| FileUtils.mkdir_p(File.dirname(f)) FileUtils.touch(f) end end let(:test_files) do [ File.join(Dir.pwd, 'tests', 'an_example.pp'), File.join(Dir.pwd, 'tests', 'deep', 'directory', 'structure', 'another_example.pp') ] end it 'raises an error' do expected_output = test_files.join("\n") expect { task.execute } .to raise_error(/pp files present in tests folder/) .and output(a_string_including(expected_output)).to_stdout end end context 'when there are no .pp files under tests/' do before do FileUtils.mkdir('tests') end it 'runs without raising an error' do expect { task.execute }.not_to raise_error end end context 'when there is no tests/ directory' do it 'runs without raising an error' do expect { task.execute }.not_to raise_error end end end puppetlabs_spec_helper-7.0.5/spec/unit/puppetlabs_spec_helper/tasks/fixture_helpers_spec.rb000066400000000000000000000221351456137173500326270ustar00rootroot00000000000000# frozen_string_literal: true require 'spec_helper' require 'puppetlabs_spec_helper/tasks/fixtures' describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do describe '.module_name' do subject(:module_name) { described_class.module_name } before do allow(Dir).to receive(:pwd).and_return(File.join('path', 'to', 'my-awsome-module_from_pwd')) end shared_examples 'module name from working directory' do it 'determines the module name from the working directory name' do expect(module_name).to eq('module_from_pwd') end end shared_examples 'module name from metadata' do it 'determines the module name from the module metadata' do expect(module_name).to eq('module_from_metadata') end end context 'when metadata.json does not exist' do before do allow(File).to receive(:file?).with('metadata.json').and_return(false) end it_behaves_like 'module name from working directory' end context 'when metadata.json does exist' do before do allow(File).to receive(:file?).with('metadata.json').and_return(true) end context 'when it is not readable' do before do allow(File).to receive(:readable?).with('metadata.json').and_return(false) end it_behaves_like 'module name from working directory' end context 'when it is readable' do before do allow(File).to receive(:readable?).with('metadata.json').and_return(true) allow(File).to receive(:read).with('metadata.json').and_return(metadata_content) end context 'when it contains invalid JSON' do let(:metadata_content) { '{ "name": "my-awesome-module_from_metadata", }' } it_behaves_like 'module name from working directory' end context 'when it contains a name value' do let(:metadata_content) { '{ "name": "my-awesome-module_from_metadata" }' } it_behaves_like 'module name from metadata' end context 'when it does not contain a name value' do let(:metadata_content) { '{}' } it_behaves_like 'module name from working directory' end context 'when the name has a null value' do let(:metadata_content) { '{ "name": null }' } it_behaves_like 'module name from working directory' end context 'when the name is blank' do let(:metadata_content) { '{ "name": "" }' } it_behaves_like 'module name from working directory' end end end end describe '.fixtures' do subject(:helper) { described_class } before do # Unstub the fixtures "helpers" PuppetlabsSpec::Fixtures.instance_methods.each do |m| PuppetlabsSpec::Fixtures.send(:undef_method, m) end allow(File).to receive(:exist?).with('.fixtures.yml').and_return false allow(File).to receive(:exist?).with('.fixtures.yaml').and_return false allow(ENV).to receive(:[]).and_call_original allow(ENV).to receive(:[]).with('FIXTURES_YML').and_return(nil) allow(described_class).to receive(:auto_symlink).and_return('project' => source_dir.to_s) end context 'when file is missing' do it 'returns basic directories per category' do expect(helper.fixtures('forge_modules')).to eq({}) expect(helper.fixtures('repositories')).to eq({}) end end context 'when file is empty' do it 'returns basic directories per category' do allow(File).to receive(:exist?).with('.fixtures.yml').and_return true allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return false expect(helper.fixtures('forge_modules')).to eq({}) expect(helper.fixtures('repositories')).to eq({}) end end context 'when file is malformed' do it 'raises an error' do expect(File).to receive(:exist?).with('.fixtures.yml').and_return true expect(YAML).to receive(:load_file).with('.fixtures.yml').and_raise(Psych::SyntaxError.new('/file', '123', '0', '0', 'spec message', 'spec context')) expect { helper.fixtures('forge_modules') }.to raise_error(RuntimeError, /malformed YAML/) end end context 'when file contains no fixtures' do it 'raises an error' do allow(File).to receive(:exist?).with('.fixtures.yml').and_return true allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return('some' => 'key') expect { helper.fixtures('forge_modules') }.to raise_error(RuntimeError, /No 'fixtures'/) end end context 'when file specifies fixtures' do it 'returns the hash' do allow(File).to receive(:exist?).with('.fixtures.yml').and_return true allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return('fixtures' => { 'forge_modules' => { 'stdlib' => 'puppetlabs-stdlib' } }) expect(helper.fixtures('forge_modules')).to eq( 'puppetlabs-stdlib' => { 'target' => 'spec/fixtures/modules/stdlib', 'ref' => nil, 'branch' => nil, 'scm' => nil, 'flags' => nil, 'subdir' => nil }, ) end end context 'when file specifies defaults' do it 'returns the hash' do allow(File).to receive(:exist?).with('.fixtures.yml').and_return true allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return('defaults' => { 'forge_modules' => { 'flags' => '--module_repository=https://myforge.example.com/' } }, 'fixtures' => { 'forge_modules' => { 'stdlib' => 'puppetlabs-stdlib' } }) expect(helper.fixtures('forge_modules')).to eq( 'puppetlabs-stdlib' => { 'target' => 'spec/fixtures/modules/stdlib', 'ref' => nil, 'branch' => nil, 'scm' => nil, 'flags' => '--module_repository=https://myforge.example.com/', 'subdir' => nil }, ) end end context 'when file specifies repository fixtures' do before do allow(File).to receive(:exist?).with('.fixtures.yml').and_return true allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return( 'fixtures' => { 'repositories' => { 'stdlib' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git' } }, ) end it 'returns the hash' do expect(helper.repositories).to eq( 'https://github.com/puppetlabs/puppetlabs-stdlib.git' => { 'target' => 'spec/fixtures/modules/stdlib', 'ref' => nil, 'branch' => nil, 'scm' => nil, 'flags' => nil, 'subdir' => nil }, ) end end context 'when file specifies repository fixtures with an invalid git ref' do before do allow(File).to receive(:exist?).with('.fixtures.yml').and_return true allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return( 'fixtures' => { 'repositories' => { 'stdlib' => { 'scm' => 'git', 'repo' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git', 'ref' => 'this/is/a/branch' } } }, ) end it 'raises an ArgumentError' do expect { helper.fixtures('repositories') }.to raise_error(ArgumentError) end end context 'when file specifies puppet version' do def stub_fixtures(data) allow(File).to receive(:exist?).with('.fixtures.yml').and_return true allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return(data) end it 'includes the fixture if the puppet version matches', if: Gem::Version.new(Puppet::PUPPETVERSION) > Gem::Version.new('4') do stub_fixtures( 'fixtures' => { 'forge_modules' => { 'stdlib' => { 'repo' => 'puppetlabs-stdlib', 'puppet_version' => Puppet::PUPPETVERSION } } }, ) expect(helper.fixtures('forge_modules')).to include('puppetlabs-stdlib') end it 'excludes the fixture if the puppet version does not match', if: Gem::Version.new(Puppet::PUPPETVERSION) > Gem::Version.new('4') do stub_fixtures( 'fixtures' => { 'forge_modules' => { 'stdlib' => { 'repo' => 'puppetlabs-stdlib', 'puppet_version' => '>= 999.9.9' } } }, ) expect(helper.fixtures('forge_modules')).to eq({}) end it 'includes the fixture on obsolete puppet versions', if: Gem::Version.new(Puppet::PUPPETVERSION) <= Gem::Version.new('4') do stub_fixtures( 'fixtures' => { 'forge_modules' => { 'stdlib' => { 'repo' => 'puppetlabs-stdlib', 'puppet_version' => Puppet::PUPPETVERSION } } }, ) expect(helper.fixtures('forge_modules')).to include('puppetlabs-stdlib') end end end end puppetlabs_spec_helper-7.0.5/spec/watchr.rb000066400000000000000000000032201456137173500210330ustar00rootroot00000000000000# frozen_string_literal: true ENV['FOG_MOCK'] ||= 'true' ENV['AUTOTEST'] = 'true' ENV['WATCHR'] = '1' system 'clear' def growl(message) growlnotify = `which growlnotify`.chomp title = 'Watchr Test Results' image = case message when /(\d+)\s+?(failure|error)/i Regexp.last_match(1).to_i == 0 ? '~/.watchr_images/passed.png' : '~/.watchr_images/failed.png' else '~/.watchr_images/unknown.png' end options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'" system %(#{growlnotify} #{options} &) end def run(cmd) puts(cmd) `#{cmd}` end def run_spec_test(file) if File.exist? file result = run "rspec --format p #{file}" growl result.split("\n").last puts result else puts "FIXME: No test #{file} [#{Time.now}]" end end def filter_rspec(data) data.split("\n").grep(/^(\d+)\s+exampl\w+.*?(\d+).*?failur\w+.*?(\d+).*?pending/).join("\n") end def run_all_tests system('clear') files = Dir.glob('spec/**/*_spec.rb').join(' ') result = run "rspec #{files}" growl_results = filter_rspec result growl growl_results puts result puts "GROWL: #{growl_results}" end # Ctrl-\ Signal.trap 'QUIT' do puts " --- Running all tests ---\n\n" run_all_tests end @interrupted = false # Ctrl-C Signal.trap 'INT' do if @interrupted @wants_to_quit = true abort("\n") else puts 'Interrupt a second time to quit' @interrupted = true Kernel.sleep 1.5 # raise Interrupt, nil # let the run loop catch it run_suite end end watch('spec/.*_spec\.rb') do |_md| run_all_tests end watch('lib/.*\.rb') do |_md| run_all_tests end