- From: Phil Mocek <
>
- To:
- Subject: [chef] Re: Access attributes in serverspec tests excuted in a report handler
- Date: Thu, 12 Feb 2015 17:00:26 -0800
wrote:
>
Is it possible to access the attributes of the current chef run in
>
these rspec-tests? And when, how?
Julian C. Dunn responded:
>
I don't recommend this approach, because you're conflating the
>
variables of the system under test with the test vectors, so how do
>
you know if you have a valid test?
What do others recommend doing to verify, for example, that use of a
recipe results in a file existing in a location described in a node
attribute? The recipe I want to test includes golang::default,
downloads some source code, then creates files in a subdirectory of
node['go']['gopath'].
I'm considering these options:
- Hard-coding the default values of applicable node attributes
in my serverspec tests
- Overriding the attributes in .kitchen.yml and hard-coding the
override values in my tests
- [Dumping attributes with a helper cookbook][1], then loading
the result in my tests
- Figuring out where the "property" hash in the [apache2
cookbook's tests][2] comes from and doing something similar
I would appreciate any related suggestions.
References:
[1]:
<
http://jakshi.com/blog/2014/05/12/accessing-chef-attributes-in-serverspec-tests/>
[2]:
<
https://github.com/svanzoest/apache2-cookbook/blob/master/test/integration/default/serverspec/localhost/default_spec.rb>
--
Phil Mocek
https://mocek.org
- [chef] Re: Access attributes in serverspec tests excuted in a report handler, Phil Mocek, 02/12/2015
Archive powered by MHonArc 2.6.16.