Skip to content

Coverage on custom functions tests #128

@pfrayer

Description

@pfrayer

Describe the Bug

On a module, I have tests about custom functions present in this module. The tests work well, but the coverage don't detect it and stays at 0%.

My module structure is classic:

lib
└── puppet
    └── functions                      # my custom functions
    	├── bar.rb
    	└── foo.rb
spec
├── classes
└── functions                          # the related tests
	├── bar_spec.rb
	└── foo_spec.rb
templates
└── ...
files
└── ...
manifests
└── ...

rspec output:

$ rspec
Run options: exclude {:bolt=>true}
.................

Coverage Report:

Total resources:   0
Touched resources: 0
Resource coverage: 100.00%

Finished in 3.23 seconds (files took 1.57 seconds to load)
148 examples, 0 failures

Expected Behavior

rspec coverage report's resources should not be 0. Am I missing something ?

Environment

rspec (3.13.0)
rspec-core (3.13.0)
rspec-expectations (3.13.1)
rspec-github (2.4.0)
rspec-mocks (3.13.1)
rspec-puppet (4.0.2)
rspec-puppet-facts (5.1.0)
rspec-support (3.13.1)

spec_helper.rb uses a classic conf:

RSpec.configure do |c|
  c.default_facts = default_facts
  c.before :each do
    Puppet.settings[:strict] = :warning
    Puppet.settings[:strict_variables] = true
  end
  c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
  c.after(:suite) do
    RSpec::Puppet::Coverage.report!
  end

Additional Context

In this module I only have tests about custom functions, other part of the module aren't tested yet

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Has been Actioned

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions