Why does this test return a failure? I'm using serverspec 2.
1) Service "cfengine3" should be enabled
Failure/Error: it { should be_enabled }
expected Service "cfengine3" to be enabled
sudo -p 'Password: ' /bin/sh -c chkconfig\ --list\ cfengine3\ \|\ grep\ 3:on
From spec file:
describe service( 'cfengine3' ) do
it { should be_enabled }
end
Manual test on host:
newatson@atlspf01:~$ sudo /bin/sh -c chkconfig\ --list\ cfengine3\ \|\ grep\ 3:on
cfengine3 0:off 1:off 2:on 3:on 4:on 5:on 6:off
newatson@atlspf01:~$ echo $?
0
Try specifying with the run level as follows:
I had the same issue on a RHEL6 machine. When you specify be_enabled.with_level(x) it appears to populate some value to make be_running pass as well.