[rspec-users] can't seem to test redirect?

Pat Maddox pergesu at gmail.com
Fri Oct 24 14:06:40 EDT 2008

Harry Bishop <lists at ruby-forum.com> writes:

> I'm posting to the create action and seeing the line "at the motion save
> part of create in the following:
>   def create
>     @motion = Motion.new(params[:motion])
>     respond_to do |format|
>       if @motion.save
>         puts "at the motion save part of create"
>         flash[:notice] = 'Motion was successfully created. Needs a
> second'
>         format.html { redirect_to(@motion) }
> but when I insert the line in motions_controller_spec.rb
> response.should redirect_to(@motion)
> I receive "got no redirect"
> expected redirect to #<Spec::Mocks::Mock:0x112ec96 @name=#<Motion id:
> 20, title:........>>, got no redirect
> Is there something missing in the test?
> TIA,
> Harry

Can you post your example code as well?  Also, are there any errors?
Here are my two guesses at this point:

* you forgot to make a request in the example (post :create)
* there's some error that is keeping the action from getting to the

Also, what is the value of response.code in the example?


More information about the rspec-users mailing list