[rspec-users] How far to go with ActiveRecord unit tests without hitting the database?

Tom Stuart tom at experthuman.com
Sun Sep 16 04:05:31 EDT 2007

On 16 Sep 2007, at 06:43, Pat Maddox wrote:
> You can't assign mock objects to associations.

Actually I haven't had any trouble with e.g.

   @company = Company.new :name => 'BigCo'
   @mock_employee = mock_model(Employee, :name => 'Pat', :[]= =>  
true, :save => true)
   @company.employees << @mock_employee

(To be followed by, for example, @mock_employee.should_receive 
(:destroy); @company.destroy.)

Is that unacceptable?


More information about the rspec-users mailing list