在 chefspec 中是否可以编写一次方法并在其他规范文件中调用该方法?

In chefspec is it possible to write a method once and call that method in other spec files?

我正在尝试在一个规范文件 program_spec.rb 中编写方法 test_run(first_param,second_param),我想在另一个规范文件 second_program_spec.rb 中调用此方法 test_run。如何调用在 program_spec.rb 中声明的方法以在另一个规范文件中使用?

您可以创建一个 helper_spec.rb 并将其包含在所需的规范文件中。 我在文档示例中附加了 link。

https://relishapp.com/rspec/rspec-core/v/3-9/docs/helper-methods/define-helper-methods-in-a-module#include-a-module-in-only-some- example-groups

此致。