puppet-strings 2.3.0 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +102 -4
  3. data/COMMITTERS.md +17 -17
  4. data/CONTRIBUTING.md +37 -7
  5. data/README.md +17 -12
  6. data/lib/puppet-strings.rb +5 -3
  7. data/lib/puppet-strings/describe.rb +2 -0
  8. data/lib/puppet-strings/json.rb +2 -0
  9. data/lib/puppet-strings/markdown.rb +12 -10
  10. data/lib/puppet-strings/markdown/base.rb +30 -3
  11. data/lib/puppet-strings/markdown/data_type.rb +18 -0
  12. data/lib/puppet-strings/markdown/data_types.rb +3 -1
  13. data/lib/puppet-strings/markdown/defined_type.rb +2 -0
  14. data/lib/puppet-strings/markdown/defined_types.rb +3 -1
  15. data/lib/puppet-strings/markdown/function.rb +9 -7
  16. data/lib/puppet-strings/markdown/functions.rb +3 -1
  17. data/lib/puppet-strings/markdown/puppet_class.rb +2 -0
  18. data/lib/puppet-strings/markdown/puppet_classes.rb +3 -1
  19. data/lib/puppet-strings/markdown/puppet_plan.rb +2 -0
  20. data/lib/puppet-strings/markdown/puppet_plans.rb +3 -1
  21. data/lib/puppet-strings/markdown/puppet_task.rb +2 -0
  22. data/lib/puppet-strings/markdown/puppet_tasks.rb +3 -1
  23. data/lib/puppet-strings/markdown/resource_type.rb +21 -2
  24. data/lib/puppet-strings/markdown/resource_types.rb +3 -1
  25. data/lib/puppet-strings/markdown/table_of_contents.rb +3 -1
  26. data/lib/puppet-strings/markdown/templates/classes_and_defines.erb +18 -6
  27. data/lib/puppet-strings/markdown/templates/data_type.erb +30 -7
  28. data/lib/puppet-strings/markdown/templates/data_type_function.erb +67 -0
  29. data/lib/puppet-strings/markdown/templates/function.erb +10 -1
  30. data/lib/puppet-strings/markdown/templates/puppet_task.erb +1 -1
  31. data/lib/puppet-strings/markdown/templates/resource_type.erb +35 -13
  32. data/lib/puppet-strings/markdown/templates/table_of_contents.erb +6 -6
  33. data/lib/puppet-strings/monkey_patches/display_object_command.rb +2 -0
  34. data/lib/puppet-strings/tasks.rb +2 -0
  35. data/lib/puppet-strings/tasks/generate.rb +2 -0
  36. data/lib/puppet-strings/tasks/gh_pages.rb +3 -0
  37. data/lib/puppet-strings/version.rb +3 -1
  38. data/lib/puppet-strings/yard.rb +9 -0
  39. data/lib/puppet-strings/yard/code_objects.rb +2 -0
  40. data/lib/puppet-strings/yard/code_objects/base.rb +2 -0
  41. data/lib/puppet-strings/yard/code_objects/class.rb +4 -2
  42. data/lib/puppet-strings/yard/code_objects/data_type.rb +30 -8
  43. data/lib/puppet-strings/yard/code_objects/data_type_alias.rb +2 -0
  44. data/lib/puppet-strings/yard/code_objects/defined_type.rb +4 -2
  45. data/lib/puppet-strings/yard/code_objects/function.rb +8 -5
  46. data/lib/puppet-strings/yard/code_objects/group.rb +3 -0
  47. data/lib/puppet-strings/yard/code_objects/plan.rb +4 -2
  48. data/lib/puppet-strings/yard/code_objects/provider.rb +6 -0
  49. data/lib/puppet-strings/yard/code_objects/task.rb +3 -1
  50. data/lib/puppet-strings/yard/code_objects/type.rb +49 -5
  51. data/lib/puppet-strings/yard/handlers.rb +2 -0
  52. data/lib/puppet-strings/yard/handlers/helpers.rb +2 -0
  53. data/lib/puppet-strings/yard/handlers/json/base.rb +2 -0
  54. data/lib/puppet-strings/yard/handlers/json/task_handler.rb +2 -0
  55. data/lib/puppet-strings/yard/handlers/puppet/base.rb +3 -0
  56. data/lib/puppet-strings/yard/handlers/puppet/class_handler.rb +2 -0
  57. data/lib/puppet-strings/yard/handlers/puppet/data_type_alias_handler.rb +2 -0
  58. data/lib/puppet-strings/yard/handlers/puppet/defined_type_handler.rb +2 -0
  59. data/lib/puppet-strings/yard/handlers/puppet/function_handler.rb +3 -1
  60. data/lib/puppet-strings/yard/handlers/puppet/plan_handler.rb +2 -0
  61. data/lib/puppet-strings/yard/handlers/ruby/base.rb +5 -0
  62. data/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +225 -52
  63. data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +9 -7
  64. data/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb +13 -0
  65. data/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +4 -1
  66. data/lib/puppet-strings/yard/handlers/ruby/type_base.rb +20 -6
  67. data/lib/puppet-strings/yard/handlers/ruby/type_extras_handler.rb +6 -3
  68. data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +18 -1
  69. data/lib/puppet-strings/yard/parsers.rb +2 -0
  70. data/lib/puppet-strings/yard/parsers/json/parser.rb +2 -0
  71. data/lib/puppet-strings/yard/parsers/json/task_statement.rb +2 -0
  72. data/lib/puppet-strings/yard/parsers/puppet/parser.rb +18 -14
  73. data/lib/puppet-strings/yard/parsers/puppet/statement.rb +4 -0
  74. data/lib/puppet-strings/yard/tags.rb +4 -0
  75. data/lib/puppet-strings/yard/tags/enum_tag.rb +14 -0
  76. data/lib/puppet-strings/yard/tags/factory.rb +18 -0
  77. data/lib/puppet-strings/yard/tags/overload_tag.rb +4 -1
  78. data/lib/puppet-strings/yard/tags/parameter_directive.rb +5 -4
  79. data/lib/puppet-strings/yard/tags/property_directive.rb +5 -4
  80. data/lib/puppet-strings/yard/tags/summary_tag.rb +2 -0
  81. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/method_details_list.erb +6 -0
  82. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb +9 -1
  83. data/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb +1 -1
  84. data/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb +3 -1
  85. data/lib/puppet-strings/yard/templates/default/tags/html/enum.erb +17 -0
  86. data/lib/puppet-strings/yard/templates/default/tags/setup.rb +6 -0
  87. data/lib/puppet-strings/yard/util.rb +7 -4
  88. data/lib/puppet/application/strings.rb +2 -0
  89. data/lib/puppet/face/strings.rb +4 -1
  90. data/lib/puppet/feature/rgen.rb +2 -0
  91. data/lib/puppet/feature/yard.rb +2 -0
  92. metadata +14 -51
  93. data/Gemfile +0 -47
  94. data/HISTORY.md +0 -218
  95. data/JSON.md +0 -832
  96. data/Rakefile +0 -168
  97. data/codecov.yml +0 -3
  98. data/misc/ANNOUNCEMENT_TEMPLATE.md +0 -40
  99. data/spec/acceptance/emit_json_options_spec.rb +0 -69
  100. data/spec/acceptance/generate_markdown_spec.rb +0 -47
  101. data/spec/acceptance/running_strings_generate_spec.rb +0 -78
  102. data/spec/fixtures/acceptance/modules/test/functions/add.pp +0 -9
  103. data/spec/fixtures/acceptance/modules/test/lib/puppet/functions/4x_function.rb +0 -5
  104. data/spec/fixtures/acceptance/modules/test/lib/puppet/parser/functions/function3x.rb +0 -2
  105. data/spec/fixtures/acceptance/modules/test/lib/puppet/provider/server/linux.rb +0 -9
  106. data/spec/fixtures/acceptance/modules/test/lib/puppet/type/database.rb +0 -15
  107. data/spec/fixtures/acceptance/modules/test/manifests/init.pp +0 -27
  108. data/spec/fixtures/acceptance/modules/test/manifests/triple_nested_classes.pp +0 -27
  109. data/spec/fixtures/acceptance/modules/test/metadata.json +0 -10
  110. data/spec/fixtures/acceptance/modules/test/types/elephant.pp +0 -2
  111. data/spec/fixtures/unit/markdown/output.md +0 -508
  112. data/spec/fixtures/unit/markdown/output_with_data_types.md +0 -553
  113. data/spec/fixtures/unit/markdown/output_with_plan.md +0 -542
  114. data/spec/spec_helper.rb +0 -49
  115. data/spec/spec_helper_acceptance.rb +0 -58
  116. data/spec/spec_helper_acceptance_local.rb +0 -10
  117. data/spec/unit/puppet-strings/describe_spec.rb +0 -141
  118. data/spec/unit/puppet-strings/json_spec.rb +0 -302
  119. data/spec/unit/puppet-strings/markdown/base_spec.rb +0 -146
  120. data/spec/unit/puppet-strings/markdown_spec.rb +0 -357
  121. data/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +0 -92
  122. data/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +0 -116
  123. data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +0 -217
  124. data/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb +0 -65
  125. data/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +0 -231
  126. data/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +0 -315
  127. data/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +0 -232
  128. data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +0 -746
  129. data/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +0 -158
  130. data/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +0 -235
  131. data/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +0 -311
  132. data/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb +0 -72
  133. data/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +0 -56
  134. data/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +0 -251
  135. 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