On 8/15/07, Priit Tamboom <[EMAIL PROTECTED]> wrote:
> Good morning rspec people!
>
> Still rspec nuby: I must do something wrong obviously.
>
> How can I spec about redirect_to at ApplicationController
>
> describe ApplicationController do
>    it "method login_required should redirect to home path without login" do

heh.  "it" is so out of place here :)

>      pending "I tried to use
> controller.login_required.should be_redirected
>         and got NoMethodError with nil object didn't expect error."
>    end
> end
>

like
  controller.should_receive(:redirect_to)
  controller.send :login_required

??

or

  controller.should_receive(:current_user).and_return(nil)
  get :foo
  response.should redirect_to(...)



> class ApplicationController < ActionController::Base
>   # using it with before_filter
>   def login_required
>      # I took out everything except redirecting to make the point simple
>      redirect_to home_path  # tried also redirect_to "/"
>   end
> end
>
> However the code does work manually testing with browser.
>
> Thanks for any help,
> Priit
>
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to