Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDK should default to mock_with :rspec and resolve deprecation message #477

Closed
ardrigh opened this issue Apr 16, 2018 · 1 comment
Closed

Comments

@ardrigh
Copy link
Contributor

ardrigh commented Apr 16, 2018

I have been testing module updates in TravisCI, and it kept giving me a deprecation message about defaulting to using "mocha" for the "mock" functions.

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

Now, I see in the documetation for this change someone has provided a nice helper on adding a few lines to .sync.yml

https://github.com/puppetlabs/puppetlabs_spec_helper#mock_with
https://github.com/puppetlabs/pdk-templates#specspec_helperrb

spec/spec_helper.rb:
  mock_with: ':rspec'

Which works when running pdk update to update the spec/spec_helper.rb file, BUT it still doesn't fix the deprecation message in my TravisCI runs.

For some reason, the way pdk update handles this line, it adds it to the bottom of the file like so:

RSpec.configure do |c|
  c.default_facts = default_facts
  c.mock_with :rspec
end

The documentation hints at putting it at the top of the file, like so:

RSpec.configure do |c|
  c.mock_with :rspec
end
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'

The second method, putting this config at the very top of the file, removes the deprecation warning message from TravisCI. So it obviously needs to happen very early in the setup, before other things are called.

It seems like the simplest fix for this change would be to make "mock_with :rspec" the default template, and leave the remaining settings to be added at the bottom via .sync.yml as documented.

@ardrigh
Copy link
Contributor Author

ardrigh commented Apr 18, 2018

It looks like this has been updated in recent changes to pdk-templates 👍

@ardrigh ardrigh closed this as completed Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant