Skip to content
Browse files

Updated README

  • Loading branch information...
1 parent 020c16a commit bb5c42c13ec434b9069d4ba2e2dd6318055d743e @nakajima committed
Showing with 92 additions and 105 deletions.
  1. +92 −0 README.md
  2. +0 −105 README.textile
View
92 README.md
@@ -0,0 +1,92 @@
+# 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
+
+ validates_presence_of :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
+ # ETC!
+ end
+ end
+
+The `build_model` method allows you to build an ActiveRecord model on
+the fly. It takes a block where you can specify columns and methods.
+
+#### Single Table Inheritance
+
+If you want to create a model that's a subclass of another, you can
+use the `:superclass` option:
+
+ build_model(:assets) do
+ string :type
+ string :name
+ named_scope :pictures, :conditions => { :type => "Picture" }
+ end
+
+ build_model(:pictures, :superclass => Asset)
+
+The `Picture` model will then be a subclass of the `Asset` model.
+
+#### Custom database configuration
+
+If the in-memory sqlite3 database doesn't suit your needs, you can
+specify an alternative configuration with the `ActsAsFu.connect!` method:
+
+ ActsAsFu.connect! \
+ :adapter => 'mysql',
+ :database => 'some-db',
+ :username => 'some-user',
+ :password => 'some-password',
+ :socket => '/path/to/mysql.sock'
+
+### Install
+
+ $ gem install nakajima-acts_as_fu --source=http://gems.github.com
+
+TODO
+
+Provide the ability to create **multiple** connections (thanks to Pivotal for the idea):
+
+ ActsAsFu.connections[:sqlite3] # or something
+
+(c) Copyright 2008-2009 Pat Nakajima. All Rights Reserved.
View
105 README.textile
@@ -1,105 +0,0 @@
-h2. Changes by Pivotal:
-
-In the original implementation, one could not truly use two different database connections: ActsAsFu would use ActiveRecord::Base's connection, or setting ActsAsFu's connection would change ActiveRecord::Base's connection globally, breaking other tests.
-
-To fix this, we created ActsAsFu::Connection, an abstract class that extends from ActiveRecord::Base. This segregates ActsAsFu's database connection (to whatever database technology) from ActiveRecord::Base, and thus from the rest of the project.
-
-<hr/>
-
-h1. ACTS-AS-FU
-
-Now you have no excuse for not test-driving your ActiveRecord
-extending plugins.
-
-h3. 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:
-
-<pre>
-describe "acts_as_gilmore_girls" do
- before(:each) do
- build_model :nerds do
- text :omg_omg_bio
- string :name
- string :favorite_scene
-
- validates_presence_of :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
- # ETC!
- end
-end
-</pre>
-
-The @build_model@ method allows you to build an ActiveRecord model on
-the fly. It takes a block where you can specify columns and methods.
-
-h4. Single Table Inheritance
-
-If you want to create a model that's a subclass of another, you can
-use the @:superclass@ option:
-
- build_model(:assets) do
- string :type
- string :name
- named_scope :pictures, :conditions => { :type => "Picture" }
- end
-
- build_model(:pictures, :superclass => Asset)
-
-The @Picture@ model will then be a subclass of the @Asset@ model.
-
-h4. Custom database configuration
-
-If the in-memory sqlite3 database doesn't suit your needs, you can
-specify an alternative configuration with the @ActsAsFu.connect!@ method:
-
- ActsAsFu.connect! \
- :adapter => 'mysql',
- :database => 'some-db',
- :username => 'some-user',
- :password => 'some-password',
- :socket => '/path/to/mysql.sock'
-
-h3. Install
-
- gem install nakajima-acts_as_fu --source=http://gems.github.com
-
-TODO
-
-* Maybe a couple more options... maybe.
-
-NOTE
-
-Despite the above example, watching Gilmore Girls doesn't make you
-a nerd. Probably.
-
-(c) Copyright 2008 Pat Nakajima. All Rights Reserved.

0 comments on commit bb5c42c

Please sign in to comment.
Something went wrong with that request. Please try again.