I'm writing some tests for puppet and in my init_spec.rb file I want to use a variable that is declared in the default_facts.yml file. How could I import the value of that variable without having to declare it in the init_spec.rb file.
Thanks in advance!
In general, you would be able to access that data inside the
RSpec.configurationobject.Supposing you had a default facts file like this:
You could address that data in your tests like this:
(I am assuming of course that your default facts file was set up correctly, e.g. by PDK.)
If instead you just want a general way to access the data in any arbitrary YAML file, you can also do this:
Then in your tests you can write: