I have the following code in lib/test/company.rb:
module Test
class Company
# irrelevant stuff
end
end
In spec/model/request.rb, I’ve tried all of the following:
require "company"
require "lib/test/company"
require "lib/test/company.rb"
require Rails.root + "/lib/test/company.rb"
None of those works, at the class certainly isn’t getting autoloaded. What’s going on?
In your spec file:
This is unnecessary if you’d like to autoload all modules/classes from lib. To do so, add to the config block in your application.rb file:
Addition:
You can then call
Test::Companyfrom the top-level namespace to access this class.