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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
require 'spec_helper'
require 'puppet/application/describe'
describe Puppet::Application::Describe do
let(:describe) { Puppet::Application[:describe] }
it "lists all types" do
describe.command_line.args << '--list'
expect {
describe.run
}.to output(/These are the types known to puppet:/).to_stdout
end
it "describes a single type" do
describe.command_line.args << 'exec'
expect {
describe.run
}.to output(/exec.*====.*Executes external commands/m).to_stdout
end
it "describes multiple types" do
describe.command_line.args.concat(['exec', 'file'])
expect {
describe.run
}.to output(/Executes external commands.*Manages files, including their content, ownership, and permissions./m).to_stdout
end
it "describes parameters for the type by default" do
describe.command_line.args << 'exec'
expect {
describe.run
}.to output(/Parameters\n----------/m).to_stdout
end
it "lists parameter names, but excludes description in short mode" do
describe.command_line.args.concat(['exec', '-s'])
expect {
describe.run
}.to output(/Parameters.*command, creates, cwd/m).to_stdout
end
it "outputs providers for the type" do
describe.command_line.args.concat(['exec', '--providers'])
expect {
describe.run
}.to output(/Providers.*#{Regexp.escape('**posix**')}.*#{Regexp.escape('**windows**')}/m).to_stdout
end
it "lists metaparameters for a type" do
describe.command_line.args.concat(['exec', '--meta'])
expect {
describe.run
}.to output(/Meta Parameters.*#{Regexp.escape('**notify**')}/m).to_stdout
end
it "outputs no documentation if the summary is missing" do
Puppet::Type.newtype(:describe_test) {}
describe.command_line.args << '--list'
expect {
describe.run
}.to output(/#{Regexp.escape("describe_test - .. no documentation ..")}/).to_stdout
end
it "outputs the first short sentence ending in a dot" do
Puppet::Type.newtype(:describe_test) do
@doc = "ends in a dot."
end
describe.command_line.args << '--list'
expect {
describe.run
}.to output(/#{Regexp.escape("describe_test - ends in a dot\n")}/).to_stdout
end
it "outputs the first short sentence missing a dot" do
Puppet::Type.newtype(:describe_test) do
@doc = "missing a dot"
end
describe.command_line.args << '--list'
expect {
describe.run
}.to output(/describe_test - missing a dot\n/).to_stdout
end
it "truncates long summaries ending in a dot" do
Puppet::Type.newtype(:describe_test) do
@doc = "This sentence is more than 45 characters and ends in a dot."
end
describe.command_line.args << '--list'
expect {
describe.run
}.to output(/#{Regexp.escape("describe_test - This sentence is more than 45 characters and ...")}/).to_stdout
end
it "truncates long summaries missing a dot" do
Puppet::Type.newtype(:describe_test) do
@doc = "This sentence is more than 45 characters and is missing a dot"
end
describe.command_line.args << '--list'
expect {
describe.run
}.to output(/#{Regexp.escape("describe_test - This sentence is more than 45 characters and ...")}/).to_stdout
end
it "formats text with long non-space runs without garbling" do
f = Formatter.new(76)
teststring = <<TESTSTRING
. 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 nick@magpie.puppetlabs.lan
**this part should not repeat!**
TESTSTRING
expected_result = <<EXPECTED
.
1234567890123456789012345678901234567890123456789012345678901234567890123456
7890123456789012345678901234567890 nick@magpie.puppetlabs.lan
**this part should not repeat!**
EXPECTED
result = f.wrap(teststring, {:indent => 0, :scrub => true})
expect(result).to eql(expected_result)
end
end
|