[rspec-users] Trouble defining a stub method for a controller

Aníbal Rojas anibalrojas at gmail.com
Tue May 29 19:47:01 EDT 2007


Gaston, right now I am far away from mi dev box, I will check tomorow.
Thanks for your help.

-- 
Aníbal

On 5/29/07, Gastón Ramos <gramos at rectorado.unl.edu.ar> wrote:
> El mar, 29 de may de 2007, a las 04:12:19 -0400, Aníbal Rojas dijo:
> > Gastón, thanks for your response, but that is my same code and it is not workig.
> >
> > I  started a new scaffold application, to discard any other problem,
> > and it just doesn't work in any of the dev boxes in our offices.
> >
> > --
> > Aníbal
>
> wich is the exact error?
> are you watching the test.log file?
>
> >
> > On 5/29/07, Gaston Ramos <gramos at rectorado.unl.edu.ar> wrote:
> > > El mar, 29 de may de 2007, a las 01:42:04 -0400, Aníbal Rojas dijo:
> > > > Hello,
> > > >
> > > >     Not sure if I am doing something really wrong (let's not say
> > > > stupid for now), but I haven't been able to stub a controller method
> > > > like:
> > > >
> > > >      controller.stub!(:logged_in?).and_return(true)
> > > >
> > > >      Please help, this is driving me nuts ;-)
> > >
> > > I have this, and works ok! try it:
> > >
> > > describe PersonController do
> > >
> > >   before(:each) do
> > >     @person = mock("person")
> > >
> > >     @person.stub!(:new_record?).and_return(false)
> > >     Person.stub!(:new).and_return(@person)
> > >     controller.stub!(:logged_in?).and_return(true)
> > >  end
> > >
> > >  it "create should be redirect list at finish" do
> > >    get 'create'
> > >    response.should redirect_to(:action => 'list')
> > >  end
> > >
> > > end
> > >
> > >
> > > >
> > > > --
> > > > Aníbal Rojas
> > > > http://www.rubycorner.com
> > > > http://www.hasmanydevelopers.com
> > > > _______________________________________________
> > > > rspec-users mailing list
> > > > rspec-users at rubyforge.org
> > > > http://rubyforge.org/mailman/listinfo/rspec-users
> > > >
> > >
> > > --
> > > Gastón Ramos
> > >
> > > "I always thought Smalltalk would beat Java, I just didn't know it would be
> > > called 'Ruby' when it did."
> > >  -- Kent Beck
> > > _______________________________________________
> > > rspec-users mailing list
> > > rspec-users at rubyforge.org
> > > http://rubyforge.org/mailman/listinfo/rspec-users
> > >
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
> >
>
> --
> Gastón Ramos
>
> "I always thought Smalltalk would beat Java, I just didn't know it would be
> called 'Ruby' when it did."
>  -- Kent Beck
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list