monkey-patch match_manifests to not load init.pp when not necessary
monkey-patch match_manifests to not load init.pp when not necessary

When loading a class, Puppet::Module::match_manifests is used to list
candidate filenames.  To maintain backwards compatibility, it will return
init.pp for the module first in the list, so that a class may be declared
outside autoload namespace (Puppet bug #4220).

Normally, this does not cause any problems, but if pre_condition is used
to make a simplified version of the top class in your module, Puppet will
complain about a duplicate declaration.

  describe "baseconfig::logging" do
    let(:pre_condition) { [
     'class baseconfig($enable_filebeat=false) { }',
     'include baseconfig',
    ] }

This results in an error like this:

  error during compilation: Class 'baseconfig' is already defined (line: 2); cannot
  redefine (file: /home/kjetilho/src/baseconfig/spec/fixtures/modules/baseconfig/manifests/init.pp,
  line: 6) on node ranger.ms.redpill-linpro.com

The patch changes the logic so that it removes init.pp from the beginning
of the list if there are other files in the list.  This will break code
which puts the class foo::bar in foo/manifests/init.pp *and* has a file
foo/manifests/bar.pp in the project, but I believe such code thoroughly
deserves to break.

puppetlabs/rspec-puppet,rodjek/rspec-puppet,DavidS/rspec-puppet