Hi, I''m looking for a way to avoid repeating all necessary facts to make the catalog compile. I''m using the let function for passing needed facts: Now I have to repeat all facts in every context to make it work. Is there a way to do something like : describe ''x'' do let(:facts) {{ :x => ''x'',: y => ''y'', ......, :many => ''more'' , z => ''z'' }} it {} //test using default facts context ''x has other value'' do let(:x) { ''overruled value'' } ====> is still using the facts :x => ''x'' end context ''y has other value'' do let(:params) {{ :y => ''overruled'' }} =====> all other params are gone, only :y exists end end Only when i repeat all facts, in every context, it works as should, but i would like tot ovoid repeating this in every context. Any hints on where to look for a solution are welcome. I have looked at before(:each) .. but still no working solution Thx Johan -- 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 _________________________________________________________ Next Events: Extending Puppet Training 2013 | http://www.open-future.be/extending-puppet-training-8-till-11th-october Puppet Fundamentals Training | http://www.open-future.be/puppet-fundamentals-training-15-till-17th-october Puppet Advanced Training | https://www.open-future.be/puppet-advanced-training-12-till-14th-november Zabbix Certified Training | http://www.open-future.be/zabbix-certified-training-18-till-20th-november Zabbix Large Environments Training | http://www.open-future.be/zabbix-large-environments-training-21-till-22nd-november Puppet Fundamentals Training | http://www.open-future.be/puppet-fundamentals-training-10-till-12th-december Subscribe to our newsletter | http://eepurl.com/BUG8H -- 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+unsubscribe@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.
I do this with params.merge! in a before block: here is an example: https://github.com/stackforge/puppet-openstack/blob/master/spec/classes/openstack_cinder_all_spec.rb#L61 On Mon, Oct 7, 2013 at 6:26 AM, Johan De Wit <Johan@open-future.be> wrote:> Hi, > > I''m looking for a way to avoid repeating all necessary facts to make the > catalog compile. > > I''m using the let function for passing needed facts: > > Now I have to repeat all facts in every context to make it work. Is there > a way to do something like : > > > describe ''x'' do > let(:facts) {{ :x => ''x'',: y => ''y'', ......, :many => ''more'' , z => ''z'' > }} > > it {} //test using default facts > > context ''x has other value'' do > let(:x) { ''overruled value'' } > ====> is still using the facts :x => ''x'' > end > > context ''y has other value'' do > let(:params) {{ :y => ''overruled'' }} > =====> all other params are gone, only :y exists > end > end > > Only when i repeat all facts, in every context, it works as should, but i > would like tot ovoid repeating this in every context. > > Any hints on where to look for a solution are welcome. > > I have looked at before(:each) .. but still no working solution > > Thx > > Johan > > -- > 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 > ______________________________**___________________________ > > Next Events: > Extending Puppet Training 2013 | http://www.open-future.be/** > extending-puppet-training-8-**till-11th-october<http://www.open-future.be/extending-puppet-training-8-till-11th-october> > Puppet Fundamentals Training | http://www.open-future.be/** > puppet-fundamentals-training-**15-till-17th-october<http://www.open-future.be/puppet-fundamentals-training-15-till-17th-october> > Puppet Advanced Training | https://www.open-future.be/** > puppet-advanced-training-12-**till-14th-november<https://www.open-future.be/puppet-advanced-training-12-till-14th-november> > Zabbix Certified Training | http://www.open-future.be/** > zabbix-certified-training-18-**till-20th-november<http://www.open-future.be/zabbix-certified-training-18-till-20th-november> > Zabbix Large Environments Training | http://www.open-future.be/** > zabbix-large-environments-**training-21-till-22nd-november<http://www.open-future.be/zabbix-large-environments-training-21-till-22nd-november> > Puppet Fundamentals Training | http://www.open-future.be/** > puppet-fundamentals-training-**10-till-12th-december<http://www.open-future.be/puppet-fundamentals-training-10-till-12th-december> > Subscribe to our newsletter | http://eepurl.com/BUG8H > > -- > 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+unsubscribe@**googlegroups.com<puppet-users%2Bunsubscribe@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<http://groups.google.com/group/puppet-users> > . > For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> > . >-- 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+unsubscribe@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.
Johan De Wit
2013-Oct-08 07:58 UTC
Re: [Puppet Users] rspec and overriding :facts per context
Hi Dan, Thx for the tip ! Just what i was looking for. I will delve into the spec files here, i can learn a lot of them grts jo On 10/08/2013 01:25 AM, Dan Bode wrote:> I do this with params.merge! in a before block: > > here is an example: > > https://github.com/stackforge/puppet-openstack/blob/master/spec/classes/openstack_cinder_all_spec.rb#L61 > > > On Mon, Oct 7, 2013 at 6:26 AM, Johan De Wit <Johan@open-future.be > <mailto:Johan@open-future.be>> wrote: > > Hi, > > I''m looking for a way to avoid repeating all necessary facts to > make the catalog compile. > > I''m using the let function for passing needed facts: > > Now I have to repeat all facts in every context to make it work. > Is there a way to do something like : > > > describe ''x'' do > let(:facts) {{ :x => ''x'',: y => ''y'', ......, :many => ''more'' , z > => ''z'' }} > > it {} //test using default facts > > context ''x has other value'' do > let(:x) { ''overruled value'' } > ====> is still using the facts :x => ''x'' > end > > context ''y has other value'' do > let(:params) {{ :y => ''overruled'' }} > =====> all other params are gone, only :y exists > end > end > > Only when i repeat all facts, in every context, it works as > should, but i would like tot ovoid repeating this in every context. > > Any hints on where to look for a solution are welcome. > > I have looked at before(:each) .. but still no working solution > > Thx > > Johan > > -- > 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 > <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> > BELGIUM http://www.open-future.be > _________________________________________________________ > > Next Events: > Extending Puppet Training 2013 | > http://www.open-future.be/extending-puppet-training-8-till-11th-october > Puppet Fundamentals Training | > http://www.open-future.be/puppet-fundamentals-training-15-till-17th-october > Puppet Advanced Training | > https://www.open-future.be/puppet-advanced-training-12-till-14th-november > Zabbix Certified Training | > http://www.open-future.be/zabbix-certified-training-18-till-20th-november > Zabbix Large Environments Training | > http://www.open-future.be/zabbix-large-environments-training-21-till-22nd-november > Puppet Fundamentals Training | > http://www.open-future.be/puppet-fundamentals-training-10-till-12th-december > Subscribe to our newsletter | http://eepurl.com/BUG8H > > -- > 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+unsubscribe@googlegroups.com > <mailto:puppet-users%2Bunsubscribe@googlegroups.com>. > To post to this group, send email to puppet-users@googlegroups.com > <mailto: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. > > > -- > 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+unsubscribe@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.-- 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 _________________________________________________________ Next Events: Extending Puppet Training 2013 | http://www.open-future.be/extending-puppet-training-8-till-11th-october Puppet Fundamentals Training | http://www.open-future.be/puppet-fundamentals-training-15-till-17th-october Puppet Advanced Training | https://www.open-future.be/puppet-advanced-training-12-till-14th-november Zabbix Certified Training | http://www.open-future.be/zabbix-certified-training-18-till-20th-november Zabbix Large Environments Training | http://www.open-future.be/zabbix-large-environments-training-21-till-22nd-november Puppet Fundamentals Training | http://www.open-future.be/puppet-fundamentals-training-10-till-12th-december Subscribe to our newsletter | http://eepurl.com/BUG8H -- 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+unsubscribe@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.