My requirement is that I need to run a utility that is installed in other user and I have to check the output returned from that session and verify it. Example :
- I installed java as srijava user
- Now in Serverspec I wrote the command to test the Java version (Assume that the
java -versionruns only in that user and not as root). - if I use
su srijava, then I do not get the output returned back to the root session and the test fails. - If I run without
su srijavathen my utility will throw an error that the user is not SriJava
Code with su :
describe command('su srijava ; cd /app/java; ./java --version') do
its(:stdout) { should contain('1.7') }
end
Code without su:
describe command('cd /app/java; ./java --version') do
its(:stdout) { should contain('1.7') }
end