Created
July 4, 2017 13:44
-
-
Save riton/4c51370c6d9c4bc34de69986ff891da9 to your computer and use it in GitHub Desktop.
rspec-puppet-function
This file contains 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
# functions/myfunction.pp | |
function mymodule::myfunction(Array[String] $domains) >> Array { | |
$result = $domains.map |$domain| { | |
{ | |
"${domain}/.../*" => { 'include' => true } | |
} | |
} | |
$result | |
} | |
# vim: tabstop=2 shiftwidth=2 softtabstop=2 |
This file contains 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
# spec/functions/myfunction_spec.rb | |
require 'spec_helper' | |
describe 'mymodule::myfunction', :type => :puppet_function do | |
it 'should return Array' do | |
h = subject.execute(['/d1', '/d2']) | |
expect(h).to be_a(Array) | |
end | |
let(:expected_result) do | |
[ | |
{ '/d1/.../*' => { | |
'include' => true | |
}, | |
}, | |
{ | |
'/d2/.../*' => { | |
'include' => true | |
} | |
} | |
] | |
end | |
it 'should return proper structure with order respected' do | |
h = subject.execute(['/d1', '/d2']) | |
expect(h).to eq(expected_result) | |
end | |
it 'should return empty array when called with empty arg' do | |
h = subject.execute([]) | |
expect(h).to eq([]) | |
end | |
end | |
# vim: tabstop=2 shiftwidth=2 softtabstop=2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment