When running Rspec-puppet tests, a deprecation warning is seen:
Deprecation Warnings:
puppetlabs_spec_helper: defaults `mock_with` to `:mocha`.
See https://github.com/puppetlabs/puppetlabs_spec_helper#mock_with
to choose a sensible value for you
Accordingly, I set up a spec_helper with a block like this:
RSpec.configure do |c|
c.mock_with :mocha
...
end
Just like the documentation here suggests. But the warning persists. What is wrong?
It is actually necessary to open two configuration blocks, whereas the
mock_with
config must be declared before thepuppetlabs_spec_helper
is required.In other words, like this:
See also discussion in here.
I have asked and answered this question here so that this confusing behaviour is documented somewhere because no matter how clear the docs are, this is going to continue to trip people up.