0

I'm currently trying to document my serverspec tests using yardoc. For this i've installed the yard-serverspec-plugin rubygem which does its job not that bad.

But i have one problem. The rubygem handles the "describe" and the "context" the same way and doesn't structure it hierarchical. Because of this it is hard to find the correct documentation for a failed serverspec test.

These are my serverspec tests:

describe 'OS name and version' do
  # @reason command - compare local os name with the os name defined in hpsm
  # @solution command - adjust the HPSM os name to match the servers os name
  context command('awk \'{ printf("%s %s %s %s", $1,$2,$3,$4 ) }\' /etc/redhat-release') do
    its(:stdout) { should eq 'Red Hat Enterprise Linux' }
  end

  # @reason command - compare local os version with the os version defined in hpsm
  # @solution command - adjust the HPSM os version to match the servers os version
  context command('awk -F . \'{printf gensub(/[^0-9]/, "", "g", $1)}\' /etc/redhat-release') do
    its(:stdout) { should eq '7' }
  end
end

And this is how it gets documented:

enter image description here

And here you find the code of the handler: https://github.com/rrreeeyyy/yard-serverspec-plugin/blob/master/lib/yard/serverspec/plugin/handler.rb

My question is if anybody knows how to adjust the handler code to get only 2 objects in the html documentation with a hierarchical structure? Because the "OS name and version" object is really useless. Something like this would be nice:

"OS name and version command('awk \'{ printf("%s %s ....')"
"OS name and version command('awk -F . \'{printf ....')"

Thanks in advance and regards

linux guy
  • 27
  • 1
  • 6
  • You should be using `host_inventory` for those tests instead of raw commands. – Matthew Schuchard Feb 10 '17 at 12:21
  • @Matt Schuchard thanks for your hint but this is only an example. I have about 600 tests and it would be nice to get those hierarchical documented. – linux guy Feb 10 '17 at 12:25
  • I know, I was just pointing out an issue with your tests. Also I would be fine personally with the structure yard is outputting here, but I get that it bothers you for some reason. – Matthew Schuchard Feb 10 '17 at 12:27

0 Answers0