From beb79d3a6362f150b70b92b56c81d6e6e8815249 Mon Sep 17 00:00:00 2001 From: Will Hopper Date: Thu, 29 Sep 2016 15:58:06 -0700 Subject: [PATCH] (PDOC-88) Add acceptance test for puppet functions --- spec/acceptance/running_strings_generate.rb | 13 +++++++++++++ .../acceptance/modules/test/functions/add.pp | 9 +++++++++ 2 files changed, 22 insertions(+) create mode 100644 spec/fixtures/acceptance/modules/test/functions/add.pp 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 +}