Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of testing an individual element of an array from a parameter of a resource in rspec-puppet
require 'spec_helper'
describe 'hosttest' do
context 'with default values for all parameters' do
context 'With foo.local host pre_condition' do
let(:pre_condition) {"
host { 'foo.local':
ip => '',
host_aliases => [ 'foo1.local', 'foo2.local' ],
# This style works, but it requires the exact and full array for comparison
it { should contain_host('foo.local').with_host_aliases( ['foo1.local', 'foo2.local'] ) }
# This works, but it feels really awkard to do
it {
host_aliases = catalogue.resource('host', 'foo.local').send(:parameters)[:host_aliases]
expect(host_aliases).to include('foo1.local')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.