Questions tagged [rspec-puppet]

rspec-puppet is a framework for testing Puppet code with the rspec BDD framework

http://rspec-puppet.com/

https://github.com/rodjek/rspec-puppet

49 questions
1
vote
1 answer

Confusing Rspec-puppet deprecation warning: defaults mock_with to :mocha

When running Rspec-puppet tests, a deprecation warning is seen: Deprecation Warnings: puppetlabs_spec_helper: defaults `mock_with` to `:mocha`. See https://github.com/puppetlabs/puppetlabs_spec_helper#mock_with to choose a sensible value for…
Alex Harvey
  • 14,494
  • 5
  • 61
  • 97
1
vote
1 answer

output rspec tests on screen while redirecting them to a file

In .rpsec, --format json --out rspec.json This setting redirects rspec tests results to rspec.json. At same time I also want to watch these results displaying on screen . Is there a way doing that?
fasten
  • 27
  • 4
1
vote
1 answer

How to stub Puppet::Type('user).instances.select

In a fact Im calling Puppet::Type('user').instances.select do |user| #do something with user end How can I stub that in a spec test? I have something like: Puppet::Type.type(:user).stubs(:instances).returns( 'User[root]','User[bin]']) but…
user1571135
  • 199
  • 1
  • 7
1
vote
1 answer

Don't delete public puppet modules after rspec-puppet tests are done

In .fixtures.yml, there are modules downloaded from a public library, such as stdlib and concat in the following example: fixtures: forge_modules: stdlib: puppetlabs/stdlib concat: puppetlabs/concat These modules need to be downloaded…
fasten
  • 27
  • 4
1
vote
1 answer

Use puppet gem to parse node files and generate specs for each host

I'm integrating rspec-puppet tests in our puppet project and I'm trying to auto generate "should compile" specs for all hosts (and eventually probably other resource). This is to ensure everything at least compiles successfully. Given a list of…
eirc
  • 1,654
  • 14
  • 14
1
vote
1 answer

Running unit tests for Puppet modules

I would like to add RSpec unit tests to some Puppet 4 modules. To get started and confirm basic functioning, I would first like to run unit tests that come with standard Puppet modules such as puppetlabs/apt. If I try running a specific unit test…
rookie09
  • 736
  • 1
  • 6
  • 18
1
vote
1 answer

How to define helper methods for manipulating the Puppet catalogue object

I have a bunch of repeated code that manipulates the Puppet catalogue object (notice the repeated content = lines): require 'nokogiri' describe 'role::jenkins' do before(:each) do @jobs = catalogue.resource_keys.select{|k,v| k ==…
Alex Harvey
  • 14,494
  • 5
  • 61
  • 97
1
vote
2 answers

Rspec puppet module testing: access to included classes' custom facts

Is there a standard pattern for writing spec tests for a puppet module, that correctly creates the custom facts that are required by the modules that the tested module includes? I have a module whose class includes puppetlabs/mongodb, which uses the…
Chris Owens
  • 1,107
  • 1
  • 10
  • 15
1
vote
1 answer

Why does rspec puppet fail with undefined method error when switching ruby versions?

I developed my puppet module with ruby version 1.8.7 ran bundle install on the following gem file and rspec tests worked successfully (so did the puppet run): source 'https://rubygems.org' if puppetversion = ENV['PUPPET_GEM_VERSION'] gem…
kaizenCoder
  • 2,211
  • 6
  • 33
  • 64
1
vote
1 answer

Is it possible to write a test in rspec-puppet to check if registry exists?

I am trying to install .net framework 4.5.2 using puppet module using exec resource instead of using Package resource due to some reason. I want to write a test case to check if it is installed or not. The only way I could find to check if it is…
Ankita13
  • 469
  • 2
  • 7
  • 21
1
vote
1 answer

Puppet Rspec: class has not been evaluated

I am writing an rspec test for a puppet module which makes the following call: lookupvar('services::service') When I run the test I get the following warning: Could not look up qualified variable 'services::service'; class services has not been…
alecswan
  • 3,670
  • 5
  • 25
  • 35
1
vote
1 answer

rspec-puppet does not support file_line resource

I have below manifests with file_line resource class login { if $::operatingsystemmajrelease < 7 { file {'/etc/loginfile': ensure => present, } file_line { 'testfile': path => '/etc/loginfile', line => 'abc…
Puppeteer
  • 63
  • 1
  • 7
1
vote
1 answer

Using external variable in rspec-puppet test

Have some stuck with using variable in rspec. Here is my params.pp case $::osfamily{ Debian: { $ssh_daemon = "ssh" } Redhat: { $ssh_daemon = "sshd" } In an rspec test I need to use the variable $ssh_daemon like this: it { should…
Andrey
  • 13
  • 3
1
vote
1 answer

How to setup puppet-rspec correctly?

I'm following the instructions from here gem install rvm gem install bundle # Demo dir # Gemfile source "https://rubygems.org" gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'puppet', '~> 3.7.5' gem…
kaizenCoder
  • 2,211
  • 6
  • 33
  • 64
1
vote
1 answer

write puppet config to clone github repo

I've written a Puppet module to install Git on Windows. The Puppet Master is Linux. Is it possible to write a Puppet manifest to clone a GitHub repo using just puppet resources (i.e. without a script or exec)? This is a private repo, so the…
BaltoStar
  • 8,165
  • 17
  • 59
  • 91