[rspec-users] Trouble with (Rails) Nested Model Directories

mudphone kyleoba at gmail.com
Thu Mar 5 17:02:20 EST 2009

Hi folks,

In order to bring some order to the many model classes that I have
under /app/models, I'm created a new directory (for example):

I've added the required configuration line in environment.rb:
  config.load_paths += %W( #{RAILS_ROOT}/app/models/nestdir )

But, when I run my specs, I get an error such as:
dependencies.rb:428:in `load_missing_constant': Expected RAILS_ROOT/
app/models/nestdir/my_model.rb to define Nestdir::MyModel (LoadError)

>From my understanding, the models in the dir listed in
config.load_paths should be available in the root Rails namespace.  Is
this not how rspec handles things?

Is there a standard way of setting up specs for nested model
directories?  The models are not nested within a parent module (like
Nestdir, which would have matched the directory name).


More information about the rspec-users mailing list