Cameron Booth
2008-Nov-03 21:55 UTC
[rspec-users] concerned_with, and maybe require_dependency issues only when running specs?
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-with-skinny-controller-skinny-model 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081103/bff4c633/attachment.html>
Gerard Leijdekkers
2009-Aug-06 11:48 UTC
[rspec-users] concerned_with, and maybe require_dependency issues only
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. -- Posted via http://www.ruby-forum.com/.
Seemingly Similar Threads
- aliasing, require_dependency and require
- Am I misunderstanding "require_dependency"?
- Is require_dependency supposed to be a public API?
- Couldn't reload a module when it's changed. Tried :require_dependency, :watchable_dirs, :unloadable
- pass text_field to controller when using periodically_call_r