[英]In chefspec is it possible to write a method once and call that method in other spec files?
I am trying to write a method test_run(first_param,second_param)
in one spec file program_spec.rb
and I want to call this method test_run
in another spec file second_program_spec.rb
.我试图写一个方法
test_run(first_param,second_param)
在一个规范文件program_spec.rb
,我想调用这个方法test_run
在另一个spec文件second_program_spec.rb
。 How do I call the method which is declared in program_spec.rb
to be used in another spec file ?如何调用在
program_spec.rb
声明的方法以在另一个规范文件中使用?
you can create a helper_spec.rb and include it in the required specfiles.您可以创建一个 helper_spec.rb 并将其包含在所需的规范文件中。 I attach a link to the documentation examples.
我附上了文档示例的链接。
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 https://relishapp.com/rspec/rspec-core/v/3-9/docs/helper-methods/define-helper-methods-in-a-module#include-a-module-in-only-some-示例组
Best Regards.此致。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.