FAQ
I have a module in which parameterized classes inherit regular (non-
parameterized) 'params' class. I am writing RSpec tests for this
module and would like to make sure that required variables have been
declared in the params class. Also, is it possible to write RSpec test
to make sure that these variables/parameters are accepted by the
required parameterized classes? Any pointers will be really helpful.

--
Thanks,
Shantanu Pavgi

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Search Discussions

  • Craig Dunn at Apr 23, 2012 at 5:07 pm

    On 23/04/2012 16:51, Shantanu wrote:
    I have a module in which parameterized classes inherit regular (non-
    parameterized) 'params' class. I am writing RSpec tests for this
    module and would like to make sure that required variables have been
    declared in the params class. Also, is it possible to write RSpec test
    to make sure that these variables/parameters are accepted by the
    required parameterized classes? Any pointers will be really helpful.
    Funnily enough I was asking a similar thing on IRC the other day but
    didn't get much luck. We're implementing Hiera across modules that
    require significant amounts of variables. We have a lot of environments
    (>20) and we often get problems where someone introduces a new variable,
    adds it to a template and tests it in dev but dont add a default, or add
    it to each environment, therefore catalog compilation fails in non-dev
    environments.

    Ideally I'd like to be able to catch this with rspec-puppet but can't
    see an easy way to say "class bar should have variable foo and it
    shouldn't be undefined", or something when sourcing variables from other
    classes or hiera.

    Craig

    --
    Craig Dunn | http://www.craigdunn.org
    Yahoo/Skype: craigrdunn | Twitter: @crayfishX

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Tim Sharpe at Apr 23, 2012 at 10:49 pm
    So, rspec-puppet can't and won't ever work this way. What it's testing is the resulting catalogue of Puppet resources that your host executes (the behaviour of Puppet). Instead of testing that a variable is defined, you should be testing the resource(s) that those variables control/adjust.

    For example, if your variable changes the templated contents of a file resource, then you should be testing the contents of that file resource.

    On Monday, 23 April 2012 at 10:06 AM, Craig Dunn wrote:
    On 23/04/2012 16:51, Shantanu wrote:

    I have a module in which parameterized classes inherit regular (non-
    parameterized) 'params' class. I am writing RSpec tests for this
    module and would like to make sure that required variables have been
    declared in the params class. Also, is it possible to write RSpec test
    to make sure that these variables/parameters are accepted by the
    required parameterized classes? Any pointers will be really helpful.

    Funnily enough I was asking a similar thing on IRC the other day but
    didn't get much luck. We're implementing Hiera across modules that
    require significant amounts of variables. We have a lot of environments
    (>20) and we often get problems where someone introduces a new variable,
    adds it to a template and tests it in dev but dont add a default, or add
    it to each environment, therefore catalog compilation fails in non-dev
    environments.

    Ideally I'd like to be able to catch this with rspec-puppet but can't
    see an easy way to say "class bar should have variable foo and it
    shouldn't be undefined", or something when sourcing variables from other
    classes or hiera.

    Craig

    --
    Craig Dunn | http://www.craigdunn.org
    Yahoo/Skype: craigrdunn | Twitter: @crayfishX

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com).
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com (mailto:puppet-users+unsubscribe@googlegroups.com).
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Shantanu at Apr 24, 2012 at 8:49 pm

    On Apr 23, 5:49 pm, Tim Sharpe wrote:
    So, rspec-puppet can't and won't ever work this way.  What it's testing is the resulting catalogue of Puppet resources that your host executes (the behaviour of Puppet).  Instead of testing that a variable is defined, you should be testing the resource(s) that those variables control/adjust.

    For example, if your variable changes the templated contents of a file resource, then you should be testing the contents of that file resource.
    Thanks for the details Tim. That's helpful.

    --
    Shantanu

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Markus Falb at Jun 4, 2012 at 8:13 am

    On 24.4.2012 00:49, Tim Sharpe wrote:
    So, rspec-puppet can't and won't ever work this way. What it's testing is the resulting catalogue of Puppet resources that your host executes (the behaviour of Puppet). Instead of testing that a variable is defined, you should be testing the resource(s) that those variables control/adjust.

    For example, if your variable changes the templated contents of a file resource, then you should be testing the contents of that file resource.
    What's with virtual resources that are realized on another host?
    Is there any way to test that?
    --
    Kind Regards, Markus Falb

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedApr 23, '12 at 3:52p
activeJun 4, '12 at 8:13a
posts5
users4
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase