AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 812853
Accepted
jldugger
jldugger
Asked: 2016-11-03 14:58:18 +0800 CST2016-11-03 14:58:18 +0800 CST 2016-11-03 14:58:18 +0800 CST

当操作为:无时执行的 ChefSpec 匹配器?

  • 772

为半复杂的设置编写一些测试。systemd删除软件包安装的一些初始化脚本后,我需要重新加载。

pager.rb:

execute 'systemctl daemon-reload' do
  action :nothing
end

...

file '/etc/init.d/pdagent' do
  notifies :run, 'execute[systemctl daemon-reload]', :immediately
  action :delete
end

这一切都有效,但我在为执行块编写 ChefSpec 测试套件时遇到了麻烦。Seth Vargo 的示例显示了 run_execute 的匹配器,但使用它action :nothing失败:

spec.rb:

it do
  expect(chef_run).to run_execute('systemctl daemon-reload')
end

结果是:

失败/错误:expect(chef_run).to run_execute('systemctl daemon-reload') 预期“执行 [systemctl daemon-reload]”操作 [] 包括:run # ./spec/pagerduty_spec.rb:18:in `block (2 级)在 '

chef
  • 2 2 个回答
  • 1017 Views

2 个回答

  • Voted
  1. Best Answer
    jldugger
    2016-12-29T22:16:59+08:002016-12-29T22:16:59+08:00

    原来有一个相当通用的do_nothing匹配器:

    期望(执行).to do_nothing

    • 0
  2. Alex H.
    2019-01-23T14:56:51+08:002019-01-23T14:56:51+08:00

    在现代 Chef 中,匹配器采用action_resource. 因此,当您编写 时expect(chef_run).to run_execute('my command'),您指定的是资源execute 'my command'与操作会聚:run。相反,你想匹配 action :nothing,所以你会写:

    expect(chef_run).to nothing_execute('my command')

    • 0

相关问题

  • Chef 服务器操作码报告错误的 Postgresql 凭据

  • centos 5.3上的厨师错误

  • 哪种方式是使用 Chef 安装软件包的最“优雅”方式?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve