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

Use puppetlabs_spec_helper to test parser functions #39

Merged

Conversation

jeffmccune
Copy link
Collaborator

This patch supersedes #38

Without this patch applied rspec-puppet reaches deep inside of Puppet
and uses an unsupported and private interface to obtain functions and
scope instances. This is a problem because Puppet Labs considers
internal classes such as Puppet::Parser::Scope as private and internal.

We change these classes without warning and this is a maintenance issue
for third party testing tools.

This patch fixes this maintenance problem by using the compatibility
layer implemented in the puppetlabs_spec_helper. When we change the
internal behavior of private classes such as Puppet::Parser::Scope,
we'll update the spec helper module methods to provide a version
agnostic way to get instances of these internal objects.

As an example, a supported way to get a scope instance is:

PuppetlabsSpec::PuppetInternals.scope

Instead of the private and unsupported method of:

Puppet::Parser::Scope.new

This patch introduces a Gem dependency onto the puppetlabs_spec_helper
gem.

Without this patch applied rspec-puppet reaches deep inside of Puppet
and uses an unsupported and private interface to obtain functions and
scope instances.  This is a problem because Puppet Labs considers
internal classes such as Puppet::Parser::Scope as private and internal.

We change these classes without warning and this is a maintenance issue
for third party testing tools.

This patch fixes this maintenance problem by using the compatibility
layer implemented in the puppetlabs_spec_helper.  When we change the
internal behavior of private classes such as Puppet::Parser::Scope,
we'll update the spec helper module methods to provide a version
agnostic way to get instances of these internal objects.

As an example, a supported way to get a scope instance is:

    PuppetlabsSpec::PuppetInternals.scope

Instead of the private and unsupported method of:

    Puppet::Parser::Scope.new

This patch introduces a Gem dependency onto the puppetlabs_spec_helper
gem.
@travisbot
Copy link

This pull request fails (merged e6b88cf into 8d4c964).

@jeffmccune
Copy link
Collaborator Author

This pull request shouldn't be merged until https://github.com/puppetlabs/puppetlabs_spec_helper/pull/20/files is merged.

@jeffmccune
Copy link
Collaborator Author

@rodjek

OK, I've released the new puppetlabs_spec_helper gem to rubygems.org. This should be good to go.

Do you mind if I merge this in and release a new version of rspec-puppet ?

(Would it be possible to become an owner on rubygems.org?)

@jeffmccune
Copy link
Collaborator Author

@travisbot test this branch please.

@jeffmccune
Copy link
Collaborator Author

@rodjek I'm going to merge this since we're depending on it now that I've merged in @bodepd's two new functions into stdlib that require the behavior.

Please feel free to let me know if you're not happy with this change and I'll gladly revert the merge commit.

Thanks,
-Jeff

jeffmccune pushed a commit that referenced this pull request Aug 15, 2012
Use puppetlabs_spec_helper to test parser functions
@jeffmccune jeffmccune merged commit 4afd64e into rodjek:master Aug 15, 2012
blkperl pushed a commit to blkperl/puppetlabs_spec_helper that referenced this pull request Jan 25, 2014
Without this patch modules typically get entire scope objects in an
effort to invoke parser functions.  RSpec::Puppet uses the method
instance itself to send the :call message to the method instance.  The
spec helper does not provide a compatible way to obtain method instances
for parser functions.

This is a problem because we need a compatible way to test functions
that does not incur a high maintenance cost on rspec-puppet.

This patch fixes the problem by implementing and compatible way to test
functions using their method instances.  RSpec::Puppet has been patched
in rodjek/rspec-puppet#39 to use this
compatibility layer.
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

Successfully merging this pull request may close these issues.

None yet

2 participants