diff --git a/spec/acceptance/running_strings_generate.rb b/spec/acceptance/running_strings_generate.rb index a8c382e..48c2104 100644 --- a/spec/acceptance/running_strings_generate.rb +++ b/spec/acceptance/running_strings_generate.rb @@ -18,6 +18,19 @@ describe 'Generating module documentation using generate action' do expect(read_file_on(master, '/root/doc/puppet_classes/test.html')).to include('Class: test') end + it 'should generate documentation for puppet functions' do + puppet_version = on(master, facter('puppetversion')).stdout.chomp.to_i + + if puppet_version >= 4 + html_output = read_file_on(master, '/root/doc/puppet_functions_puppet/test_3A_3Aadd.html') + expect(html_output).to include('Adds two integers together.') + expect(html_output).to include('
test::add(1, 2) => 3
') + expect(html_output).to include('

The first integer to add.

') + expect(html_output).to include('

The second integer to add.

') + expect(html_output).to include('

Returns the sum of x and y.

') + end + end + it 'should generate documentation for 3x functions' do expect(read_file_on(master, '/root/doc/puppet_functions_ruby3x/function3x.html')).to include('This is the function documentation for function3x') end diff --git a/spec/fixtures/acceptance/modules/test/functions/add.pp b/spec/fixtures/acceptance/modules/test/functions/add.pp new file mode 100644 index 0000000..21f0d40 --- /dev/null +++ b/spec/fixtures/acceptance/modules/test/functions/add.pp @@ -0,0 +1,9 @@ +# Adds two integers together. +# @param x The first integer to add. +# @param y The second integer to add. +# @return [Integer] Returns the sum of x and y. +# @example Example of adding two integers. +# test::add(1, 2) => 3 +function test::add(Integer $x, Integer $y) { + $x + $y +}