Closed
Description
Describe the Bug
Running unit tests with puppetlabs_spec_helper
version 6.0.3
raises an error during spec_clean
due to hash['ref']
being Nil. Looking at the fixtures.rb
, the validate_fixture_hash
method is attempting to validate that the ref
option for repositories does not contain forward slash, but it doesn't consider at all the cases where ref
is not set.
As per README.md
:
used to specify the tag name (like version) or commit hash to be checked out (Optional). Branch names should use the branch option instead.
Exact error when running pdk test unit
:
root@02d4a589e156:/workspaces/puppet-module# pdk test unit --tests spec/classes/custom_spec.rb --puppet-version 7.27.0
pdk (INFO): Using Ruby 2.7.8
pdk (INFO): Using Puppet 7.27.0
[✖] Preparing to run the unit tests.
[✖] Cleaning up after running unit tests.
pdk (ERROR): The spec_clean rake task failed with the following error(s):
rake aborted!
NoMethodError: undefined method `include?' for nil:NilClass
Did you mean? include_repo?
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-6.0.3/lib/puppetlabs_spec_helper/tasks/fixtures.rb:154:in `validate_fixture_hash!'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-6.0.3/lib/puppetlabs_spec_helper/tasks/fixtures.rb:136:in `block in fixtures'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-6.0.3/lib/puppetlabs_spec_helper/tasks/fixtures.rb:120:in `each'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-6.0.3/lib/puppetlabs_spec_helper/tasks/fixtures.rb:120:in `fixtures'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-6.0.3/lib/puppetlabs_spec_helper/tasks/fixtures.rb:47:in `repositories'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-6.0.3/lib/puppetlabs_spec_helper/tasks/fixtures.rb:431:in `block in <top (required)>'
/opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/rake-13.1.0/exe/rake:27:in `<top (required)>'
Expected Behavior
This started occurring after upgrade my local PDK Docker image to the latest version. Previously not having ref
specified was working without issues.
Steps to Reproduce
Steps to reproduce the behavior:
- Create a new puppet module via
pdk new
- Add to
.fixtures.yml
the following content
---
fixtures:
repositories:
<repo-name>:
repo: <url-to-a-puppet-module>
scm: git
- Run
pdk test unit
.
Environment
- Using latest PDK Docker image link
Additional Context
N/A