namespaced controllers

View: New views
13 Messages — Rating Filter:   Alert me  

namespaced controllers

by Scott Taylor-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Out of curiosity, I've seen the following fail:

module Admin
   describe MyController
   ...
   end
end

But this works fine:

describe Admin::MyController
   ..
end

Why?

Scott



_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: namespaced controllers

by Kyle Hargraves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 23, 2007 3:48 PM, Scott Taylor <mailing_lists@...> wrote:

>
> Out of curiosity, I've seen the following fail:
>
> module Admin
>    describe MyController
>    ...
>    end
> end
>
> But this works fine:
>
> describe Admin::MyController
>    ..
> end

How has the top one failed? I use it exclusively and haven't ever
noticed a problem.

Kyle
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: namespaced controllers

by Scott Taylor-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Nov 23, 2007, at 5:27 PM, Kyle Hargraves wrote:

> On Nov 23, 2007 3:48 PM, Scott Taylor  
> <mailing_lists@...> wrote:
>>
>> Out of curiosity, I've seen the following fail:
>>
>> module Admin
>>    describe MyController
>>    ...
>>    end
>> end
>>
>> But this works fine:
>>
>> describe Admin::MyController
>>    ..
>> end
>
> How has the top one failed? I use it exclusively and haven't ever
> noticed a problem.
>

I got an "unknown action foo" error message (wasn't getting it before  
today - running on trunk).

Scott



_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: namespaced controllers

by Kyle Hargraves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 23, 2007 11:53 PM, Scott Taylor <mailing_lists@...> wrote:
> I got an "unknown action foo" error message (wasn't getting it before
> today - running on trunk).
>
>
> Scott

Can you reproduce it reliably?

I had an Admin::SomeController controller, and the specs were passing
fine. I went to add ::SomeController, and the new specs for it passed,
but Admin::SomeController started raising UnknownAction (for all the
actions that weren't defined in the non-admin controller).

But once I restarted autotest, they're passing cleanly, and now I
can't seem to reproduce it at all.

Kyle
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: namespaced controllers

by Kyle Hargraves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 25, 2007 9:23 AM, Kyle Hargraves <philodespotos@...> wrote:

> On Nov 23, 2007 11:53 PM, Scott Taylor <mailing_lists@...> wrote:
> > I got an "unknown action foo" error message (wasn't getting it before
> > today - running on trunk).
> >
> >
> > Scott
>
> Can you reproduce it reliably?
>
> I had an Admin::SomeController controller, and the specs were passing
> fine. I went to add ::SomeController, and the new specs for it passed,
> but Admin::SomeController started raising UnknownAction (for all the
> actions that weren't defined in the non-admin controller).
>
> But once I restarted autotest, they're passing cleanly, and now I
> can't seem to reproduce it at all.

Figured out how to reproduce it. It depends on load order, I guess.

Given the files:
  spec/controllers/foo_controller_spec.rb
  spec/controllers/admin/foo_controller_spec.rb

The specs do nothing but hit the FooController#show and
Admin::FooController#index actions and expect the right render.

If I touch admin/foo_controller_spec.rb, the specs pass.

If I touch foo_controller_spec.rb, the specs for Admin::FooController
fail with UnknownAction exceptions, since ::FooController has no index
action defined.

Problem occurs with autotest and rake spec, but not with ./script/spec spec.

This is happening with the current latest trunk versions, rails r8200
and rspec r2980.

Kyle
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: namespaced controllers

by Scott Taylor-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> Figured out how to reproduce it. It depends on load order, I guess.
>
> Given the files:
>   spec/controllers/foo_controller_spec.rb
>   spec/controllers/admin/foo_controller_spec.rb
>
> The specs do nothing but hit the FooController#show and
> Admin::FooController#index actions and expect the right render.
>
> If I touch admin/foo_controller_spec.rb, the specs pass.
>
> If I touch foo_controller_spec.rb, the specs for Admin::FooController
> fail with UnknownAction exceptions, since ::FooController has no index
> action defined.
>
> Problem occurs with autotest and rake spec, but not with ./script/
> spec spec.
>
> This is happening with the current latest trunk versions, rails r8200
> and rspec r2980.

Can you put this in the tracker?  I'm likely to forget about it  
otherwise.

Scott

_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: namespaced controllers

by Thijs Cadier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Has anybody been taking a look at this issue? I'm getting a little annoyed touching the namespaced controllers before running the specs all the time :-).


Scott Taylor-6 wrote:
>
> Figured out how to reproduce it. It depends on load order, I guess.
>
> Given the files:
>   spec/controllers/foo_controller_spec.rb
>   spec/controllers/admin/foo_controller_spec.rb
>
> The specs do nothing but hit the FooController#show and
> Admin::FooController#index actions and expect the right render.
>
> If I touch admin/foo_controller_spec.rb, the specs pass.
>
> If I touch foo_controller_spec.rb, the specs for Admin::FooController
> fail with UnknownAction exceptions, since ::FooController has no index
> action defined.
>
> Problem occurs with autotest and rake spec, but not with ./script/
> spec spec.
>
> This is happening with the current latest trunk versions, rails r8200
> and rspec r2980.

Can you put this in the tracker?  I'm likely to forget about it  
otherwise.

Scott

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: namespaced controllers

by David Chelimsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Dec 12, 2007 5:03 AM, Thijs Cadier <thijs@...> wrote:
>
> Has anybody been taking a look at this issue? I'm getting a little annoyed
> touching the namespaced controllers before running the specs all the time
> :-).

What annoys me is the relative inverse ratio of level of whining to
level of contribution.

If you want it done quick, stop whining and contribute a patch.

>
>
>
>
> Scott Taylor-6 wrote:
> >
> >>
> >> Figured out how to reproduce it. It depends on load order, I guess.
> >>
> >> Given the files:
> >>   spec/controllers/foo_controller_spec.rb
> >>   spec/controllers/admin/foo_controller_spec.rb
> >>
> >> The specs do nothing but hit the FooController#show and
> >> Admin::FooController#index actions and expect the right render.
> >>
> >> If I touch admin/foo_controller_spec.rb, the specs pass.
> >>
> >> If I touch foo_controller_spec.rb, the specs for Admin::FooController
> >> fail with UnknownAction exceptions, since ::FooController has no index
> >> action defined.
> >>
> >> Problem occurs with autotest and rake spec, but not with ./script/
> >> spec spec.
> >>
> >> This is happening with the current latest trunk versions, rails r8200
> >> and rspec r2980.
> >
> > Can you put this in the tracker?  I'm likely to forget about it
> > otherwise.
> >
> > Scott
> >
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users@...
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
> >
>
> --
> View this message in context: http://www.nabble.com/namespaced-controllers-tp13919259p14292651.html
> Sent from the rspec-users mailing list archive at Nabble.com.
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users@...
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: namespaced controllers

by Thijs Cadier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi David,

You might have taken my message the wrong way. I didn't mean to say I was annoyed because the Rspec team hasn't delivered a solution for my problem. I was trying to say that I'm annoyed by the consequences of this problem, in a friendly way.

I actually had a look at the Rspec code, but I quickly saw that I'm not able to fix a problem like this with my level of understanding of the Rspec internals.

Anyway, I hope this issue stays on the radar and I'll do a bit more research myself to see if I can find the cause.


Thijs

David Chelimsky-2 wrote:
What annoys me is the relative inverse ratio of level of whining to
level of contribution.

If you want it done quick, stop whining and contribute a patch.

Re: namespaced controllers

by Nathan Sutton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well put.

Nathan Sutton
fowlduck@...
rspec edge revision 3052
rspec_on_rails edge revision 3049
rails 2.0.1

On Dec 12, 2007, at 4:37 PM, David Chelimsky wrote:

> On Dec 12, 2007 5:03 AM, Thijs Cadier <thijs@...> wrote:
>>
>> Has anybody been taking a look at this issue? I'm getting a little  
>> annoyed
>> touching the namespaced controllers before running the specs all  
>> the time
>> :-).
>
> What annoys me is the relative inverse ratio of level of whining to
> level of contribution.
>
> If you want it done quick, stop whining and contribute a patch.
>
>>
>>
>>
>>
>> Scott Taylor-6 wrote:
>>>
>>>>
>>>> Figured out how to reproduce it. It depends on load order, I guess.
>>>>
>>>> Given the files:
>>>>  spec/controllers/foo_controller_spec.rb
>>>>  spec/controllers/admin/foo_controller_spec.rb
>>>>
>>>> The specs do nothing but hit the FooController#show and
>>>> Admin::FooController#index actions and expect the right render.
>>>>
>>>> If I touch admin/foo_controller_spec.rb, the specs pass.
>>>>
>>>> If I touch foo_controller_spec.rb, the specs for  
>>>> Admin::FooController
>>>> fail with UnknownAction exceptions, since ::FooController has no  
>>>> index
>>>> action defined.
>>>>
>>>> Problem occurs with autotest and rake spec, but not with ./script/
>>>> spec spec.
>>>>
>>>> This is happening with the current latest trunk versions, rails  
>>>> r8200
>>>> and rspec r2980.
>>>
>>> Can you put this in the tracker?  I'm likely to forget about it
>>> otherwise.
>>>
>>> Scott
>>>
>>> _______________________________________________
>>> rspec-users mailing list
>>> rspec-users@...
>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>>
>>>
>>
>> --
>> View this message in context: http://www.nabble.com/namespaced-controllers-tp13919259p14292651.html
>> Sent from the rspec-users mailing list archive at Nabble.com.
>>
>>
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users@...
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
> _______________________________________________
> rspec-users mailing list
> rspec-users@...
> http://rubyforge.org/mailman/listinfo/rspec-users

_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: namespaced controllers

by Kyle Hargraves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Dec 12, 2007 4:37 PM, David Chelimsky <dchelimsky@...> wrote:

> On Dec 12, 2007 5:03 AM, Thijs Cadier <thijs@...> wrote:
> >
> > Has anybody been taking a look at this issue? I'm getting a little annoyed
> > touching the namespaced controllers before running the specs all the time
> > :-).
>
> What annoys me is the relative inverse ratio of level of whining to
> level of contribution.
>
> If you want it done quick, stop whining and contribute a patch.

I ended up coming to the conclusion that this is probably not rspec's
bug, but never bothered to reply here or update the ticket I filed.
Just did:

http://rspec.lighthouseapp.com/projects/5645/tickets/145-namespaced-controller-load-order

Kyle
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: namespaced controllers

by Kyle Hargraves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Dec 12, 2007 5:03 AM, Thijs Cadier <thijs@...> wrote:
>
> Has anybody been taking a look at this issue? I'm getting a little annoyed
> touching the namespaced controllers before running the specs all the time
> :-).

As a workaround, do what the rest of us have done and just be explicit
about the module.

describe Admin::FooController

Problem goes away.

I probably shouldn't even call it a workaround -- it's a solution. The
only change is a minor difference in style.

Kyle
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users

Re: namespaced controllers

by David Chelimsky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Dec 12, 2007 5:57 PM, Thijs Cadier <thijs@...> wrote:
>
> Hi David,
>
> You might have taken my message the wrong way. I didn't mean to say I was
> annoyed because the Rspec team hasn't delivered a solution for my problem. I
> was trying to say that I'm annoyed by the consequences of this problem, in a
> friendly way.

I did misread it. Thanks for being less reactionary than me :)

> I actually had a look at the Rspec code, but I quickly saw that I'm not able
> to fix a problem like this with my level of understanding of the Rspec
> internals.

They are confusing - especially in the rails plugin. We're slowly
working on improving that.

> Anyway, I hope this issue stays on the radar and I'll do a bit more research
> myself to see if I can find the cause.
>
>
> Thijs
>
>
> David Chelimsky-2 wrote:
> >
> > What annoys me is the relative inverse ratio of level of whining to
> > level of contribution.
> >
> > If you want it done quick, stop whining and contribute a patch.
> >
> --
> View this message in context: http://www.nabble.com/namespaced-controllers-tp13919259p14306960.html
>
> Sent from the rspec-users mailing list archive at Nabble.com.
>
> _______________________________________________
> rspec-users mailing list
> rspec-users@...
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@...
http://rubyforge.org/mailman/listinfo/rspec-users