[rspec-users] Autotest and subclasses / namespaces

Matt Wynne matt at mattwynne.net
Mon Aug 18 05:07:41 EDT 2008


Thanks for the tips Ben.

We upgraded to Rails 2.1 (from 1.x) on Friday and this seems to have  
gone away. I'll report back though if I learn anything else.

cheers,
Matt
----
http://blog.mattwynne.net

On 16 Aug 2008, at 20:32, Ben Mabey wrote:

> Matt Wynne wrote:
>> I am writing a controller admin/cities_controller.rb
>>
>> it inherits from AdminController, so it's defined like
>>
>> class Admin::CitiesController > AdminController
>>
>> Whenever I save the controller file, autotest freaks out:
>>
>> uninitialized constant Admin::AdminController (NameError)
>>
>> I'm pretty used to just hitting CTRL-C to get autotest to re-load all
>> the files, or flicking to the spec file, and saving it to get a
>> similar effect.
>>
>> But it is fairly irritating.
>>
>> Any suggestions for how to hack autotest to get this to flow more  
>> nicely?
>
>
> Hmm... I am using namedspaced controllers on my current project and  
> I am
> not running into those issues.  I am using rspec edge, ZenTest 3.9.1,
> and rails 2.1.0.
>
> Have you copied your code exactly in your original email?  If so, I
> might see a difference in how we are doing things and that might be  
> your
> problem.
> My base controller is also namedspaced.. So in my app/controllers/ 
> admin
> dir I have the following:
>
> base_contoller.rb:
> module Admin
>   class BaseController < ::ApplicationController
>   ....
>   end
> end
>
> Then:
>
> other_controller.rb:
> module Admin
>   class OtherController < BaseController
>     ...
>   end
> end
>
> Note that I could also do:
>
> base_contoller.rb:
> class Admin::BaseController < ApplicationController
>
> other_controller.rb:
> class Admin::OtherController < Admin::BaseController
>
>
>
>
> So.. If your AdminController is namespaced you should change your  
> other
> controllers to:
> class Admin::CitiesController < Admin::AdminController
>
> If it is not namespaced (but, it really should be IMO) then you could
> try this:
> class Admin::CitiesController < ::AdminController
>
> Hope that helps,
> Ben
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list