On 12/2/15 6:33 PM, Haani Niyaz wrote: > Hi Ben, > > I am also looking for some reference material to better illustrate how > to use rsepc puppet, a best practices of sorts to my team. Were you > successful in finding some examples? > > On Friday, 11 July 2014 10:29:32 UTC+10, Ben Sullivan wrote: > > Hi > > I'm looking for some reference modules to share with my team to > illustrate how to best use rspec-puppet to unit test Puppet DSL code. > > I'm going to go through the Puppet Enterprise supported modules as I > figured that was a reasonable place to > start: https://forge.puppetlabs.com/modules?supported=yes > <https://forge.puppetlabs.com/modules?supported=yes> > > The team doesn't understand the value of rspec-puppet at present and > I need to articulate arguments to get some buy-in. At the moment we > rely on long-running end to end tests which won't scale for us as > our automation codebase grows. > > Any tips/recommendations would be appreciated. > > Many thanks > > Ben >
Hello, Last year I spoke[1] at LISA about why TDD works for configuration management. Unfortunately, those slides are all pictures.. I teach an interactive class about testing and last year gave a 1/2 day tutorial on testing with rspec-puppet at LOAD. Those slides[2] explain why testing is important, what are all the bits needed to get rspec-puppet to work and what to test. It references a Vagrant setup[3] to get you started. It installs some older gems, so you might be better off cloning one of the modules below and using `rvm use 2.1.0 && bundle install` to get all the testing dependencies going. My vim module is an example[4] of testing a simple class that works on many platforms and the nscd module is an example[5] of a module with a ton of parameters and also supporting many platforms. If you're interested in best practices around testing, I recently starting working with Rubocop after noticing that a puppet-community module was using it in their automated testing. Rubocop enforces ruby style. Here's an example commit[6] that shows how I added it to a module, modified the Travis-ci testing setup and all the changes to the code that resulted. [1] - http://www.slideshare.net/gh/20141114-why-test-driven-development-tdd-works-for-sysadmins-lisa14 [2] - http://www.slideshare.net/gh/20140406-loa-daystddwithpuppettutorial [3] - https://github.com/ghoneycutt/learnpuppet-tdd-vagrant [4] - https://github.com/ghoneycutt/puppet-module-vim/blob/master/spec/classes/init_spec.rb [5] - https://github.com/ghoneycutt/puppet-module-nscd/blob/master/spec/classes/init_spec.rb [6] - https://github.com/ghoneycutt/puppet-module-nscd/commit/de95ca517ed7df0bf2c34b0c8decff551a697fde Best regards, -g -- Garrett Honeycutt @learnpuppet Puppet Training with LearnPuppet.com Mobile: +1.206.414.8658 -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/566070AC.5000401%40garretthoneycutt.com. For more options, visit https://groups.google.com/d/optout.
