
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
rspec-system-puppet
is a Puppet plugin for rspec-system. The goal here is to provide a series of helpers for performing proper system tests on Puppet related modules such as:
While unit testing using rspec-puppet is extremely useful for testing your content based on comparing input of parameters, facts etc. with the desired catalog output, it doesn't however do a real test. This library is meant to augment the rspec-puppet test suite, and is designed specifically to work with it. In fact I suggest running both these tests in parallel with rspec-puppet, as rspec-puppet is always going to execute basic tests faster - especially tests that don't need a real run like comparing template output with desired output, or fine-detailed items like expected property values and logical blocks.
Recommended to be installed first:
In your existing Puppet module project, create a .nodeset.yml
with the following contents:
---
default_set: 'centos-64-x64'
sets:
'centos-59-x64':
nodes:
"main.foo.vm":
prefab: 'centos-59-x64'
'centos-64-x64':
nodes:
"main.foo.vm":
prefab: 'centos-64-x64'
'fedora-18-x64':
nodes:
"main.foo.vm":
prefab: 'fedora-18-x64'
'debian-607-x64':
nodes:
"main.foo.vm":
prefab: 'debian-607-x64'
'debian-70rc1-x64':
nodes:
"main.foo.vm":
prefab: 'debian-70rc1-x64'
'ubuntu-server-10044-x64':
nodes:
"main.foo.vm":
prefab: 'ubuntu-server-10044-x64'
'ubuntu-server-12042-x64':
nodes:
"main.foo.vm":
prefab: 'ubuntu-server-12042-x64'
The intention is that this gem is used within your project as a development library.
You may install rspec-system-puppet
manually with:
# gem install rspec-system-puppet
However it is usually recommended to include gem 'rspec-system-puppet'
in your Gemfile
and let bundler install it. An example Gemfile
is shown below. This includes rspec-puppet
test content as well:
source 'https://rubygems.org'
group :development, :test do
gem 'rake'
gem 'rspec-puppet'
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-system-puppet'
gem 'puppet-lint'
end
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
Install using Bundler with:
bundle install --path vendor/bundle
If you're using git, add .rspec_system
to your project's .gitignore
file. This is the default location for files created by rspec-system.
Create a Rakefile
like so:
require 'puppetlabs_spec_helper/rake_tasks'
require 'rspec-system/rake_task'
task :default do
sh %{rake -T}
end
You will need a spec helper for your tests to require
. So create the file spec/spec_helper_system.rb
:
require 'rspec-system/spec_helper'
require 'rspec-system-puppet/helpers'
include RSpecSystemPuppet::Helpers
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Enable colour
c.tty = true
c.include RSpecSystemPuppet::Helpers
# This is where we 'setup' the nodes before running our tests
c.before :suite do
# Install puppet
puppet_install
puppet_master_install
# Replace mymodule with your module name
puppet_module_install(:source => proj_root, :module_name => 'mymodule')
end
end
I advise you to seperate the location of your system and unit tests:
And create your first system tests in say spec/system/basic_spec.rb
(make sure it has the _spec.rb suffix!):
require 'spec_helper_system'
describe 'basic tests:' do
# Using puppet_apply as a subject
context puppet_apply 'notice("foo")' do
its(:stdout) { should =~ /foo/ }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
end
# Using puppet_apply as a helper
it 'my class should work with no errors' do
pp = <<-EOS
class { 'mymodule': }
EOS
# Run it twice and test for idempotency
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
r.refresh
r.exit_code.should be_zero
end
end
end
Now you should be able to do:
# bundle exec rake spec:system
If you want to test an alternate set, just use the RSPEC_SET
environment variable like so:
# RSPEC_SET=debian-70rc1-x64 bundle exec rake spec:system
Consult the .nodeset.yml
file for the list of sets.
spec/system
for the tests.For now consult the documentation for rspec-system for more details.
FAQs
Unknown package
We found that rspec-system-puppet demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.