super - 如何在 Chef 资源中测试“超级”?
问题描述
是否有类似于step_into
鼓励 Chefspec 遵循资源super
调用到其父类的方法?或者您能否建议一种方法来测试super
调用是否按预期遵循(或未遵循),以在父类中执行适当的操作?
例如,
class Child < Chef::Provider::Parent
provides :child_resource
def action_create
# do childlike things
super
end
end
class Parent < Chef::Provider::LWRPBase
provides :parent_resource
def action_create
# do parental things
file "/home/mine/#{new_resource.name}.json" do
action :create
content 'I am malformed json content'
end
end
end
有食谱
child_resource 'ima_potato' do
property 'vegechair'
end
并用
require 'chefspec'
describe('procreate-concreate') do
let(:child_runner) do
memoized_runner('procreate-concreate', {step_into: ['child_resource', 'parent_resource']}, 'child_runner') do |node|
# node things
end
end
it 'creates the parent resource' do
expect(child_runner).to create_parent_resource('ima_potato')
end
it 'creates the parent file' do
expect(child_runner).to create_file('/home/mine/ima_potato.json')
end
end
上述模式有效。我的测试忽略了条件的缺失布尔值。
解决方案
上述模式有效。我的测试忽略了条件的缺失布尔值。
推荐阅读
- javascript - 将 for 循环限制为幻想足球选秀的特定次数
- javascript - 在nodejs中合并异步数据并在没有竞争条件的情况下使用它
- python - 大家好,我如何在屏幕管理器中播放 kivy 视频,我试过但不能
- laravel - 文件上传 laravel - 请求的文件方法返回 null
- javascript - FullCalendar,在选择期间显示事件创建
- python - Linux虚拟机上Dash App部署及用户并发问题
- .net - WinForms 中的 Per-Monitor V2 DPI 感知不使用非环境字体重新缩放控件
- flutter - 小部件重建后显示小吃栏消息
- jquery - 为什么 $.ajaxSetup 不能与 $.post 一起使用
- pytest - 需要pytest hooks执行的顺序和动作