我在下面显示了file_line资源
class login {
if $::operatingsystemmajrelease < 7 {
file {'/etc/loginfile':
ensure => present,
}
file_line { 'testfile':
path => '/etc/loginfile',
line => 'abc 022',
match => '^abc.*$',
}
}
}
下面是rspec文件
require 'spec_helper'
describe 'login' do
it { should contain_class('login')}
let(:facts) {{:operatingsystemmajrelease => 6}}
if (6 < 7)
it { should contain_file('/etc/loginfile').with_ensure('present')}
it { should contain_file_line('testfile').with(
:path => '/etc/loginfile',
:line => 'abc 022',
:match => '^abc.*$'
)}
end
end
当我运行rake-spec命令时出现以下错误
login
Failure/Error: it { should contain_class('login')}
Puppet::Error:
Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type file_line at /etc/puppetlabs/modulename/login/spec/fixtures/modules/login_defs/manifests/init.pp:17 on node
# ./spec/classes/login_spec.rb:5
rspec不支持file_line resporce?
如果我删除&#34; file_line&#34;资源并运行rsepc文件其工作
答案 0 :(得分:1)
file_line位于puppetlabs-stdlib中,因此您需要将其包含在测试夹具中。
最简单的方法是在.fixtures.yml:
fixtures:
repositories:
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib"