Rspec + puppet:嵌套固定装置?

Rspec + puppet: nested fixtures?

我正在尝试开始使用 rspec 来测试一些已经制作(并在生产中)的木偶模块,但这件事一直让我生气。

首先,我正在使用 rake 进行 "complete" 测试。任务是:

Rakefile:

desc 'Validate manifests, templates, and ruby files'
task :validate do
  Dir['manifests/**/*.pp'].each do |manifest|
    sh "puppet parser validate --noop #{manifest}"
  end
  Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file|
    sh "ruby -c #{ruby_file}" unless ruby_file =~ %r{spec/fixtures}
  end
  Dir['templates/**/*.erb'].each do |template|
    sh "erb -P -x -T '-' #{template} | ruby -c"
  end
end

desc 'Run metadata_lint, lint, validate, and spec tests.'
task :test do
  [:metadata_lint, :lint, :validate, :spec].each do |test|
    Rake::Task[test].invoke
  end

我遇到的第一个问题是这个错误:

  1) rcphp should contain Package[rcphp]
     Failure/Error: it { is_expected.to contain_package('rcphp') }

     Puppet::PreformattedError:
       Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class rcphp at line 1:1 on node test.example.com

经过一段时间的研究,我发现我应该把我正在使用的模块放在.fixtures.yml中。听起来很简单,所以我做了:

fixtures:
  symlinks:
    rcphp: "#{source_dir}"
  repositories:
    php: "git://github.com/voxpupuli/puppet-php.git"
    inifile: "git://github.com/puppetlabs/puppetlabs-inifile.git"
  forge_modules:
    stdlib:
      repo: "puppetlabs/stdlib"
      ref: "4.12.0"

从现在开始,一切都不再有意义了。我收到错误:

 Failure/Error: contain "::yum::repo::${yum_repo}"

 Puppet::PreformattedError:
   Evaluation Error: Error while evaluating a Function Call, Could not find class ::yum::repo::remi_php56 for test.example.com at /home/luis.brandao/git/rcphp/spec/fixtures/modules/php/manifests/repo/redhat.pp:12:3 on node test.example.com

::yum::repo 被 PHP 模块调用。 php 模块有自己的固定装置。我尝试添加它,然后弹出另一个嵌套模块依赖项。 这不可能是对的,我应该弄清楚并手动添加所有依赖树来进行简单测试??

This cant be right, i am supposed to figure it out and add, by hand, ALL the dependency tree to make a simple test??

是的,目前是正确的。