Namespaced controllers

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

On Nov 23, 2007 3:48 PM, Scott T. [email protected]
wrote:

describe Admin::MyController

end

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

Kyle

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

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

On Nov 23, 2007 11:53 PM, Scott T. [email protected]
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

On Nov 25, 2007 9:23 AM, Kyle H. [email protected] wrote:

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

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

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 T.-6 wrote:

and rspec r2980.


View this message in context:
http://www.nabble.com/namespaced-controllers-tp13919259p14292651.html
Sent from the rspec-users mailing list archive at Nabble.com.

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 C.-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.

Well put.

Nathan S.
[email protected]
rspec edge revision 3052
rspec_on_rails edge revision 3049
rails 2.0.1

On Dec 12, 2007 5:03 AM, Thijs C. [email protected] 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.

On Dec 12, 2007 5:03 AM, Thijs C. [email protected] 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

On Dec 12, 2007 4:37 PM, David C. [email protected] wrote:

On Dec 12, 2007 5:03 AM, Thijs C. [email protected] 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

On Dec 12, 2007 5:57 PM, Thijs C. [email protected] 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 :slight_smile:

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.