@@ -135,6 +135,43 @@ class bar {
135
135
end
136
136
end
137
137
138
+ describe 'parsing puppet plans' , if : TEST_PUPPET_PLANS do
139
+ # The parsing code actually checks this and sets a global (Puppet[:tasks]).
140
+ # Plan parsing will fail if it hasn't yet encountered a file under plans/.
141
+ let ( :file ) { 'plans/test.pp' }
142
+ let ( :source ) { <<SOURCE
143
+ # A simple plan.
144
+ # @param param1 First param.
145
+ # @param param2 Second param.
146
+ # @param param3 Third param.
147
+ plan plann(String $param1, $param2, Integer $param3 = 1) {
148
+ }
149
+ SOURCE
150
+ }
151
+
152
+ it 'should parse the puppet plan statement' do
153
+ subject . parse
154
+ expect ( subject . enumerator . size ) . to eq ( 1 )
155
+ statement = subject . enumerator . first
156
+ expect ( statement ) . to be_a ( PuppetStrings ::Yard ::Parsers ::Puppet ::PlanStatement )
157
+ expect ( statement . name ) . to eq ( 'plann' )
158
+ expect ( statement . source ) . to eq ( source . sub ( /\A .*?\n ([^#])/m , '\1' ) . chomp )
159
+ expect ( statement . file ) . to eq ( file )
160
+ expect ( statement . line ) . to eq ( 5 )
161
+ expect ( statement . docstring ) . to eq ( 'A simple plan.' )
162
+ expect ( statement . parameters . size ) . to eq ( 3 )
163
+ expect ( statement . parameters [ 0 ] . name ) . to eq ( 'param1' )
164
+ expect ( statement . parameters [ 0 ] . type ) . to eq ( 'String' )
165
+ expect ( statement . parameters [ 0 ] . value ) . to be_nil
166
+ expect ( statement . parameters [ 1 ] . name ) . to eq ( 'param2' )
167
+ expect ( statement . parameters [ 1 ] . type ) . to be_nil
168
+ expect ( statement . parameters [ 1 ] . value ) . to be_nil
169
+ expect ( statement . parameters [ 2 ] . name ) . to eq ( 'param3' )
170
+ expect ( statement . parameters [ 2 ] . type ) . to eq ( 'Integer' )
171
+ expect ( statement . parameters [ 2 ] . value ) . to eq ( '1' )
172
+ end
173
+ end
174
+
138
175
describe 'parsing puppet functions' , if : TEST_PUPPET_FUNCTIONS do
139
176
let ( :source ) { <<SOURCE
140
177
notice hello
0 commit comments