On Apr 15, 3:02 pm, BarryOg <[email protected]> wrote:
> Frederick Cheung-2 wrote:
>
> > Assuming for a moment (and I don't know if this is true) that you
> > can't test application controller directly, there's no reason you
> > cannot create a subclass of ApplicationController that only exists in
> > your test and which you use to exercise the methods provided by
> > ApplicationController.
>
> > Fred
>
> That's a fair point, but it involves mocking out the ApplicationController
> and everything it relies on, that's what the rails framework is there for,
> just curious why I can't seem to access it.


That's not quite what I meant. What i meant was


class ApplicationControllerTest < ActionController::TestCase
  class StubController < ApplicationController
    def index
       render :text => 'index action'
    end
  end
  tests ApplicationControllerTest::StubController

  test "non logged in user should be redirected to login page" do
    get :index
    assert_redirected_to '/login'
  end
end

No mocking involved!

Fred

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to