为什么此测试返回失败?我使用的是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从等级库文件:
describe service( 'cfengine3' ) do
it { should be_enabled }
end在主机上手动测试:
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发布于 2016-11-04 06:10:09
我遇到的一个问题是,我不得不在spec_helper.rb中取消对"PATH“变量的注释。我通过阅读github了解到了另一个问题。如果你像我一样受苦的话看看你的帮手。默认情况下,它不包含/sbin和/usr/local/sbin。
发布于 2015-11-09 20:38:03
尝试使用运行级别指定,如下所示:
describe service('cfengine3') do
it { should be_enabled.with_level(2) }
it { should be_enabled.with_level(3) }
it { should be_enabled.with_level(4) }
it { should be_enabled.with_level(5) }
it { should be_running }
end我在RHEL6机器上也遇到了同样的问题。当您指定be_enabled.with_level(x)时,它似乎填充了一些值以使be_running也通过。
https://stackoverflow.com/questions/30783617
复制相似问题