Ruby Forum RSpec > noob question for getting true or false from a function

Posted by Patrick Aljord (patcito)
on 29.04.2008 08:00
(Received via mailing list)
Hey all,

I have an action that looks like this:

  def create
    if using_open_id?
      open_id_authentication(params[:openid_url])
    else
      password_authentication(params[:email], params[:password])
    end
  end

I have a spec that looks like this:
  it "should login and redirect" do
    post :create, :email => "foo@bar.com", :password => "test"
    <here goes the code that says that using_open_id? must return false>
    session[:user_id].should_not be(nil)
    response.should be_redirect
  end

any idea how to make this work so that using_open_id? returns false?
For now I get "undefined method `using_open_id?' for
#<SessionsController>". I don't want to write a test for
using_open_id? cause it comes with the open_id_authentication plugin.

thanks in advance

Pat
Posted by David Chelimsky (Guest)
on 29.04.2008 08:08
(Received via mailing list)
On Apr 29, 2008, at 12:59 AM, Patrick Aljord wrote:

>  end
>
> I have a spec that looks like this:
>  it "should login and redirect" do
>    post :create, :email => "foo@bar.com", :password => "test"
>    <here goes the code that says that using_open_id? must return  
> false>

      controller.stub!(:using_open_id?).and_return(false)

>
>    session[:user_id].should_not be(nil)
>    response.should be_redirect
>  end
>
> any idea how to make this work so that using_open_id? returns false?
> For now I get "undefined method `using_open_id?' for
> #<SessionsController>". I don't want to write a test for
> using_open_id? cause it comes with the open_id_authentication plugin.

HTH,
David
Posted by Helder Ribeiro (helder)
on 29.04.2008 09:25
(Received via mailing list)
On Tue, Apr 29, 2008 at 3:06 AM, David Chelimsky <dchelimsky@gmail.com> 
wrote:
> >   else
>      controller.stub!(:using_open_id?).and_return(false)
I had run into the same problem the other day. Thanks for the tip! :)
Posted by Patrick Aljord (patcito)
on 29.04.2008 17:59
(Received via mailing list)
ok thanks a lot.