Closed zoras closed 13 years ago
Hi,
I think it's not a problem in your Guardfile, we have many models in subfolders, never had this issue. Is your model well named? (i.e. it should be class Vehicles::Car < Vehicle
I guess)
Anyway, the simplest watch
definition you can add is the following (it will catch all subfolders if any):
watch(%r{^spec/.+_spec\.rb})
Edit: And it's definitely not related to Guard::Spork at all! ;)
I don't think it's a issue with guard-spork (maybe more guard-rspec or guard directly), but
watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
will automatically handles any numbers of sub paths.
hmm.. i already have that watch, but somethings not working. My specs and features are working fine with spork though.
I'm using mongoid and i've inherited models as class Car < Vehicle
as suggested in mongoid documentation.
Thanx for quick reply.
PS: guard is loading fine but i can't run tests due to the error
Hey,
I'll try to reproduce your issue, when I got some time, let us know if you fix it in the meantime! ;)
@zoras If you have
class Car < Vehicle
then car.rb should be in app/models/ not app/models/vehicle/ .
@nickhoffman rails allows STI models to be organized in separate folder, which is what I want to implement
also there's no need to namespace
class Vehicles::Car < Vehicle
as shown in mongoid documentation
http://mongoid.org/docs/documents/inheritance.html
As I mentioned earlier, now only guard is not working while spork is fine. But if I do that then my app doesn't work & gives me the same error even in development mode.
Finally, found & solved the problem
I removed the following line from spechelper.rb
ActiveSupport::Dependencies.clear
and voila guard is working fine now. :)
I have 2 to 3 level inheritance and have arranged them inside subfolders under models.
When I run guard rspec or cucumber, I get following error:
Exception encountered: #<LoadError: Expected /Users/zoras/Dev/automobile/app/models/vehicles/car.rb to define Car>
So how do I tell guard that they are subclasses?
I tried adding these to guardfile but didn't work:
watch(p %r{^app/models/*/$})
watch('app/models/**/*.rb') { "spec/models" }