Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
When you need a dash of ActiveRecord and nothing more
Ruby Shell
tree: 163013ac4f

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gemified
LICENSE
README.textile
acts_as_fu.gemspec

README.textile

ACTS_AS-FU

Now you have no excuse for not test-driving your ActiveRecord
extending plugins.

Usage

In your spec_helper.rb (pretty sure this works with Test::Unit
too, I’ll leave you to figure it out though)

require ‘rubygems’ require ‘acts_as_fu’ require ‘spec’ Spec::Runner.configure do |config| config.include ActsAsFu end

Then in your specs:

describe “acts_as_gilmore_girls” do before(:each) do build_model :nerds do text :omg_omg_bio string :name string :favorite_scene def awesome?(show_name) show_name == “Gilmore Girls” end end end it “should require favorite scene” do nerd = Nerd.new :favorite_scene => nil nerd.should_not be_valid nerd.errors.on(:favorite_scene).should_not be_nil end it “should think gilmore girls is awesome” nerd = Nerd.new nerd.awesome?(“Gilmore Girls”).should be_true end it “has other stuff” do
  1. ETC!
    end
    end

The build_model method allows you to build an ActiveRecord on
the fly. It takes a block where you can specify columns and methods.
The table will be created in in an in-memory sqlite3 database. If
you need another adapter, this project ain’t for you. Sorry.

TODO

  • Maybe a couple more options… maybe.

NOTE

Despite the above example, watching Gilmore Girls doesn’t make you
a nerd. Probably.

© Copyright 2008 Pat Nakajima. All Rights Reserved.

Something went wrong with that request. Please try again.