On 28/03/14 18:53, Trevor Vaughan wrote:
Yep, but I need the value of $bar to figure out what the later
resource name is!
A better example:
class foo {
$bar = interesting_function('baz')
file { "/some/path/$bar":
content => 'whatever'
}
}
Aren't we mixing some things here ?
IMHO, what should be tested is that, given $bar a 'value', no matter
what the source of that value is (be it generates using a function,
provided by hiera or given as parameter during classification).
In your spec file, just assign a 'value' to $bar, and just test that
value is the resource
let(:param) { { :bar => 'somevalue' } }
it should contain_file('/some/path/somevalue).with_content(/whatever/)
Thats about your test for your class.
The second test you could do, is to test your function with rspec :
|it { should run.with_params('foo').and_return('somevalue') }
|
So, given that I don't necessarily know what interesting_function is
going to generate, I need to actually run it to get the result.
Thanks,
Trevor
On Fri, Mar 28, 2014 at 12:23 PM, James Sweeny
<james.swe...@puppetlabs.com <mailto:james.swe...@puppetlabs.com>> wrote:
I could be way off here, but shouldn't you be testing the resource
$bar ends up in, rather than the value of $bar itself?
On Fri, Mar 28, 2014 at 11:15 AM, Trevor Vaughan
<tvaug...@onyxpoint.com <mailto:tvaug...@onyxpoint.com>> wrote:
Hmm...so you're saying that I would mock the variable result
with the real function to get the real result?
That's doesn't make me super happy but if it works, I'll take it!
Trevor
On Fri, Mar 28, 2014 at 11:26 AM, Johan De Wit
<jo...@open-future.be <mailto:jo...@open-future.be>> wrote:
I stumbled against this text :
you can write a mock function my_mock_function.rb and put
it under
{module name}/spec / fixtures / modules / {module name}/
lib / puppet / parser /
If you put the real function(s) so there ?
On 28/03/14 15:39, Trevor Vaughan wrote:
Hopefully I didn't just overlook this in the docs but, in
rspec-puppet, how would you go about getting the value of
$bar from the following?
class foo {
$bar = interesting_function('baz')
}
I've inspected everything that I think is obvious and I
don't want to try and stub what 'interesting_function'
should be doing since it's dynamic.
Any ideas?
Thanks,
Trevor
--
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699 <tel:%28410%29%20541-6699>
tvaug...@onyxpoint.com <mailto:tvaug...@onyxpoint.com>
-- This account not approved for unencrypted proprietary
information --
--
You received this message because you are subscribed to
the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails
from it, send an email to
puppet-dev+unsubscr...@googlegroups.com
<mailto:puppet-dev+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-dev/CANs%2BFoVY%3DCtqRSjbOQYN-j%2B9PCkfYbXnGW-9qPOf1R6ZB%3DtNSA%40mail.gmail.com
<https://groups.google.com/d/msgid/puppet-dev/CANs%2BFoVY%3DCtqRSjbOQYN-j%2B9PCkfYbXnGW-9qPOf1R6ZB%3DtNSA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
Johan De Wit
Open Source Consultant
Red Hat Certified Engineer (805008667232363)
Puppet Certified Professional 2013/2014 (PCP0000006)
_________________________________________________________
Open-Future Phone+32 (0)2/255 70 70 <tel:%2B32%20%280%292%2F255%2070%2070>
Zavelstraat 72 Fax+32 (0)2/255 70 71
<tel:%2B32%20%280%292%2F255%2070%2071>
3071 KORTENBERG Mobile+32 (0)474/42 40 73
<tel:%2B32%20%280%29474%2F42%2040%2073>
BELGIUMhttp://www.open-future.be
_________________________________________________________
Upcoming Events:
Puppet Introduction Course |
http://www.open-future.be/puppet-introduction-course-14th-april
Puppet Advanced Training |
http://www.open-future.be/puppet-advanced-training-15-till-17th-april
Linux Training |
https://www.open-future.be/linux-training-5-till-9th-may
Puppet Introduction Course |
https://www.open-future.be/puppet-introduction-course-12th-may
Subscribe to our newsletter: http://eepurl.com/BUG8H
--
You received this message because you are subscribed to
the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails
from it, send an email to
puppet-dev+unsubscr...@googlegroups.com
<mailto:puppet-dev+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-dev/5335948B.5070003%40open-future.be
<https://groups.google.com/d/msgid/puppet-dev/5335948B.5070003%40open-future.be?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699 <tel:%28410%29%20541-6699>
tvaug...@onyxpoint.com <mailto:tvaug...@onyxpoint.com>
-- This account not approved for unencrypted proprietary
information --
--
You received this message because you are subscribed to the
Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from
it, send an email to puppet-dev+unsubscr...@googlegroups.com
<mailto:puppet-dev+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-dev/CANs%2BFoVR2zGd_Tj4BTdb-UvRQnLpU%3D7vBRHOfPN3JTi%2BJHVJOA%40mail.gmail.com
<https://groups.google.com/d/msgid/puppet-dev/CANs%2BFoVR2zGd_Tj4BTdb-UvRQnLpU%3D7vBRHOfPN3JTi%2BJHVJOA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
James Sweeny
Professional Services
http://puppetlabs.com/
*Join us at PuppetConf 2014, September 23-24 in San Francisco -
http://2014.puppetconf.com*
--
You received this message because you are subscribed to the Google
Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to puppet-dev+unsubscr...@googlegroups.com
<mailto:puppet-dev+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-dev/CAKDACKubSgMpn2gfmFjrRV4N5vGRzXk4oyDrb5BW9FRyE8iJ8Q%40mail.gmail.com
<https://groups.google.com/d/msgid/puppet-dev/CAKDACKubSgMpn2gfmFjrRV4N5vGRzXk4oyDrb5BW9FRyE8iJ8Q%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699
tvaug...@onyxpoint.com <mailto:tvaug...@onyxpoint.com>
-- This account not approved for unencrypted proprietary information --
--
You received this message because you are subscribed to the Google
Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to puppet-dev+unsubscr...@googlegroups.com
<mailto:puppet-dev+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-dev/CANs%2BFoVrJ_Lw%3Dm940eu1io1dCZn-dPObaSgARZecx-rDu2rbyg%40mail.gmail.com
<https://groups.google.com/d/msgid/puppet-dev/CANs%2BFoVrJ_Lw%3Dm940eu1io1dCZn-dPObaSgARZecx-rDu2rbyg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
Johan De Wit
Open Source Consultant
Red Hat Certified Engineer (805008667232363)
Puppet Certified Professional 2013/2014 (PCP0000006)
_________________________________________________________
Open-Future Phone +32 (0)2/255 70 70
Zavelstraat 72 Fax +32 (0)2/255 70 71
3071 KORTENBERG Mobile +32 (0)474/42 40 73
BELGIUM http://www.open-future.be
_________________________________________________________
Next Events:
Puppet Introduction Course |
http://www.open-future.be/puppet-introduction-course-14th-april
Puppet Advanced Training |
http://www.open-future.be/puppet-advanced-training-15-till-17th-april
Linux Training | https://www.open-future.be/linux-training-5-till-9th-may
Puppet Introduction Course |
https://www.open-future.be/puppet-introduction-course-12th-may
Subscribe to our newsletter | http://eepurl.com/BUG8H
--
You received this message because you are subscribed to the Google Groups "Puppet
Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-dev/53390619.8060804%40open-future.be.
For more options, visit https://groups.google.com/d/optout.