Permalink
Browse files

Update README.md

  • Loading branch information...
1 parent 6f3e14e commit e7455b265343333529a02d8a9f8f7a98177e85fb @unders committed Apr 13, 2012
Showing with 59 additions and 1 deletion.
  1. +59 −1 README.md
View
@@ -19,7 +19,65 @@ Or install it yourself as:
## Usage
-TODO: Write usage instructions here
+### Rails, ActiveRecord and minitest
+
+
+1. Update Gemfile
+
+ group :development, :test do
+ gem 'letterpress', :require => 'letterpress/rails'
+ end
+
+2. Install the gem
+
+ $ bundle install
+
+3. Generate (test|spec)/blueprint.rb file
+
+ $ rails generate letterpress:install
+
+4. Update config/application.rb
+
+ config.generators do |g|
+ g.test_framework :mini_test, :spec => true, :fixture_replacement => :letterpress
+ end
+
+5. Generate a model object with its factory
+
+ $ rails generate model Comment post_id:integer body:text
+
+6. It adds to the end of file (test|spec)/blueprint.rb
+
+ class Comment < Blueprint(ProxyMethods)
+ default do
+ post_id { 1 }
+ body { "MyText" }
+ end
+ end
+
+7. Modify the generated blueprint according to your preferences
+
+ class Comment < Blueprint(ProxyMethods)
+ default do
+ post { Post.make.new }
+ body { "MyText" }
+ end
+ end
+
+8. Write tests in test/comment_test.rb
+
+ require "minitest_helper"
+
+ class CommentTest < MiniTest::Rails::Model
+ before do
+ @comment = Comment.make.new
+ end
+
+ it "must be valid" do
+ @comment.valid?.must_equal true
+ end
+ end
+
Compatibility

0 comments on commit e7455b2

Please sign in to comment.