Aníbal Rojas
2007-May-29 17:42 UTC
[rspec-users] Trouble defining a stub method for a controller
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 ;-) -- An?bal Rojas http://www.rubycorner.com http://www.hasmanydevelopers.com
Gaston Ramos
2007-May-29 18:37 UTC
[rspec-users] Trouble defining a stub method for a controller
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
Gaston Ramos
2007-May-29 18:42 UTC
[rspec-users] Trouble defining a stub method for a controller
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
Aníbal Rojas
2007-May-29 20:12 UTC
[rspec-users] Trouble defining a stub method for a controller
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 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 >
Gastón Ramos
2007-May-29 20:57 UTC
[rspec-users] Trouble defining a stub method for a controller
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?balwich 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
Aníbal Rojas
2007-May-29 23:47 UTC
[rspec-users] Trouble defining a stub method for a controller
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 >