[rspec-users] RSpec - Testing ActiveRecord addins

James Byrne lists at ruby-forum.com
Fri Jan 30 15:24:21 EST 2009

James Byrne wrote:
> Pat Nakajima wrote:
>> James,
>> Can you show me how you're trying to use ActsAsFu?
>> Pat
> Not easily, because I removed the code.  When I get a moment I will 
> reset it and post here.  It will be later today.

Here is what I have.  FYI once I removed the custom logger from 
spec_helper.rb everything worked just fine thereafter.

# hll_audit_stamps_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "Builds a Model with custom magic columns" do
  before(:all) do
    build_model   :magiks do
      string    :description
    # these are Rails' own magic columns
      datetime  :created_at
      datetime  :created_on
      datetime  :updated_at
      datetime  :updated_on
    # these are our custom magic columns
      ActiveRecord::Base::HLL_AUDIT_COLUMNS.each do |magic_column|
        string    magic_column  if /.*_by\z/.match(magic_column)
        datetime  magic_column  if /.*_(at|on)\z/.match(magic_column)
    @my_mage = Magik.new

# control - make sure the default behaviour is preserved
  it "should set Rails created_at" do
    @my_mage.created_at.should_not be_nil
    puts @my_mage.created_at

  it "should set Rails created_on" do
    @my_mage.created_on.should_not be_nil
    puts @my_mage.created_on
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list