Anonymous controller don't load named routes #339

Closed
petRUShka opened this Issue Mar 23, 2011 · 4 comments

Comments

Projects
None yet
4 participants
@petRUShka
require 'spec_helper'

describe Company::BaseController do
  controller do
    def index
      render :text => "text"
    end
  end

  it "should redirect to destroy" do
    get :index

    response.should redirect_to(destroy_user_session_path)
  end
end

I got an error:

 Failure/Error: response.should redirect_to(destroy_user_session_path)
 NameError:
   undefined local variable or method `destroy_user_session_path' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x0000000690b450>

But in other specs destroy_user_session_path works fine

P.S.

Bundle show

/usr/lib/ruby/gems/1.9.1/gems/rspec-2.5.0
/usr/lib/ruby/gems/1.9.1/gems/rspec-rails-2.5.0
/usr/lib/ruby/gems/1.9.1/gems/rails-3.0.1
@raskchanky

This comment has been minimized.

Show comment
Hide comment
@raskchanky

raskchanky Mar 29, 2011

I'm also having this problem.

ruby = MRI 1.9.2-p0
rspec = 2.5.0
rails = 3.0.4

I'm also having this problem.

ruby = MRI 1.9.2-p0
rspec = 2.5.0
rails = 3.0.4

@alindeman

This comment has been minimized.

Show comment
Hide comment
@alindeman

alindeman Apr 16, 2011

Contributor

This is because defining a controller with controller do ... end stubs the routing. The solution may not be trivial, though I could be missing something.

Contributor

alindeman commented Apr 16, 2011

This is because defining a controller with controller do ... end stubs the routing. The solution may not be trivial, though I could be missing something.

@alindeman

This comment has been minimized.

Show comment
Hide comment
@alindeman

alindeman Apr 16, 2011

Contributor

Actually, I think I can get a patch going for this using method_missing :)

Contributor

alindeman commented Apr 16, 2011

Actually, I think I can get a patch going for this using method_missing :)

@alindeman

This comment has been minimized.

Show comment
Hide comment
@alindeman

alindeman Apr 16, 2011

Contributor

Interesting; did not realize commits in my forked repo would automatically push here

Contributor

alindeman commented Apr 16, 2011

Interesting; did not realize commits in my forked repo would automatically push here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment