[rspec-users] annotate_models plugin to annotate RSpec specs and fixture

Aníbal Rojas anibal at rojas.com.ve
Sun May 27 10:45:53 EDT 2007


I have found useful to have the table information associated to models
dispĺayed in the models and fixtures  files of my rails applications.
If you want to add this information to the spec_fixtures and specs add
the following patch to your plugin.

Index: vendor/plugins/annotate_models/lib/annotate_models.rb
===================================================================
--- vendor/plugins/annotate_models/lib/annotate_models.rb       (revision 45)
+++ vendor/plugins/annotate_models/lib/annotate_models.rb       (working copy)
@@ -1,7 +1,8 @@
 require "config/environment"

 MODEL_DIR   = File.join(RAILS_ROOT, "app/models")
-FIXTURE_DIR = File.join(RAILS_ROOT, "test/fixtures")
+SPEC_DIR    = File.join(RAILS_ROOT, "spec/models")
+FIXTURE_DIR = File.join(RAILS_ROOT, "spec/fixtures")

 module AnnotateModels

@@ -75,6 +76,9 @@
     model_file_name = File.join(MODEL_DIR, klass.name.underscore + ".rb")
     annotate_one_file(model_file_name, info)

+    spec_file_name = File.join(SPEC_DIR, klass.name.underscore + "_spec.rb")
+    annotate_one_file(spec_file_name, info)
+
     fixture_file_name = File.join(FIXTURE_DIR, klass.table_name + ".yml")
     annotate_one_file(fixture_file_name, info)
   end

--
Aníbal Rojas
http://www.rubycorner.com
http://www.hasmanydevelopers.com


More information about the rspec-users mailing list