puppet-strings 2.2.0 → 2.3.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.
Files changed (88) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +12 -0
  3. data/Gemfile +14 -5
  4. data/JSON.md +41 -11
  5. data/README.md +66 -7
  6. data/Rakefile +99 -29
  7. data/lib/puppet-strings/json.rb +2 -0
  8. data/lib/puppet-strings/markdown.rb +2 -0
  9. data/lib/puppet-strings/markdown/data_type.rb +18 -0
  10. data/lib/puppet-strings/markdown/data_types.rb +41 -0
  11. data/lib/puppet-strings/markdown/function.rb +2 -2
  12. data/lib/puppet-strings/markdown/table_of_contents.rb +1 -0
  13. data/lib/puppet-strings/markdown/templates/data_type.erb +78 -0
  14. data/lib/puppet-strings/tasks/generate.rb +3 -2
  15. data/lib/puppet-strings/version.rb +1 -1
  16. data/lib/puppet-strings/yard.rb +10 -0
  17. data/lib/puppet-strings/yard/code_objects.rb +2 -0
  18. data/lib/puppet-strings/yard/code_objects/class.rb +1 -1
  19. data/lib/puppet-strings/yard/code_objects/data_type.rb +80 -0
  20. data/lib/puppet-strings/yard/code_objects/data_type_alias.rb +58 -0
  21. data/lib/puppet-strings/yard/code_objects/defined_type.rb +1 -1
  22. data/lib/puppet-strings/yard/code_objects/function.rb +3 -3
  23. data/lib/puppet-strings/yard/code_objects/plan.rb +1 -1
  24. data/lib/puppet-strings/yard/handlers.rb +2 -0
  25. data/lib/puppet-strings/yard/handlers/puppet/data_type_alias_handler.rb +24 -0
  26. data/lib/puppet-strings/yard/handlers/ruby/base.rb +2 -2
  27. data/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +236 -0
  28. data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +1 -3
  29. data/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +2 -2
  30. data/lib/puppet-strings/yard/handlers/ruby/type_base.rb +5 -6
  31. data/lib/puppet-strings/yard/parsers/json/parser.rb +1 -1
  32. data/lib/puppet-strings/yard/parsers/puppet/parser.rb +14 -7
  33. data/lib/puppet-strings/yard/parsers/puppet/statement.rb +25 -0
  34. data/lib/puppet-strings/yard/tags/overload_tag.rb +1 -1
  35. data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_data_type.erb +10 -0
  36. data/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb +9 -0
  37. data/lib/puppet-strings/yard/templates/default/layout/html/objects.erb +2 -0
  38. data/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +18 -1
  39. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/box_info.erb +10 -0
  40. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/header.erb +1 -0
  41. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/note.erb +6 -0
  42. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/overview.erb +6 -0
  43. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb +5 -0
  44. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/source.erb +12 -0
  45. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/summary.erb +4 -0
  46. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/todo.erb +6 -0
  47. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/alias_of.erb +10 -0
  48. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/box_info.erb +10 -0
  49. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/header.erb +1 -0
  50. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/note.erb +6 -0
  51. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/overview.erb +6 -0
  52. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb +17 -0
  53. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/source.erb +12 -0
  54. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/summary.erb +4 -0
  55. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/todo.erb +6 -0
  56. data/lib/puppet-strings/yard/templates/default/tags/setup.rb +1 -0
  57. data/lib/puppet/face/strings.rb +3 -3
  58. data/spec/acceptance/emit_json_options_spec.rb +69 -0
  59. data/spec/acceptance/generate_markdown_spec.rb +13 -15
  60. data/spec/acceptance/running_strings_generate_spec.rb +78 -0
  61. data/spec/fixtures/acceptance/modules/test/metadata.json +5 -1
  62. data/spec/fixtures/acceptance/modules/test/types/elephant.pp +2 -0
  63. data/spec/fixtures/unit/markdown/output_with_data_types.md +553 -0
  64. data/spec/spec_helper.rb +3 -0
  65. data/spec/spec_helper_acceptance.rb +52 -22
  66. data/spec/spec_helper_acceptance_local.rb +10 -0
  67. data/spec/unit/puppet-strings/describe_spec.rb +7 -7
  68. data/spec/unit/puppet-strings/json_spec.rb +23 -4
  69. data/spec/unit/puppet-strings/markdown/base_spec.rb +3 -3
  70. data/spec/unit/puppet-strings/markdown_spec.rb +84 -23
  71. data/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +1 -1
  72. data/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +4 -4
  73. data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +8 -8
  74. data/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb +65 -0
  75. data/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +8 -8
  76. data/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +13 -13
  77. data/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +232 -0
  78. data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +36 -19
  79. data/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +26 -7
  80. data/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +7 -7
  81. data/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +26 -10
  82. data/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +2 -2
  83. data/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +42 -0
  84. data/spec/unit/puppet-strings/yard/util_spec.rb +1 -1
  85. metadata +35 -7
  86. data/spec/acceptance/emit_json_options.rb +0 -71
  87. data/spec/acceptance/lib/util.rb +0 -163
  88. data/spec/acceptance/running_strings_generate.rb +0 -54
@@ -0,0 +1,65 @@
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
@@ -44,7 +44,7 @@ define foo(Integer $param1, $param2, String $param3 = hi) {
44
44
  ensure => present
45
45
  }
46
46
  }
47
- SOURCE
47
+ SOURCE
48
48
  }
49
49
  it 'does not output a warning for title/name' do
50
50
  expect{ subject }.not_to output(/\[warn\].*(name|title).*/).to_stdout_from_any_process
@@ -92,7 +92,7 @@ define foo(Integer $param1, $param2, String $param3 = hi) {
92
92
  ensure => present
93
93
  }
94
94
  }
95
- SOURCE
95
+ SOURCE
96
96
  }
97
97
 
98
98
  it 'should output a warning' do
@@ -110,7 +110,7 @@ define foo(Integer $param1, $param2, String $param3 = hi) {
110
110
  ensure => present
111
111
  }
112
112
  }
113
- SOURCE
113
+ SOURCE
114
114
  }
115
115
 
116
116
  it 'should output a warning' do
@@ -129,7 +129,7 @@ define foo(Integer $param1, $param2, String $param3 = hi) {
129
129
  ensure => present
130
130
  }
131
131
  }
132
- SOURCE
132
+ SOURCE
133
133
  }
134
134
 
135
135
  it 'should respect the type that was documented' do
@@ -152,7 +152,7 @@ define foo(Integer $param1, $param2, String $param3 = hi) {
152
152
  ensure => present
153
153
  }
154
154
  }
155
- SOURCE
155
+ SOURCE
156
156
  }
157
157
 
158
158
  it 'should output a warning' do
@@ -171,7 +171,7 @@ define foo(Integer $param1, $param2, String $param3 = hi) {
171
171
  ensure => present
172
172
  }
173
173
  }
174
- SOURCE
174
+ SOURCE
175
175
  }
176
176
 
177
177
  it 'should respect the type that was documented' do
@@ -197,7 +197,7 @@ define foo(Integer $param1, $param2, String $param3 = hi) {
197
197
  ensure => present
198
198
  }
199
199
  }
200
- SOURCE
200
+ SOURCE
201
201
  }
202
202
 
203
203
  it 'should parse the summary' do
@@ -220,7 +220,7 @@ define foo(Integer $param1, $param2, String $param3 = hi) {
220
220
  ensure => present
221
221
  }
222
222
  }
223
- SOURCE
223
+ SOURCE
224
224
  }
225
225
 
226
226
  it 'should log a warning' do
@@ -44,7 +44,7 @@ function foo(Integer $param1, $param2, String $param3 = hi) {
44
44
  notice 'hello world'
45
45
  undef
46
46
  }
47
- SOURCE
47
+ SOURCE
48
48
  }
49
49
 
50
50
  it 'should register a function object' do
@@ -90,7 +90,7 @@ SOURCE
90
90
  function foo(Integer $param1, $param2, String $param3 = hi) {
91
91
  notice 'hello world'
92
92
  }
93
- SOURCE
93
+ SOURCE
94
94
  }
95
95
 
96
96
  it 'should output a warning' do
@@ -107,7 +107,7 @@ SOURCE
107
107
  function foo(Integer $param1, $param2, String $param3 = hi) {
108
108
  notice 'hello world'
109
109
  }
110
- SOURCE
110
+ SOURCE
111
111
  }
112
112
 
113
113
  it 'should output a warning' do
@@ -125,7 +125,7 @@ SOURCE
125
125
  function foo(Integer $param1, $param2, String $param3 = hi) {
126
126
  notice 'hello world'
127
127
  }
128
- SOURCE
128
+ SOURCE
129
129
  }
130
130
 
131
131
  it 'should respect the type that was documented' do
@@ -147,7 +147,7 @@ SOURCE
147
147
  function foo(Integer $param1, $param2, String $param3 = hi) {
148
148
  notice 'hello world'
149
149
  }
150
- SOURCE
150
+ SOURCE
151
151
  }
152
152
 
153
153
  it 'should output a warning' do
@@ -165,7 +165,7 @@ SOURCE
165
165
  function foo(Integer $param1, $param2, String $param3 = hi) {
166
166
  notice 'hello world'
167
167
  }
168
- SOURCE
168
+ SOURCE
169
169
  }
170
170
 
171
171
  it 'should respect the type that was documented' do
@@ -186,7 +186,7 @@ SOURCE
186
186
  function foo(Integer $param1, $param2, String $param3 = hi) {
187
187
  notice 'hello world'
188
188
  }
189
- SOURCE
189
+ SOURCE
190
190
  }
191
191
 
192
192
  it 'should output a warning' do
@@ -200,7 +200,7 @@ SOURCE
200
200
  function foo() >> String {
201
201
  notice 'hello world'
202
202
  }
203
- SOURCE
203
+ SOURCE
204
204
  }
205
205
 
206
206
  it 'should register a function object with the correct return type' do
@@ -223,7 +223,7 @@ SOURCE
223
223
  function foo() >> String {
224
224
  notice 'hi there'
225
225
  }
226
- SOURCE
226
+ SOURCE
227
227
  }
228
228
 
229
229
  it 'should not output a warning if return types match' do
@@ -238,7 +238,7 @@ SOURCE
238
238
  function foo() >> Struct[{'a' => Integer[1, 10]}] {
239
239
  notice 'hello world'
240
240
  }
241
- SOURCE
241
+ SOURCE
242
242
  }
243
243
 
244
244
  it 'should prefer the return type from the function definition' do
@@ -260,7 +260,7 @@ SOURCE
260
260
  function foo() {
261
261
  notice 'hello world'
262
262
  }
263
- SOURCE
263
+ SOURCE
264
264
  }
265
265
 
266
266
  it 'should add a return tag with a default type value of Any' do
@@ -285,7 +285,7 @@ SOURCE
285
285
  function foo() {
286
286
  notice 'hello world'
287
287
  }
288
- SOURCE
288
+ SOURCE
289
289
  }
290
290
 
291
291
  it 'should parse the summary' do
@@ -304,7 +304,7 @@ function foo() {
304
304
  notice 'hello world'
305
305
  }
306
306
 
307
- SOURCE
307
+ SOURCE
308
308
  }
309
309
 
310
310
  it 'should log a warning' do
@@ -0,0 +1,232 @@
1
+ require 'spec_helper'
2
+ require 'puppet-strings/yard'
3
+
4
+ describe PuppetStrings::Yard::Handlers::Ruby::DataTypeHandler, if: TEST_PUPPET_DATATYPES do
5
+ subject {
6
+ YARD::Parser::SourceParser.parse_string(source, :ruby)
7
+ YARD::Registry.all(:puppet_data_type)
8
+ }
9
+
10
+ before(:each) do
11
+ # Tests may suppress logging to make it easier to read results,
12
+ # so remember the logging object prior to running the test
13
+ @original_yard_logging_object = YARD::Logger.instance.io
14
+ end
15
+
16
+ after(:each) do
17
+ # Restore the original logging IO object
18
+ YARD::Logger.instance.io = @original_yard_logging_object
19
+ end
20
+
21
+ def suppress_yard_logging
22
+ YARD::Logger.instance.io = nil
23
+ end
24
+
25
+ describe 'parsing source without a data type definition' do
26
+ let(:source) { 'puts "hi"' }
27
+
28
+ it 'no data types should be in the registry' do
29
+ expect(subject.empty?).to eq(true)
30
+ end
31
+ end
32
+
33
+ describe 'parsing an empty data type definition' do
34
+ let(:source) { <<-SOURCE
35
+ Puppet::DataTypes.create_type('RubyDataType') do
36
+ end
37
+ SOURCE
38
+ }
39
+
40
+ it 'should register a data type object with no param tags' do
41
+ expect(subject.size).to eq(1)
42
+ object = subject.first
43
+ expect(object).to be_a(PuppetStrings::Yard::CodeObjects::DataType)
44
+ expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::DataTypes.instance)
45
+ expect(object.name).to eq(:RubyDataType)
46
+ expect(object.docstring).to eq('')
47
+ expect(object.docstring.tags.size).to eq(1)
48
+ tags = object.docstring.tags(:api)
49
+ expect(tags.size).to eq(1)
50
+ expect(tags[0].text).to eq('public')
51
+
52
+ expect(object.parameters.size).to eq(0)
53
+ end
54
+ end
55
+
56
+ describe 'parsing a data type definition with missing param tags' do
57
+ let(:source) { <<-SOURCE
58
+ # An example Puppet Data Type in Ruby.
59
+ Puppet::DataTypes.create_type('RubyDataType') do
60
+ interface <<-PUPPET
61
+ attributes => {
62
+ msg => String[1],
63
+ }
64
+ PUPPET
65
+ end
66
+ SOURCE
67
+ }
68
+
69
+ it 'should output a warning' do
70
+ expect{ subject }.to output(/\[warn\]: Missing @param tag for attribute 'msg' near \(stdin\):2/).to_stdout_from_any_process
71
+ end
72
+
73
+ it 'should register a data type object with all param tags' do
74
+ suppress_yard_logging
75
+
76
+ expect(subject.size).to eq(1)
77
+ object = subject.first
78
+ expect(object).to be_a(PuppetStrings::Yard::CodeObjects::DataType)
79
+ expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::DataTypes.instance)
80
+ expect(object.name).to eq(:RubyDataType)
81
+ expect(object.docstring).to eq('An example Puppet Data Type in Ruby.')
82
+ expect(object.docstring.tags.size).to eq(2)
83
+ tags = object.docstring.tags(:api)
84
+ expect(tags.size).to eq(1)
85
+ expect(tags[0].text).to eq('public')
86
+
87
+ # Check that the param tags are created
88
+ tags = object.docstring.tags(:param)
89
+ expect(tags.size).to eq(1)
90
+ expect(tags[0].name).to eq('msg')
91
+ expect(tags[0].text).to eq('')
92
+ expect(tags[0].types).to eq(['String[1]'])
93
+
94
+ # Check for default values for parameters
95
+ expect(object.parameters.size).to eq(1)
96
+ expect(object.parameters[0]).to eq(['msg', nil])
97
+ end
98
+ end
99
+
100
+ describe 'parsing a data type definition with extra param tags' do
101
+ let(:source) { <<-SOURCE
102
+ # An example Puppet Data Type in Ruby.
103
+ # @param msg A message parameter.
104
+ # @param arg1 Optional String parameter. Defaults to 'param'.
105
+ Puppet::DataTypes.create_type('RubyDataType') do
106
+ interface <<-PUPPET
107
+ attributes => {
108
+ msg => Numeric,
109
+ }
110
+ PUPPET
111
+ end
112
+ SOURCE
113
+ }
114
+
115
+ it 'should output a warning' do
116
+ expect{ subject }.to output(/\[warn\]: The @param tag for 'arg1' has no matching attribute near \(stdin\):4/).to_stdout_from_any_process
117
+ end
118
+
119
+ it 'should register a data type object with extra param tags removed' do
120
+ suppress_yard_logging
121
+
122
+ expect(subject.size).to eq(1)
123
+ object = subject.first
124
+ expect(object).to be_a(PuppetStrings::Yard::CodeObjects::DataType)
125
+ expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::DataTypes.instance)
126
+ expect(object.name).to eq(:RubyDataType)
127
+ expect(object.docstring).to eq('An example Puppet Data Type in Ruby.')
128
+ expect(object.docstring.tags.size).to eq(2)
129
+ tags = object.docstring.tags(:api)
130
+ expect(tags.size).to eq(1)
131
+ expect(tags[0].text).to eq('public')
132
+
133
+ # Check that the param tags are removed
134
+ tags = object.docstring.tags(:param)
135
+ expect(tags.size).to eq(1)
136
+ expect(tags[0].name).to eq('msg')
137
+ expect(tags[0].text).to eq('A message parameter.')
138
+ expect(tags[0].types).to eq(['Numeric'])
139
+
140
+ # Check that only the actual attributes appear
141
+ expect(object.parameters.size).to eq(1)
142
+ expect(object.parameters[0]).to eq(['msg', nil])
143
+ end
144
+ end
145
+
146
+ describe 'parsing a valid data type definition' do
147
+ let(:source) { <<-SOURCE
148
+ # An example Puppet Data Type in Ruby.
149
+ #
150
+ # @param msg A message parameter5.
151
+ # @param arg1 Optional String parameter5. Defaults to 'param'.
152
+ Puppet::DataTypes.create_type('RubyDataType') do
153
+ interface <<-PUPPET
154
+ attributes => {
155
+ msg => Variant[Numeric, String[1,2]],
156
+ arg1 => { type => Optional[String[1]], value => "param" }
157
+ }
158
+ PUPPET
159
+ end
160
+ SOURCE
161
+ }
162
+
163
+ it 'should register a data type object' do
164
+ expect(subject.size).to eq(1)
165
+ object = subject.first
166
+ expect(object).to be_a(PuppetStrings::Yard::CodeObjects::DataType)
167
+ expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::DataTypes.instance)
168
+ expect(object.name).to eq(:RubyDataType)
169
+ expect(object.docstring).to eq('An example Puppet Data Type in Ruby.')
170
+ expect(object.docstring.tags.size).to eq(3)
171
+ tags = object.docstring.tags(:api)
172
+ expect(tags.size).to eq(1)
173
+ expect(tags[0].text).to eq('public')
174
+
175
+ # Check that the param tags are removed
176
+ tags = object.docstring.tags(:param)
177
+ expect(tags.size).to eq(2)
178
+ expect(tags[0].name).to eq('msg')
179
+ expect(tags[0].text).to eq('A message parameter5.')
180
+ expect(tags[0].types).to eq(['Variant[Numeric, String[1,2]]'])
181
+ expect(tags[1].name).to eq('arg1')
182
+ expect(tags[1].text).to eq('Optional String parameter5. Defaults to \'param\'.')
183
+ expect(tags[1].types).to eq(['Optional[String[1]]'])
184
+
185
+ # Check for default values
186
+ expect(object.parameters.size).to eq(2)
187
+ expect(object.parameters[0]).to eq(['msg', nil])
188
+ expect(object.parameters[1]).to eq(['arg1', 'param'])
189
+ end
190
+ end
191
+
192
+ describe 'parsing a data type with a summary' do
193
+ context 'when the summary has fewer than 140 characters' do
194
+ let(:source) { <<-SOURCE
195
+ # An example Puppet Data Type in Ruby.
196
+ #
197
+ # @summary A short summary.
198
+ Puppet::DataTypes.create_type('RubyDataType') do
199
+ interface <<-PUPPET
200
+ attributes => { }
201
+ PUPPET
202
+ end
203
+ SOURCE
204
+ }
205
+
206
+ it 'should parse the summary' do
207
+ expect{ subject }.to output('').to_stdout_from_any_process
208
+ expect(subject.size).to eq(1)
209
+ summary = subject.first.tags(:summary)
210
+ expect(summary.first.text).to eq('A short summary.')
211
+ end
212
+ end
213
+
214
+ context 'when the summary has more than 140 characters' do
215
+ let(:source) { <<-SOURCE
216
+ # An example Puppet Data Type in Ruby.
217
+ #
218
+ # @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!!
219
+ Puppet::DataTypes.create_type('RubyDataType') do
220
+ interface <<-PUPPET
221
+ attributes => { }
222
+ PUPPET
223
+ end
224
+ SOURCE
225
+ }
226
+
227
+ it 'should log a warning' do
228
+ expect{ subject }.to output(/\[warn\]: The length of the summary for puppet_data_type 'RubyDataType' exceeds the recommended limit of 140 characters./).to_stdout_from_any_process
229
+ end
230
+ end
231
+ end
232
+ end