The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Feature #3138

Improve procedure for enabling rspec tests in modules

Added by Mike Pountney almost 5 years ago. Updated almost 2 years ago.

Status:AcceptedStart date:02/01/2010
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:testing
Target version:-
Affected Puppet version:0.25.4 Branch:
Keywords:rspec

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This ticket may be automatically exported to the PUP project on JIRA using the button below:


Description

I’m logging this at the request of James Turnbull:

I’ve recently started on my first puppet custom type/provider, and decided to try to do this a) in a module, and b) with rspec tests.

I was able to get spec tests running, but with quite a bit of hackery, copying files from the main puppet repo:

spec/spec_helper.rb

test/lib test/lib/puppettest test/lib/puppettest/certificates.rb test/lib/puppettest/exetest.rb test/lib/puppettest/fakes.rb test/lib/puppettest/fileparsing.rb test/lib/puppettest/filetesting.rb test/lib/puppettest/parsertesting.rb test/lib/puppettest/railstesting.rb test/lib/puppettest/reporttesting.rb test/lib/puppettest/resourcetesting.rb test/lib/puppettest/runnable_test.rb test/lib/puppettest/servertest.rb test/lib/puppettest/support test/lib/puppettest/support/assertions.rb test/lib/puppettest/support/collection.rb test/lib/puppettest/support/helpers.rb test/lib/puppettest/support/resources.rb test/lib/puppettest/support/utils.rb test/lib/puppettest/support.rb test/lib/puppettest/testcase.rb test/lib/puppettest.rb

Honestly, I haven’t worked out which of these libs are totally required, but puppettest.rb is at a minimum. (puppettest/runnable_test.rb seems to be unrequired so far, except for being called in spec_helper.rb)

Is there a way that this can be made easier? Developing types in modules seems to be a sensible way to go after all – it should allow folk on any client version to add a new type, rather than requiring they upgrade to puppet-latest.

My vcsrepo module (based now on James' tutorial at http://www.kartar.net/2010/02/puppet-types-and-providers-are-easy/ btw) is located at:

http://github.com/mikepea/puppet-git

Naturally, i’m more than happy to help with this work, but my knowledge of the puppet codebase and Rspec framework is very limited.

History

#1 Updated by James Turnbull almost 5 years ago

  • Category set to testing
  • Status changed from Unreviewed to Needs Decision
  • Assignee set to Luke Kanies
  • Target version set to 2.7.x

#2 Updated by Luke Kanies almost 5 years ago

  • Status changed from Needs Decision to Accepted
  • Assignee deleted (Luke Kanies)

I definitely think this is a good idea, but I think overall it’s probably best within the context of a tool like gepetto – you have something on your system that expects a given convention, and that thing makes modules that follow the convention easy to test.

#3 Updated by Anonymous almost 2 years ago

  • Target version deleted (2.7.x)

Also available in: Atom PDF