[rspec-users] RSpec - Testing ActiveRecord addins

James B. Byrne byrnejb at harte-lyne.ca
Thu Jan 29 16:24:36 EST 2009

I wish to test a small library that I have written.  The module
resides in a file in ./lib.  It is loaded in the application via a a
file in ./config/initializers that contains the following code:

> require 'hll_audit_stamps'
> ActiveRecord::Base
>  include ActiveRecord::HLLAuditStamps
> end

My questions are really procedural in nature.  What do I put at the
top of my spec file to load an ActiveRecord instance containing the
custom module? Or, do I put the code given above into

I am really only interested in the actions of the module so I would
like to create a test model instance (Mytable) inside the spec
rather than create a dummy model in app/models.  How do you do this
without connecting to an underlying database?  I am unfamiliar with
mocks, although this seems to be the case for one.  Nonetheless, am
am uncertain how a mock would inherit the necessary characteristics
from the module that I am testing?

I would appreciate guidance here.


***          E-Mail is NOT a SECURE channel          ***
James B. Byrne                mailto:ByrneJB at Harte-Lyne.ca
Harte & Lyne Limited          http://www.harte-lyne.ca
9 Brockley Drive              vox: +1 905 561 1241
Hamilton, Ontario             fax: +1 905 561 0757
Canada  L8E 3C3

More information about the rspec-users mailing list