Unable to include file in the spec file

60 Views Asked by At

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
1

There are 1 best solutions below

0
javiyu On

You need to change the LOAD_PATH or use require_relative

Here you have more info.