chef-infrachefspec

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. How do I call the method which is declared in program_spec.rb to be used in another spec file ?


Solution

  • you can create a helper_spec.rb and include it in the required specfiles. 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

    Best Regards.