File: documentation_spec.rb

package info (click to toggle)
puppet 5.5.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,316 kB
  • sloc: ruby: 254,925; sh: 1,608; xml: 219; makefile: 153; sql: 103
file content (57 lines) | stat: -rw-r--r-- 2,204 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require 'spec_helper'
require 'puppet/face'

describe "documentation of faces" do
  it "should generate global help" do
    help = nil
    expect { help = Puppet::Face[:help, :current].help }.not_to raise_error
    expect(help).to be_an_instance_of String
    expect(help.length).to be > 200
  end

  ########################################################################
  # Can we actually generate documentation for the face, and the actions it
  # has?  This avoids situations where the ERB template turns out to have a
  # bug in it, triggered in something the user might do.

  context "face help messages" do
    Puppet::Face.faces.sort.each do |face_name|
      # REVISIT: We should walk all versions of the face here...
      let :help do Puppet::Face[:help, :current] end

      context "generating help" do
        it "for #{face_name}" do
          expect {
            text = help.help(face_name)
            expect(text).to be_an_instance_of String
            expect(text.length).to be > 100
          }.not_to raise_error
        end

        Puppet::Face[face_name, :current].actions.sort.each do |action_name|
          it "for #{face_name}.#{action_name}" do
            expect {
              text = help.help(face_name, action_name)
              expect(text).to be_an_instance_of String
              expect(text.length).to be > 100
            }.not_to raise_error
          end
        end
      end

      ########################################################################
      # Ensure that we have authorship and copyright information in *our* faces;
      # if you apply this to third party faces you might well be disappointed.
      context "licensing of Puppet Inc. face '#{face_name}'" do
        subject { Puppet::Face[face_name, :current] }
        its :license   do should =~ /Apache\s*2/ end
        its :copyright do should =~ /Puppet Inc\./ end

        # REVISIT: This is less that ideal, I think, but right now I am more
        # comfortable watching us ship with some copyright than without any; we
        # can redress that when it becomes appropriate. --daniel 2011-04-27
        its :copyright do should =~ /20\d{2}/ end
      end
    end
  end
end