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

Update documentation on how to stub a puppet function #684

Open
TraGicCode opened this issue May 9, 2018 · 1 comment
Open

Update documentation on how to stub a puppet function #684

TraGicCode opened this issue May 9, 2018 · 1 comment

Comments

@TraGicCode
Copy link
Contributor

TraGicCode commented May 9, 2018

I've noticed a reoccuring question of people asking how to stub puppet functions when using rspec-puppet. We should get some documentation on this going. Below are the 2 mechanisms i've used for stubbing puppet functions.

Approach 1

describe 'role::blah' do
  let(:pre_condition) do
    'function googlecloudstorage::generate_signed_url($x, $y, $z) { return \'https://asdasdasd.com/file.iso\' }'
  end
end

Approach 2

describe 'role::blah' do
  before(:each) do
          Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) {|args| '4.0.0'}
  end
end

Also based on conversations it sounds like the first approach is the one that most people should lean towards using for newer code.

@TraGicCode
Copy link
Contributor Author

There could be a tile on “Stubbing Dependencies” or “Stubbing Puppet Functions” on the website docs http://rspec-puppet.com/documentation/. If not a new tile not sure which one to put it in….

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants