问题描述
我有一个自定义的 Puppet 函数,它接受一个文件,检查文件的内容并根据内容返回一个哈希值:
Puppet::Functions.create_function(:check_file) do
dispatch :check_file do
param 'String',:file_path
end
def check_file(file_path)
data = Hash.new
...
...
return data
end
end
describe 'check_file' do
tempfile = Tempfile.new('dummy_file_name.txt')
tempfile.write('dummy_file_content')
expected_hash = {'abc' => 'def','ghi' => 'jkl'}
result = check_file('dummy_file_name.txt')
expect(result).to eq(expected_hash)
end
但我收到以下错误:
An error occurred while loading ./spec/functions/check_file_spec.rb.
Failure/Error: result = check_file('dummy_file_name.txt')
NoMethodError:
undefined method `check_file' for RSpec::ExampleGroups::CheckFile:Class
# ./spec/functions/check_file.rb:81:in `block in <top (required)>'
# ./spec/functions/check_file_spec.rb:74:in `<top (required)>'
No examples found.
Finished in 0.00002 seconds (files took 1.94 seconds to load)
0 examples,0 failures,1 error occurred outside of examples
知道为什么 rspec 无法找到我的方法吗?
目录结构为:
module/lib/puppet/functions/check_file.rb
module/spec/functions/check_file_spec.rb
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)