[rspec-users] Help with spec controller

Gaston Ramos gramos at rectorado.unl.edu.ar
Tue Jun 5 13:15:31 EDT 2007


El mar, 05 de jun de 2007, a las 12:00:11 -0500, David Chelimsky dijo:
> On 6/5/07, Gaston Ramos <gramos at rectorado.unl.edu.ar> wrote:
> > El mar, 05 de jun de 2007, a las 10:59:15 -0500, David Chelimsky dijo:
> > > On 6/5/07, Gaston Ramos <gramos at rectorado.unl.edu.ar> wrote:
> > > > Hello,
> > > >
> > > > I haven't been able to create a controller spec.
> > > > You can see the code here:
> > > >
> > > > http://pastie.caboo.se/67980
> > >
> > > Instead of this:
> > >
> > >   Person.stub!(:save).and_return( @person )
> > >
> > > do this:
> > >
> > >   person.stub!(:save).and_return(true)
> > >
> > > Please let us know if that fixes it.
> >
> > I tried that way and it did'nt work
> 
> "it didn't work" doesn't help us to help you. How didn't it work? What
> was the error this time? Can you post the controller code in addition
> to the rspec example?

you can see the person_controller_spec code:

http://pastie.caboo.se/67993

and the person_controller code:

http://pastie.caboo.se/67994

when I run:
 rake spec:controllers

I get this error:

DEPRECATION WARNING: model is deprecated and will be removed from Rails 2.0  See
http://www.rubyonrails.org/deprecation for details. (called from
/home/gramos/src/rails/dental/config/../app/controllers/application.rb:10)
DEPRECATION WARNING: depend_on is deprecated and will be removed from Rails 2.0
See http://www.rubyonrails.org/deprecation for details. (called from
model_without_deprecation at
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/deprecated_dependencies.rb:13)
...F

1)
Spec::Mocks::MockExpectationError in 'PersonController should tell the Person
model to create a new person on POST to create'
Mock 'person' received unexpected message :save with (no args)
/home/gramos/src/rails/dental/config/../app/controllers/person_controller.rb:26:in
`create'
./spec/controllers/person_controller_spec.rb:47:

Finished in 0.142998 seconds

4 examples, 1 failure


> 
> 
> >
> > >
> > > >
> > > > The error message I'm getting is:
> > > >
> > > > Spec::Mocks::MockExpectationError in 'PersonController should tell the Person
> > > > model to create a new person on POST to create'
> > > > Mock 'person' received unexpected message :save with (no args)
> > > > /home/gramos/src/rails/dental/config/../app/controllers/person_controller.rb:26:in
> > > > `create'
> > > > ./spec/controllers/person_controller_spec.rb
> > > >
> > > > I can't find what I am doing wrong.
> > > >
> > > > I would appreciate any help. thanks in advance.
> > > >
> > > >
> > > > --
> > > > 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
> >
> _______________________________________________
> 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


More information about the rspec-users mailing list