puppet-strings 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -2
- data/lib/puppet-strings.rb +2 -2
- data/lib/puppet-strings/markdown.rb +1 -1
- data/lib/puppet-strings/markdown/base.rb +6 -0
- data/lib/puppet-strings/markdown/data_type.rb +16 -0
- data/lib/puppet-strings/markdown/resource_type.rb +19 -2
- data/lib/puppet-strings/markdown/templates/classes_and_defines.erb +4 -4
- data/lib/puppet-strings/markdown/templates/data_type.erb +11 -4
- data/lib/puppet-strings/markdown/templates/data_type_function.erb +67 -0
- data/lib/puppet-strings/markdown/templates/function.erb +2 -1
- data/lib/puppet-strings/markdown/templates/puppet_task.erb +1 -1
- data/lib/puppet-strings/markdown/templates/resource_type.erb +12 -12
- data/lib/puppet-strings/markdown/templates/table_of_contents.erb +6 -6
- data/lib/puppet-strings/version.rb +1 -1
- data/lib/puppet-strings/yard/code_objects/data_type.rb +26 -6
- data/lib/puppet-strings/yard/code_objects/type.rb +46 -5
- data/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +190 -43
- data/lib/puppet-strings/yard/handlers/ruby/type_base.rb +6 -0
- data/lib/puppet-strings/yard/handlers/ruby/type_extras_handler.rb +1 -1
- data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/method_details_list.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb +9 -1
- data/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb +3 -1
- metadata +4 -46
- data/CODEOWNERS +0 -1
- data/Gemfile +0 -53
- data/HISTORY.md +0 -218
- data/JSON.md +0 -832
- data/Rakefile +0 -160
- data/codecov.yml +0 -3
- data/misc/ANNOUNCEMENT_TEMPLATE.md +0 -40
- data/spec/acceptance/emit_json_options_spec.rb +0 -69
- data/spec/acceptance/generate_markdown_spec.rb +0 -47
- data/spec/acceptance/running_strings_generate_spec.rb +0 -88
- data/spec/fixtures/acceptance/modules/test/functions/add.pp +0 -9
- data/spec/fixtures/acceptance/modules/test/lib/puppet/functions/4x_function.rb +0 -5
- data/spec/fixtures/acceptance/modules/test/lib/puppet/parser/functions/function3x.rb +0 -2
- data/spec/fixtures/acceptance/modules/test/lib/puppet/provider/server/linux.rb +0 -9
- data/spec/fixtures/acceptance/modules/test/lib/puppet/type/database.rb +0 -15
- data/spec/fixtures/acceptance/modules/test/manifests/init.pp +0 -31
- data/spec/fixtures/acceptance/modules/test/manifests/triple_nested_classes.pp +0 -27
- data/spec/fixtures/acceptance/modules/test/metadata.json +0 -10
- data/spec/fixtures/acceptance/modules/test/types/elephant.pp +0 -2
- data/spec/fixtures/unit/markdown/output.md +0 -561
- data/spec/fixtures/unit/markdown/output_with_data_types.md +0 -606
- data/spec/fixtures/unit/markdown/output_with_plan.md +0 -595
- data/spec/spec_helper.rb +0 -49
- data/spec/spec_helper_acceptance.rb +0 -58
- data/spec/spec_helper_acceptance_local.rb +0 -10
- data/spec/unit/puppet-strings/describe_spec.rb +0 -141
- data/spec/unit/puppet-strings/json_spec.rb +0 -302
- data/spec/unit/puppet-strings/markdown/base_spec.rb +0 -146
- data/spec/unit/puppet-strings/markdown_spec.rb +0 -374
- data/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +0 -92
- data/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +0 -116
- data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +0 -217
- data/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb +0 -65
- data/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +0 -231
- data/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +0 -315
- data/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +0 -309
- data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +0 -746
- data/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +0 -158
- data/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +0 -235
- data/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +0 -311
- data/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb +0 -72
- data/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +0 -56
- data/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +0 -251
- data/spec/unit/puppet-strings/yard/util_spec.rb +0 -48
@@ -1,92 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'puppet-strings/yard/code_objects/task'
|
3
|
-
require 'puppet-strings/yard/parsers/json/task_statement'
|
4
|
-
|
5
|
-
describe PuppetStrings::Yard::CodeObjects::Task do
|
6
|
-
let(:source) { <<-SOURCE
|
7
|
-
{
|
8
|
-
"description": "Allows you to backup your database to local file.",
|
9
|
-
"input_method": "stdin",
|
10
|
-
"parameters": {
|
11
|
-
"database": {
|
12
|
-
"description": "Database to connect to",
|
13
|
-
"type": "Optional[String[1]]"
|
14
|
-
},
|
15
|
-
"user": {
|
16
|
-
"description": "The user",
|
17
|
-
"type": "Optional[String[1]]"
|
18
|
-
},
|
19
|
-
"password": {
|
20
|
-
"description": "The password",
|
21
|
-
"type": "Optional[String[1]]"
|
22
|
-
},
|
23
|
-
"sql": {
|
24
|
-
"description": "Path to file you want backup to",
|
25
|
-
"type": "String[1]"
|
26
|
-
}
|
27
|
-
}
|
28
|
-
}
|
29
|
-
SOURCE
|
30
|
-
}
|
31
|
-
let(:json) { JSON.parse(source) }
|
32
|
-
let(:statement) { PuppetStrings::Yard::Parsers::JSON::TaskStatement.new(json, source, "test.json") }
|
33
|
-
subject { PuppetStrings::Yard::CodeObjects::Task.new(statement) }
|
34
|
-
|
35
|
-
describe '#type' do
|
36
|
-
it 'returns the correct type' do
|
37
|
-
expect(subject.type).to eq(:puppet_task)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#source' do
|
42
|
-
it 'returns the source' do
|
43
|
-
expect(subject.source).to eq(source)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#to_hash' do
|
48
|
-
let(:expected) do
|
49
|
-
{
|
50
|
-
:name => "test",
|
51
|
-
:supports_noop => false,
|
52
|
-
:docstring => {
|
53
|
-
:text=>"Allows you to backup your database to local file.",
|
54
|
-
:tags=> [
|
55
|
-
{
|
56
|
-
:name=>"database",
|
57
|
-
:tag_name=>"param",
|
58
|
-
:text=>"Database to connect to",
|
59
|
-
:types=> ["Optional[String[1]]"]
|
60
|
-
},
|
61
|
-
{
|
62
|
-
:name=>"user",
|
63
|
-
:tag_name=>"param",
|
64
|
-
:text=>"The user",
|
65
|
-
:types=> ["Optional[String[1]]"]
|
66
|
-
},
|
67
|
-
{
|
68
|
-
:name=>"password",
|
69
|
-
:tag_name=>"param",
|
70
|
-
:text=>"The password",
|
71
|
-
:types=> ["Optional[String[1]]"]
|
72
|
-
},
|
73
|
-
{
|
74
|
-
:name=>"sql",
|
75
|
-
:tag_name=>"param",
|
76
|
-
:text=>"Path to file you want backup to",
|
77
|
-
:types=>["String[1]"]
|
78
|
-
}
|
79
|
-
]
|
80
|
-
},
|
81
|
-
:file => "test.json",
|
82
|
-
:input_method => "stdin",
|
83
|
-
:line => 0,
|
84
|
-
:source => "{\n \"description\": \"Allows you to backup your database to local file.\",\n \"input_method\": \"stdin\",\n \"parameters\": {\n \"database\": {\n \"description\": \"Database to connect to\",\n \"type\": \"Optional[String[1]]\"\n },\n \"user\": {\n \"description\": \"The user\",\n \"type\": \"Optional[String[1]]\"\n },\n \"password\": {\n \"description\": \"The password\",\n \"type\": \"Optional[String[1]]\"\n },\n \"sql\": {\n \"description\": \"Path to file you want backup to\",\n \"type\": \"String[1]\"\n }\n }\n}\n"
|
85
|
-
}
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'returns the correct hash' do
|
89
|
-
expect(subject.to_hash).to eq(expected)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'puppet-strings/yard'
|
3
|
-
|
4
|
-
describe PuppetStrings::Yard::Handlers::JSON::TaskHandler do
|
5
|
-
subject {
|
6
|
-
YARD::Parser::SourceParser.parse_string(source, :json)
|
7
|
-
YARD::Registry.all(:puppet_task)
|
8
|
-
}
|
9
|
-
|
10
|
-
describe 'parsing task metadata with a syntax error' do
|
11
|
-
let(:source) { <<-SOURCE
|
12
|
-
{
|
13
|
-
"input_method": "stdin",
|
14
|
-
"parameters":
|
15
|
-
"database": {
|
16
|
-
"description": "Database to connect to",
|
17
|
-
"type": "Optional[String[1]]"
|
18
|
-
}
|
19
|
-
}
|
20
|
-
}
|
21
|
-
SOURCE
|
22
|
-
}
|
23
|
-
|
24
|
-
it 'should log an error' do
|
25
|
-
expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\):/).to_stdout_from_any_process
|
26
|
-
expect(subject.empty?).to eq(true)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe 'parsing task metadata with a missing description' do
|
31
|
-
let(:source) { <<-SOURCE
|
32
|
-
{
|
33
|
-
"input_method": "stdin",
|
34
|
-
"parameters": {
|
35
|
-
"database": {
|
36
|
-
"description": "Database to connect to",
|
37
|
-
"type": "Optional[String[1]]"
|
38
|
-
},
|
39
|
-
"user": {
|
40
|
-
"description": "The user",
|
41
|
-
"type": "Optional[String[1]]"
|
42
|
-
},
|
43
|
-
"password": {
|
44
|
-
"description": "The password",
|
45
|
-
"type": "Optional[String[1]]"
|
46
|
-
},
|
47
|
-
"sql": {
|
48
|
-
"description": "Path to file you want backup to",
|
49
|
-
"type": "String[1]"
|
50
|
-
}
|
51
|
-
}
|
52
|
-
}
|
53
|
-
SOURCE
|
54
|
-
}
|
55
|
-
|
56
|
-
it 'should log a warning' do
|
57
|
-
expect{ subject }.to output(/\[warn\]: Missing a description for Puppet Task \(stdin\)/).to_stdout_from_any_process
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'parsing task metadata with a description' do
|
62
|
-
let(:source) { <<-SOURCE
|
63
|
-
{
|
64
|
-
"description": "Allows you to backup your database to local file.",
|
65
|
-
"input_method": "stdin",
|
66
|
-
"parameters": {
|
67
|
-
"database": {
|
68
|
-
"description": "Database to connect to",
|
69
|
-
"type": "Optional[String[1]]"
|
70
|
-
},
|
71
|
-
"user": {
|
72
|
-
"description": "The user",
|
73
|
-
"type": "Optional[String[1]]"
|
74
|
-
},
|
75
|
-
"password": {
|
76
|
-
"description": "The password",
|
77
|
-
"type": "Optional[String[1]]"
|
78
|
-
},
|
79
|
-
"sql": {
|
80
|
-
"description": "Path to file you want backup to",
|
81
|
-
"type": "String[1]"
|
82
|
-
}
|
83
|
-
}
|
84
|
-
}
|
85
|
-
|
86
|
-
SOURCE
|
87
|
-
}
|
88
|
-
|
89
|
-
it 'should register a task object' do
|
90
|
-
expect(subject.size).to eq(1)
|
91
|
-
object = subject.first
|
92
|
-
expect(object).to be_a(PuppetStrings::Yard::CodeObjects::Task)
|
93
|
-
expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::Tasks.instance)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe 'parsing task metadata with a missing parameter description' do
|
98
|
-
let(:source) { <<-SOURCE
|
99
|
-
{
|
100
|
-
"description": "Allows you to backup your database to local file.",
|
101
|
-
"input_method": "stdin",
|
102
|
-
"parameters": {
|
103
|
-
"database": {
|
104
|
-
"type": "Optional[String[1]]"
|
105
|
-
}
|
106
|
-
}
|
107
|
-
}
|
108
|
-
SOURCE
|
109
|
-
}
|
110
|
-
|
111
|
-
it 'should output a warning' do
|
112
|
-
expect{ subject }.to output(/\[warn\]: Missing description for param 'database' in Puppet Task \(stdin\)/).to_stdout_from_any_process
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
@@ -1,217 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'puppet-strings/yard'
|
3
|
-
|
4
|
-
describe PuppetStrings::Yard::Handlers::Puppet::ClassHandler do
|
5
|
-
subject {
|
6
|
-
YARD::Parser::SourceParser.parse_string(source, :puppet)
|
7
|
-
YARD::Registry.all(:puppet_class)
|
8
|
-
}
|
9
|
-
|
10
|
-
describe 'parsing source without a class definition' do
|
11
|
-
let(:source) { 'notice hi' }
|
12
|
-
|
13
|
-
it 'no classes should be in the registry' do
|
14
|
-
expect(subject.empty?).to eq(true)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'parsing source with a syntax error' do
|
19
|
-
let(:source) { 'class foo{' }
|
20
|
-
|
21
|
-
it 'should log an error' do
|
22
|
-
expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\): Syntax error at end of (file|input)/).to_stdout_from_any_process
|
23
|
-
expect(subject.empty?).to eq(true)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'parsing a class with a missing docstring' do
|
28
|
-
let(:source) { 'class foo{}' }
|
29
|
-
|
30
|
-
it 'should log a warning' do
|
31
|
-
expect{ subject }.to output(/\[warn\]: Missing documentation for Puppet class 'foo' at \(stdin\):1\./).to_stdout_from_any_process
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe 'parsing a class with a docstring' do
|
36
|
-
let(:source) { <<-SOURCE
|
37
|
-
# A simple foo class.
|
38
|
-
# @param param1 First param.
|
39
|
-
# @param param2 Second param.
|
40
|
-
# @param param3 Third param.
|
41
|
-
class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {
|
42
|
-
file { '/tmp/foo':
|
43
|
-
ensure => present
|
44
|
-
}
|
45
|
-
}
|
46
|
-
SOURCE
|
47
|
-
}
|
48
|
-
|
49
|
-
it 'should register a class object' do
|
50
|
-
expect(subject.size).to eq(1)
|
51
|
-
object = subject.first
|
52
|
-
expect(object).to be_a(PuppetStrings::Yard::CodeObjects::Class)
|
53
|
-
expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::Classes.instance)
|
54
|
-
expect(object.name).to eq(:foo)
|
55
|
-
expect(object.statement).not_to eq(nil)
|
56
|
-
expect(object.parameters).to eq([['param1', nil], ['param2', nil], ['param3', 'hi']])
|
57
|
-
expect(object.docstring).to eq('A simple foo class.')
|
58
|
-
expect(object.docstring.tags.size).to eq(4)
|
59
|
-
tags = object.docstring.tags(:param)
|
60
|
-
expect(tags.size).to eq(3)
|
61
|
-
expect(tags[0].name).to eq('param1')
|
62
|
-
expect(tags[0].text).to eq('First param.')
|
63
|
-
expect(tags[0].types).to eq(['Integer'])
|
64
|
-
expect(tags[1].name).to eq('param2')
|
65
|
-
expect(tags[1].text).to eq('Second param.')
|
66
|
-
expect(tags[1].types).to eq(['Any'])
|
67
|
-
expect(tags[2].name).to eq('param3')
|
68
|
-
expect(tags[2].text).to eq('Third param.')
|
69
|
-
expect(tags[2].types).to eq(['String'])
|
70
|
-
tags = object.docstring.tags(:api)
|
71
|
-
expect(tags.size).to eq(1)
|
72
|
-
expect(tags[0].text).to eq('public')
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe 'parsing a class with a missing parameter' do
|
77
|
-
let(:source) { <<-SOURCE
|
78
|
-
# A simple foo class.
|
79
|
-
# @param param1 First param.
|
80
|
-
# @param param2 Second param.
|
81
|
-
# @param param3 Third param.
|
82
|
-
# @param param4 missing!
|
83
|
-
class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {
|
84
|
-
file { '/tmp/foo':
|
85
|
-
ensure => present
|
86
|
-
}
|
87
|
-
}
|
88
|
-
SOURCE
|
89
|
-
}
|
90
|
-
|
91
|
-
it 'should output a warning' do
|
92
|
-
expect{ subject }.to output(/\[warn\]: The @param tag for parameter 'param4' has no matching parameter at \(stdin\):6\./).to_stdout_from_any_process
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe 'parsing a class with a missing @param tag' do
|
97
|
-
let(:source) { <<-SOURCE
|
98
|
-
# A simple foo class.
|
99
|
-
# @param param1 First param.
|
100
|
-
# @param param2 Second param.
|
101
|
-
class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {
|
102
|
-
file { '/tmp/foo':
|
103
|
-
ensure => present
|
104
|
-
}
|
105
|
-
}
|
106
|
-
SOURCE
|
107
|
-
}
|
108
|
-
|
109
|
-
it 'should output a warning' do
|
110
|
-
expect{ subject }.to output(/\[warn\]: Missing @param tag for parameter 'param3' near \(stdin\):4\./).to_stdout_from_any_process
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe 'parsing a class with a typed parameter that also has a @param tag type which matches' do
|
115
|
-
let(:source) { <<-SOURCE
|
116
|
-
# A simple foo class.
|
117
|
-
# @param [Integer] param1 First param.
|
118
|
-
# @param param2 Second param.
|
119
|
-
# @param param3 Third param.
|
120
|
-
class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {
|
121
|
-
file { '/tmp/foo':
|
122
|
-
ensure => present
|
123
|
-
}
|
124
|
-
}
|
125
|
-
SOURCE
|
126
|
-
}
|
127
|
-
|
128
|
-
it 'should respect the type that was documented' do
|
129
|
-
expect{ subject }.to output('').to_stdout_from_any_process
|
130
|
-
expect(subject.size).to eq(1)
|
131
|
-
tags = subject.first.tags(:param)
|
132
|
-
expect(tags.size).to eq(3)
|
133
|
-
expect(tags[0].types).to eq(['Integer'])
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe 'parsing a class with a typed parameter that also has a @param tag type which does not match' do
|
138
|
-
let(:source) { <<-SOURCE
|
139
|
-
# A simple foo class.
|
140
|
-
# @param [Boolean] param1 First param.
|
141
|
-
# @param param2 Second param.
|
142
|
-
# @param param3 Third param.
|
143
|
-
class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {
|
144
|
-
file { '/tmp/foo':
|
145
|
-
ensure => present
|
146
|
-
}
|
147
|
-
}
|
148
|
-
SOURCE
|
149
|
-
}
|
150
|
-
|
151
|
-
it 'should output a warning' do
|
152
|
-
expect{ subject }.to output(/\[warn\]: The type of the @param tag for parameter 'param1' does not match the parameter type specification near \(stdin\):5: ignoring in favor of parameter type information./).to_stdout_from_any_process
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
describe 'parsing a class with a untyped parameter that also has a @param tag type' do
|
157
|
-
let(:source) { <<-SOURCE
|
158
|
-
# A simple foo class.
|
159
|
-
# @param param1 First param.
|
160
|
-
# @param [Boolean] param2 Second param.
|
161
|
-
# @param param3 Third param.
|
162
|
-
class foo(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {
|
163
|
-
file { '/tmp/foo':
|
164
|
-
ensure => present
|
165
|
-
}
|
166
|
-
}
|
167
|
-
SOURCE
|
168
|
-
}
|
169
|
-
|
170
|
-
it 'should respect the type that was documented' do
|
171
|
-
expect{ subject }.to output('').to_stdout_from_any_process
|
172
|
-
expect(subject.size).to eq(1)
|
173
|
-
tags = subject.first.tags(:param)
|
174
|
-
expect(tags.size).to eq(3)
|
175
|
-
expect(tags[1].types).to eq(['Boolean'])
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
describe 'parsing a class with a summary' do
|
180
|
-
context 'when the summary has fewer than 140 characters' do
|
181
|
-
let(:source) { <<-SOURCE
|
182
|
-
# A simple foo class.
|
183
|
-
# @summary A short summary.
|
184
|
-
class foo() {
|
185
|
-
file { '/tmp/foo':
|
186
|
-
ensure => present
|
187
|
-
}
|
188
|
-
}
|
189
|
-
SOURCE
|
190
|
-
}
|
191
|
-
|
192
|
-
it 'should parse the summary' do
|
193
|
-
expect{ subject }.to output('').to_stdout_from_any_process
|
194
|
-
expect(subject.size).to eq(1)
|
195
|
-
summary = subject.first.tags(:summary)
|
196
|
-
expect(summary.first.text).to eq('A short summary.')
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
context 'when the summary has more than 140 characters' do
|
201
|
-
let(:source) { <<-SOURCE
|
202
|
-
# A simple foo class.
|
203
|
-
# @summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!!
|
204
|
-
class foo() {
|
205
|
-
file { '/tmp/foo':
|
206
|
-
ensure => present
|
207
|
-
}
|
208
|
-
}
|
209
|
-
SOURCE
|
210
|
-
}
|
211
|
-
|
212
|
-
it 'should log a warning' do
|
213
|
-
expect{ subject }.to output(/\[warn\]: The length of the summary for puppet_class 'foo' exceeds the recommended limit of 140 characters./).to_stdout_from_any_process
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'puppet-strings/yard'
|
3
|
-
|
4
|
-
describe PuppetStrings::Yard::Handlers::Puppet::DataTypeAliasHandler, if: TEST_PUPPET_DATATYPES do
|
5
|
-
subject {
|
6
|
-
YARD::Parser::SourceParser.parse_string(source, :puppet)
|
7
|
-
YARD::Registry.all(:puppet_data_type_alias)
|
8
|
-
}
|
9
|
-
|
10
|
-
describe 'parsing source without a type alias definition' do
|
11
|
-
let(:source) { 'notice hi' }
|
12
|
-
|
13
|
-
it 'no aliases should be in the registry' do
|
14
|
-
expect(subject.empty?).to eq(true)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'parsing source with a syntax error' do
|
19
|
-
let(:source) { 'type Testype =' }
|
20
|
-
|
21
|
-
it 'should log an error' do
|
22
|
-
expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\): Syntax error at end of (file|input)/).to_stdout_from_any_process
|
23
|
-
expect(subject.empty?).to eq(true)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'parsing a data type alias with a missing docstring' do
|
28
|
-
let(:source) { 'type Testype = String[1]' }
|
29
|
-
|
30
|
-
it 'should log a warning' do
|
31
|
-
expect{ subject }.to output(/\[warn\]: Missing documentation for Puppet type alias 'Testype' at \(stdin\):1\./).to_stdout_from_any_process
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe 'parsing a data type alias with a summary' do
|
36
|
-
context 'when the summary has fewer than 140 characters' do
|
37
|
-
let(:source) { <<-SOURCE
|
38
|
-
# A simple foo type.
|
39
|
-
# @summary A short summary.
|
40
|
-
type Testype = String[1]
|
41
|
-
SOURCE
|
42
|
-
}
|
43
|
-
|
44
|
-
it 'should parse the summary' do
|
45
|
-
expect{ subject }.to output('').to_stdout_from_any_process
|
46
|
-
expect(subject.size).to eq(1)
|
47
|
-
summary = subject.first.tags(:summary)
|
48
|
-
expect(summary.first.text).to eq('A short summary.')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'when the summary has more than 140 characters' do
|
53
|
-
let(:source) { <<-SOURCE
|
54
|
-
# A simple foo type.
|
55
|
-
# @summary A short summary that is WAY TOO LONG. AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH this is not what a summary is for! It should be fewer than 140 characters!!
|
56
|
-
type Testype = String[1]
|
57
|
-
SOURCE
|
58
|
-
}
|
59
|
-
|
60
|
-
it 'should log a warning' do
|
61
|
-
expect{ subject }.to output(/\[warn\]: The length of the summary for puppet_data_type_alias 'Testype' exceeds the recommended limit of 140 characters./).to_stdout_from_any_process
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|