I have the following structure:
MyProject --> Main folder of my project.
MyProject/my_class.rb
MyProject/inputs/input1.txt
MyProject/inputs/input2.txt
MyProject/rspec/spec_helper.rb
MyProject/rspec/my_class_spec.rb
What is an elegant way or most common way that I can make it so that I can use the input1.txt and input2.txt in my_class_spec.rb?
You can access content of input1.txt from my_class_spec.rb like this:
file1_content = File.read(File.expand_path '../../inputs/input1.txt', __FILE__)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With