[rspec-users] How can I create a active-record model w/o depending on the database?

S Ahmed sahmed1020 at gmail.com
Sun Sep 23 23:55:43 UTC 2012

I have a class that takes a class that inherits from activerecord as a
parameter, e.g.:

class SomeModel < ActiveRecord::Base

class MyClass
  attr_accessor :model
  def initialize(model)
    @model = model

The class MyClass will then iterate over the Models attributes etc.

Also I will need to know each attributes data type in mysql like: integer,
boolean, etc.

So my unit tests shouldnt' rely on the database, but I'm a little confused
on how I can create stub/mock that will have attributes on it similiar to
how it would be if I was creating a model and it reading the mysql columns
as attributes.

Thoughts on how I can do this w/o actually having to depend on a database
for my spec tests?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120923/52187fc2/attachment.html>

More information about the rspec-users mailing list