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.
One problem I had was that I had to uncomment a "PATH" variable in my spec_helper.rb. I figured that out reading github for another issue. If you're suffering like I was check your spec helper. it doesn't include /sbin and /usr/local/sbin by default.