puppetlabs / puppet-strings

The next generation Puppet documentation extraction and presentation tool.
http://puppetlabs.github.io/puppet-strings/
Apache License 2.0
90 stars 84 forks source link

(#307) Always enable plan parsing #312

Closed danielparks closed 2 years ago

danielparks commented 2 years ago

This is an alternate to #311, which fixes this same problem in a different way. I like this solution better.

Catch parse failures in PuppetStrings::Json tests

Previously, the tests for PuppetStrings::Json (in json_spec.rb) parsed a variety of code samples and then queried YARD to test the results. Ifa sample failed to parse, an error might be outputted (see issue #307), but no failure was registered by the testing harness.

This adds simple checks to verify that the parses actually succeed.

Unfortunately, one of the samples currently fails to parse, so this commit introduces a testing error. The subbsequent commit will fix it.

(#307) Fix plan parsing in JSON spec tests

Previously, the parsing code activated task support in Puppet when it detected that it was parsing a file in a plans/ directory. This casued the JSON spec test for plans to fail because it parsed a string, which naturally had no file name to check.

This turns on task support (and thus enables parsing plans) whenever the parser starts (assuming that task support is available).

This helps avoid surprises to future users who need to parse plans from ruby code, such as in tests.

Add a plan test to parser_spec.rb

Previously, none of the examples in parser_spec.rb included a Puppet plan. This adds a plan and verifies that it parses correctly.

chelnak commented 2 years ago

I think I like this version too. I can't immediately think of anything negative that would come out of it..

danielparks commented 2 years ago

I’m going to go ahead and close #311 (thought I’ll keep I’ll keep the branch around until this is merged).