我试图运行puppet-rspec,但得到一个不是非常具体的错误

时间:2014-03-15 17:23:31

标签: unit-testing testing rspec puppet

我正在尝试让rspec在我的Puppet模块上运行,但是我收到了这个错误:

  1) apache when called with no parameters on redhat
     Failure/Error: })
     Puppet::Error:
       Could not parse for environment production: No file(s) found for import of '' at line 4 on node testhost.example.com
     # ./spec/classes/apache_spec.rb:10:in `block (3 levels) in <top (required)>'

我已经运行了puppet-rspec-init并在spec / classes / apache_spec.rb中添加了一个简单的规范

这是我最好奇的部分;它试图加载什么?

No file(s) found for import of '' at line 4

我确实有.fixtures.yml(modules / apache / .fixtures.yml):

fixtures:
  symlinks:
    "apache": "#{source_dir}"

有人可能会朝着正确的方向推动我吗?我可能错过了一些明显的东西......:S

谢谢, GER。

2 个答案:

答案 0 :(得分:1)

我在固定装置中没有site.pp文件时看到过类似的错误,但我还没有能够复制该问题。如果您还没有,请使用

运行您的第一个规范
it { should compile.with_all_deps }

...在你写任何额外的测试之前。只是让工具设置正常(并跟上变化)比编写测试困难得多;测试很容易。 运行相应的rake任务时,.fixtures文件应该为你创建符号链接,但是如果它没有,请确保你的模块在fixture中符号链接,以及符号链接的任何相关模块。

我喜欢puppetlabs_spec_helper和rspec-puppet,虽然你最终得到了rake spec和rake rspec两者都可用,其中一个或另一个可能无法正常工作。

答案 1 :(得分:1)

PE 3.2中的一些代码更改要求我在'rake spec'之前执行此操作

导出MODULEPATH = / etc / puppetlabs / puppet / modules

感谢来自PuppetLabs的Ben。