天道酬勤,学无止境

rspec-puppet

Why do I get puppet-rspec 'class does not exist' when it does?

I setup a new puppet demo module with the following Gemfile and it worked as expected when I ran a simple puppet-rspec test. Gemfile source 'https://rubygems.org' if puppetversion = ENV['PUPPET_GEM_VERSION'] gem 'puppet', puppetversion, :require => false else gem 'puppet', '3.7.5' end gem 'metadata-json-lint' gem 'puppetlabs_spec_helper', '>= 0.1.0' gem 'puppet-lint', '>= 1.0.0' gem 'facter', '>= 1.7.0' gem 'rspec-puppet-facts' # rspec must be v2 for ruby 1.8.7 if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9' gem 'rspec', '~> 2.0' end However when I cloned an existing module (silex) and

2021-11-26 08:13:20    分类:问答    rspec   puppet   rspec-puppet

Rspec + puppet:嵌套装置?(Rspec + puppet: nested fixtures?)

问题 我正在尝试开始使用 rspec 来测试一些已经制作(和生产中)的木偶模块,但是这件事一直试图让我生气。 首先,我正在用 rake 做一个“完整”的测试。 任务是: 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

2021-11-13 03:06:34    分类:技术分享    puppet   rspec-puppet

Rspec + puppet: nested fixtures?

i am trying to start using rspec to test some already made (and in production) puppet modules, but this thing keep trying to make me mad. First off, i am doing a "complete" test with rake. The task is: 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

2021-11-09 17:23:09    分类:问答    puppet   rspec-puppet

启动 RSpec-puppet 单元测试的正确方法(Correct way to start RSpec-puppet unit tests)

问题 我创建了一个简单的 Puppet 4 类和一个单元测试,如下(在执行touch metadata.json; rspec-puppet-init而在modules/test/ ): # modules/test/manifests/hello_world1.pp class test::hello_world1 { file { "/tmp/hello_world1": content => "Hello, world!\n" } } # modules/test/spec/classes/test__hello_world1_spec.rb require 'spec_helper' describe 'test::hello_world1' do it { is_expected.to compile } it { is_expected.to contain_file('/tmp/hello_world1')\ .with_content(/^Hello, world!$/) } end 我可以通过在modules/test/执行rspec spec/classes/test__hello_world1_spec.rb来成功运行单元测试。 我现在想继续学习一个稍微高级一点的类,它使用另一个模块的代码,即 concat (该模块已经安装在modules/concat ):

2021-10-16 16:26:01    分类:技术分享    unit-testing   rspec   puppet   rspec-puppet

Correct way to start RSpec-puppet unit tests

I have created a simple Puppet 4 class and a unit test to go along with it as follows (after executing touch metadata.json; rspec-puppet-init while in modules/test/): # modules/test/manifests/hello_world1.pp class test::hello_world1 { file { "/tmp/hello_world1": content => "Hello, world!\n" } } # modules/test/spec/classes/test__hello_world1_spec.rb require 'spec_helper' describe 'test::hello_world1' do it { is_expected.to compile } it { is_expected.to contain_file('/tmp/hello_world1')\ .with_content(/^Hello, world!$/) } end I can successfully run the unit test by executing rspec spec/classes

2021-06-24 13:49:32    分类:问答    unit-testing   rspec   puppet   rspec-puppet