Re: rspec-puppet: function stubs

164 views
Skip to first unread message

Tehmasp Chaudhri

unread,
Jan 2, 2014, 10:16:24 PM1/2/14
to puppet...@googlegroups.com
I'm looking to do this as well. Did you ever have any luck?

On Friday, July 27, 2012 8:44:08 AM UTC-6, James Stremick wrote:

I'm looking for a way to stub a parser function within rspec-puppet. This function returns data based on a database query and I'd rather not have to populate dummy data inside my rspec tests.

I can redefine the function by doing something like the following: 

Puppet::Parser::Functions::rmfunction("lookup_facts")
Puppet::Parser::Functions::newfunction(:lookup_facts, :type => :rvalue) { '127.0.0.1' }

but it isn't in effect on the resulting catalog during the tests.

I'm thinking that either the catalog is already generated or I'm not telling the compiler to use the updated function.

Any suggestions?

Johan De Wit

unread,
Jan 6, 2014, 2:57:23 AM1/6/14
to puppet...@googlegroups.com
I think the best place to look for examples is the puppet code itself. 

I haven't used stubbing that much myself, but this will be coming very soon. 

I'm trying to write an dynamic openldap type starting from the rspec file.

I documented a bit on every step i did, and tagged the git repo every milestone i reached.

This is very draft, but any comments are more then welcome. 

https://github.com/Open-Future-Belgium/puppet_rspec_demo

Gtrs

Jo
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/b7083977-2776-47e0-be96-cb81e7ebe722%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


-- 
Johan De Wit

Open Source Consultant

Red Hat Certified Engineer         (805008667232363)
Puppet Certified Professional 2013 (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
_________________________________________________________
 

Upcoming Events:

Puppet Advanced Training | http://www.open-future.be/puppet-advanced-training-7-till-9th-january

Puppet Fundamentals Training | http://www.open-future.be/puppet-fundamentals-training-4-till-6th-february

Subscribe to our newsletter: http://eepurl.com/BUG8H


Reply all
Reply to author
Forward
0 new messages