File tree Expand file tree Collapse file tree
lib/puppet-strings/yard/handlers/puppet
spec/unit/puppet-strings/yard/handlers/puppet Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class PuppetStrings::Yard::Handlers::Puppet::FunctionHandler < PuppetStrings::Ya
3737 def add_return_tag ( object , type = nil )
3838 tag = object . tag ( :return )
3939 if tag
40- if ( type && tag . types ) && ( type != tag . types )
40+ if ( type && tag . types . first ) && ( type != tag . types . first )
4141 log . warn "Documented return type does not match return type in function definition near #{ statement . file } :#{ statement . line } ."
4242 end
4343
Original file line number Diff line number Diff line change 2020 let ( :source ) { 'function foo{' }
2121
2222 it 'should log an error' do
23- expect { subject } . to output ( /\[ error\] : Failed to parse \( stdin\) : Syntax error at end of file / ) . to_stdout_from_any_process
23+ expect { subject } . to output ( /\[ error\] : Failed to parse \( stdin\) : Syntax error at end of/ ) . to_stdout_from_any_process
2424 expect ( subject . empty? ) . to eq ( true )
2525 end
2626 end
216216 end
217217 end
218218
219+ describe 'parsing a function with a non-conflicting return tag and type in function definition' , if : TEST_FUNCTION_RETURN_TYPE do
220+ let ( :source ) { <<-SOURCE
221+ # A simple foo function
222+ # @return [String] Hi there
223+ function foo() >> String {
224+ notice 'hi there'
225+ }
226+ SOURCE
227+ }
228+
229+ it 'should not output a warning if return types match' do
230+ expect { subject } . not_to output ( /Documented return type does not match return type in function definition/ ) . to_stdout_from_any_process
231+ end
232+ end
233+
219234 describe 'parsing a function with a conflicting return tag and type in function definition' , if : TEST_FUNCTION_RETURN_TYPE do
220235 let ( :source ) { <<-SOURCE
221236# A simple foo function.
You can’t perform that action at this time.
0 commit comments