It's been a while since I jumped into this code and it's late, forgive me
if I say something naive inline.


On Wed, Jun 26, 2013 at 8:14 PM, Nan Liu <nan....@gmail.com> wrote:

> On Wed, Jun 26, 2013 at 7:23 PM, Amos Shapira <amos.shap...@gmail.com>wrote:
>
>> I'm writing my first puppet function rspec test and am having a problem
>> which I don't see how to solve.
>>
>> The function (and the test) involve access to files through the File
>> Server. In order for the function (and the test) to work I need to pass
>> "--fileserverconf=fileserver.conf" parameter to Puppet.
>>
>> So far I haven't found a way to do that.
>>
>> If I understand the rspec-puppet source at
>> https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet.rbcorrectly
>>  then the list of parameters I can pass is limited to the ones
>> mentioned in lines 16-22. Am I right?
>>
>
Those are the limit you can pass to the RSpec.configure { ... } block in
your spec helper.

>
>> Does anyone know how can I pass other parameters, or otherwise affect
>> Puppet's configuration to set this value?
>>
>> Have you tried something like:

describe 'foo' do
    before do
        Puppet[:fileserverconfig] = '/my/path/to/fileserver.conf'
    end

    ....your tests....

end

>
> Oddly enough, you can't depend on rspec-puppet to configure the settings
> for spec test. For example, puppetlab's spec helper configures the
> modulepath [1] to include spec/fixtures/modules, but this does not seem to
> configure Puppet[:modulepath] setting. For whatever reason, puppet loads
> the modules correctly from spec/fixtures/modules, but when you debug the
> spec test, it appears to set the module path to:
>
> (rdb:1) p Puppet[:modulepath]
> "/dev/null/modules:/usr/share/puppet/modules"
>

Nan -

In puppetlabs_spec_helper/puppet_spec_helper[1] which was based on a file
in Puppet[2] the confdir and vardir are explicitly set to '/dev/null' which
causes the modulepath you're seeing in Puppet "proper".

I believe, however the subject catalog/function that is tested in each
example group (unless you explicitly create a subject yourself) should mask
that value with what ever is passed into RSpec.configure (like the
modulepath setting in module_spec_helper) for its
compilation/initialization[3][4].


 - Justin

1.
https://github.com/puppetlabs/puppetlabs_spec_helper/blob/master/lib/puppetlabs_spec_helper/puppet_spec_helper.rb#L96-L97
2.
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/test/test_helper.rb#L142-L156
3.
https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet/example/function_example_group.rb#L10
4.
https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet/support.rb#L80-L97

>
> You can do what Wolf suggested. File server conf is somewhat inconsistent,
> since the setting is actually: Puppet[:fileserverconfig].
>
> HTH,
>
> Nan
>
>
> 1.
> https://github.com/puppetlabs/puppetlabs_spec_helper/blob/master/lib/puppetlabs_spec_helper/module_spec_helper.rb#L21-L24
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To post to this group, send email to puppet-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/puppet-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 

Join us at PuppetConf 2013, August 22-23 in San Francisco -
http://bit.ly/pupconf13

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to