Forum: RSpec concerned_with, and maybe require_dependency issues only when running specs?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
27565572097bf4c73e2a5617b29682db?d=identicon&s=25 Cameron Booth (Guest)
on 2008-11-03 22:57
(Received via mailing list)
Hi all,

So in the interests of keeping a few areas of my code a bit under
control,
I've been investigating the concept of "concerned_with" as described
here:

http://paulbarry.com/articles/2008/08/30/concerned...

Basically allowing me to have:

/app/models/user.rb
class User < ActiveRecord::Base
  concerned_with :something
end

/app/models/user/something.rb
class User < ActiveRecord::Base
  def something_method
     do_it
  end
end

I realize that there might be better ways to deal with this same
issue...some of my code might be better off in separate classes, or
modules,
etc, but for now I'm hoping to try this out. And it's working working
great
in my code, when I run the server, script/console, etc...

....everywhere except in my specs.

And, its working in my actual model spec just fine
(spec/models/user_spec.rb).

But where it's not working is in other specs that end up using the user
model, such as some controller specs, and view specs where things aren't
fully stubbed/mocked out.

It seems like in those other specs, the User class doesn't have
"something_method" defined. (the failure message is undefined_method
"something_method" for #<Class:0x243626c>

Anybody have any ideas? I have a feeling it's related to
require_dependency
or something, but I'm not really sure. I've turned on logging in
require_dependency, and it seems like the files are being required. Any
help
would be great, thanks!

Cameron
7a2a1e3ce27a5da7c0849b923a9309b2?d=identicon&s=25 Gerard Leijdekkers (sundevil)
on 2009-08-06 13:48
We are having the same issue. It works fine when config.cache_classes is
on. but when its turned off stuff breaks. The extra files are no longer
parsed.

concerned_with seems to have an issue with eager loading. Right now
we're looking at alternatives.
This topic is locked and can not be replied to.