I have an environment built by using puppet. I was planning to write some rspec-ruby script that can be executed once the puppet build is complete to test whether all the directories, packages, users and roles are created.
What I would like is to test using rspec whether the particular version of Java and Tomcat (ex for tomcat: 9.0.17) is installed during the puppet build.
What I was doing so far was to test whether the directory is present for tomcat or java by including their version number in the directory name as well like the following:
describe file('/opt/tomcat/9.0.17') do
it { should be_directory }
end
Is there any other way apart from this? Or like the way we test for the package installation?
There are related questions on how to check the versions of these applications here at Stack Overflow:
But the problem you may have is that for Serverspec to run the Java command (needed in both), you may need to already know the path to the Java command, which depends on the version of Java and/or Tomcat.
For this reason, use of the directory, as you are already doing, is most probably the simplest solution.
(And it is also what I do, e.g. in this project here.)