rodjek/rspec-puppet — pull request #41 by domcleal (2012-08-24 22:44:57+00:00)
Title: Add Puppet[:libdir] as an rspec config option

Unsure if this is the correct solution to the problem, so I'd appreciate feedback if not.

My example setup:

$ tree
.
|-- manifests
| `-- init.pp
|-- Rakefile
`-- spec
|-- classes
| `-- ssh_spec.rb
|-- defines
|-- fixtures
| |-- manifests
| | `-- site.pp
| `-- modules
| |-- augeasproviders -> /home/dcleal/code/augeas/domcleal-augeasproviders
| `-- ssh
| `-- manifests -> ../../../../manifests
|-- functions
|-- hosts
`-- spec_helper.rb

12 directories, 5 files

The augeasproviders module is from domcleal/augeasproviders and distributes bits of its own under its "lib" directory:

lib
|-- augeasproviders
| `-- provider.rb
|-- augeasproviders.rb
`-- puppet
|-- provider
| |-- sshd_config
| | `-- augeas.rb

The provider then has a `require 'augeasproviders/provider'`, which fails. I believe this pattern is essentially what was [agreed on puppet-users recently](https://groups.google.com/d/topic/puppet-users/BGTVWDxr1vc/discussion) (albeit with "PuppetX").

Could not autoload sshd_config: Could not autoload /home/dcleal/code/puppet/augeas-examples/modules/ssh/spec/fixtures/modules/augeasproviders/lib/puppet/provider/sshd_config/augeas.rb: cannot load such file -- augeasproviders/provider at /home/dcleal/code/puppet/augeas-examples/modules/ssh/spec/fixtures/modules/ssh/manifests/init.pp:7 on node iridium

So this this allows lib_dir to be set. I set up my "ssh" module's spec_helper.rb with this:

c.lib_dir = Dir["#{c.module_path}/*/lib"].entries.join(File::PATH_SEPARATOR)