我正在尝试使用rspec和puppet来检查.erb文件中配置文件的生成。但是,我收到了错误
1) customizations should generate valid logstash.conf
Failure/Error: content = catalogue.resource('file', 'logstash.conf').send(:parameters)[:content]
ArgumentError:
wrong number of arguments (0 for 1)
# ./spec/classes/logstash_spec.rb:29:in `catalogue'
# ./spec/classes/logstash_spec.rb:29
logstash_spec.rb :
describe "customizations" do
let(:params) { {:template => "profiles/logstash/output_broker.erb", :options => {'opt_a' => 'value_a' } } }
it 'should generate valid logstash.conf' do
content = catalogue.resource('file', 'logstash.conf').send(:parameters)[:content]
content.should match('logstash')
end
end
如何修复错误"错误的参数数量"?
答案 0 :(得分:1)
我认为您正在混合rspec
和rspec-puppet
样式代码。
如果您正在测试logstash
课程,那么您的rspec-puppet代码应该是
# spec/classes/logstash_spec.rb
require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
describe 'logstash' do
let(:params) { {:template => "profiles/logstash/output_broker.erb", :options => {'opt_a' => 'value_a' } } }
it { should contain_file('logstash.conf').with_content(/logstash/) }
end
请注意,我从未在此上下文中使用正则表达式,但这是您要遵循的一般结构。