Load Error in file when running with minitest

395 views Asked by At

I'm somewhat new to Ruby so I apologize if this is a stupid question. I've searched pretty hard, and can't really find anything that works.

My issue, I am trying to unit test a framework i'm writing that is located in the lib directory of a rails project. I'm using the minitest unit testing framework (executing via a rake task) in my unit test i have a require that is referencing "File A". That loads fine. However "File A" has a require to "File B"

like this: require './FileB'

when that runs from minitest I get the cannot load such file error

this is how my rake task looks require 'rake/testtask'

Rake::TestTask.new do |t|
  t.libs = ["lib", "test"]
  t.name = "test:file_a_tests"
  t.warning = true
  t.test_files = FileList['test/file_a_test.rb']
end
1

There are 1 answers

0
Aleksei Matiushkin On BEST ANSWER

Whether you want to use a relative path during require, use:

require_relative 'FileB'

Hope it helps.