'Unable to include file in the spec file

I am trying to write an RSpec test for a ruby project(Sketchup plugin) but I am facing an issue with the require.

Below is how my folder is structured

enter image description here

In my smoke_tests_spec.rb

require "main_folder/subfolder1/file_to_test.rb"

When I run the rspec using rspec-core/rspec from the root directory I get the following error

Failure/Error: require "main_folder/subfolder1/file_to_test.rb"

LoadError:
  cannot load such file -- main_folder/subfolder1/file_to_test.rb


Solution 1:[1]

You need to change the LOAD_PATH or use require_relative

Here you have more info.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 javiyu