[rspec-users] [newbie]: How to test for operations inside a block?

Carmine Moleti lists at ruby-forum.com
Mon Sep 22 13:40:10 EDT 2008

Hi Mark,

First off, thanks a lot for your reply!

Mark Wilden wrote:
> On Mon, Sep 22, 2008 at 9:07 AM, Carmine Moleti 
> <lists at ruby-forum.com>wrote:
>>        assign_registration_attributes!(registration)
>>        @user.save(false)
>>        redirect_to users_path
>>      else
>>        redirect_to new_user_path
>>      end
>>    end
>>  end

> The first thing I would do would be to refactor this code into the User
> model. The controller shouldn't be concerned with assigning the 
> user_type,
> for example.

Care to explain a little more?
I left the code in the controller because it's the controller that knows 
the context in which the gets created.

Should I have written one or more class methods on User to accomplish 
the task
of setting properties properly?

"user_type" is something I forgot to remove, and it has been replaced by 

> Others may have more insight, but I would want to know what the specific
> complaints were.

The error shown is:

Mock 'User' expected :save with (false) once, but received it 0 times
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list