Created
January 11, 2017 02:11
-
-
Save Cinderhaze/b75f5f8e6c2a4f5f8ad842366b7f85bd to your computer and use it in GitHub Desktop.
Example of testing an individual element of an array from a parameter of a resource in rspec-puppet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 => '1.2.3.4', | |
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') | |
} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment