Use puppetlabs_spec_helper to test parser functions #39

Merged
merged 1 commit into from Aug 15, 2012

Projects

None yet

2 participants

@jeffmccune
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.

@jeffmccune jeffmccune Use puppetlabs_spec_helper to test parser functions
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.
e6b88cf
@travisbot

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

@jeffmccune
Collaborator

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

@jeffmccune
Collaborator

@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
Collaborator

@travisbot test this branch please.

@jeffmccune
Collaborator

@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 jeffmccune merged commit 4afd64e into rodjek:master Aug 15, 2012

1 check failed

Details default The Travis build failed
@blkperl blkperl pushed a commit to blkperl/puppetlabs_spec_helper that referenced this pull request Jan 25, 2014
@jeffmccune jeffmccune Add PuppetInternals.function_method compatibility bridge
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.
594dfe4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment