nofxx-annotate 2.2.5 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ doc/*
3
+ rdoc/*
4
+ coverage/*
5
+ spec/debug.log
6
+ pkg/*
data/History.txt CHANGED
@@ -1,19 +1,4 @@
1
- == 1.0.2 2008-03-22
2
-
3
- * Add contributions from Michael Bumann (http://github.com/bumi)
4
- * added an option "position" to choose to put the annotation,
5
- * spec/fixtures now also get annotated
6
- * added a task to remove the annotations
7
- * these options can be specified from command line as -d and -p [before|after]
8
-
9
- == 1.0.3 2008-05-02
10
-
11
- * Add misc changes from Dustin Sallings and Henrik N
12
- * Remove trailing whitespace
13
- * More intuitive info messages
14
- * Update README file with update-to-date example
15
-
16
- == 2.0.0 2008-12-25
1
+ == 2.0 2009-02-03
17
2
 
18
3
  * Add annotate_models plugin fork additions
19
4
  * Annotates Rspec and Test Unit models
@@ -22,6 +7,21 @@
22
7
  * Add AnnotateRoutes rake task
23
8
  * Up gem structure to newgem defaults
24
9
 
10
+ == 1.0.4 2008-09-04
11
+
12
+ * Only update modified models since last run, thanks to sant0sk1
25
13
 
14
+ == 1.0.3 2008-05-02
26
15
 
16
+ * Add misc changes from Dustin Sallings and Henrik N
17
+ * Remove trailing whitespace
18
+ * More intuitive info messages
19
+ * Update README file with update-to-date example
27
20
 
21
+ == 1.0.2 2008-03-22
22
+
23
+ * Add contributions from Michael Bumann (http://github.com/bumi)
24
+ * added an option "position" to choose to put the annotation,
25
+ * spec/fixtures now also get annotated
26
+ * added a task to remove the annotations
27
+ * these options can be specified from command line as -d and -p [before|after]
data/README.rdoc CHANGED
@@ -1,17 +1,17 @@
1
1
  _
2
- /_| _/__/_
2
+ /_| _/__/_
3
3
  ( |/)/)()/(//(-
4
4
  ________________
5
5
 
6
6
 
7
- Add a comment summarizing the current schema to the bottom of each
8
- ActiveRecord model, test file and fixture.
7
+ Add a comment summarizing the current schema to the bottom of each
8
+ ActiveRecord model, fixture file.
9
+
9
10
  If you are using Object Daddy, it`ll annotate your example files too.
10
11
 
11
12
  # == Schema Info
12
- # Schema version: 20081001061831
13
13
  #
14
- # Table name: line_item
14
+ # Table name: line_items
15
15
  #
16
16
  # id :integer(11) not null, primary key
17
17
  # quantity :integer(11) not null
@@ -23,17 +23,16 @@ If you are using Object Daddy, it`ll annotate your example files too.
23
23
  class LineItem < ActiveRecord::Base
24
24
  belongs_to :product
25
25
  . . .
26
-
26
+
27
27
  Annotates geometrical columns, geom type and srid, when using SpatialAdapter or PostgisAdapter:
28
28
 
29
29
  # == Schema Info
30
- # Schema version: 20081213204851
31
30
  #
32
31
  # Table name: trips
33
32
  #
34
33
  # local :geometry point, 4326
35
34
  # path :geometry line_string, 4326
36
-
35
+
37
36
 
38
37
  == INSTALL
39
38
 
@@ -41,6 +40,28 @@ Annotates geometrical columns, geom type and srid, when using SpatialAdapter or
41
40
 
42
41
 
43
42
  == HOW TO USE:
43
+ =======
44
+ == Warning
45
+
46
+ Note that this code will blow away the initial/final comment
47
+ block in your models if it looks like it was previously added
48
+ by annotate models, so you don't want to add additional text
49
+ to an automatically created comment block.
50
+
51
+ * * Back up your model files before using... * *
52
+
53
+ == Install
54
+
55
+ From rubyforge:
56
+
57
+ sudo gem install annotate
58
+
59
+ From github:
60
+
61
+ gem sources -a http://gems.github.com
62
+ sudo gem install ctran-annotate
63
+
64
+ == Usage
44
65
 
45
66
  To annotate all your models:
46
67
 
@@ -51,7 +72,6 @@ To annotate routes.rb:
51
72
 
52
73
  annotate -r
53
74
 
54
-
55
75
  More:
56
76
 
57
77
  annotate -h
@@ -66,7 +86,7 @@ Annotate on the head of the file:
66
86
 
67
87
  annotate -p [before|after]
68
88
 
69
-
89
+
70
90
  == WARNING
71
91
 
72
92
  Note that this code will blow away the initial/final comment
@@ -75,7 +95,7 @@ by annotate models, so you don't want to add additional text
75
95
  to an automatically created comment block.
76
96
 
77
97
  * * Back up your model files before using... * *
78
-
98
+
79
99
  == LINKS
80
100
 
81
101
  * Factory Girl => http://github.com/thoughtbot/factory_girl (NOT IMPLEMENTED)
@@ -87,18 +107,31 @@ to an automatically created comment block.
87
107
 
88
108
  == TODO
89
109
 
90
- * Spec
110
+ * Spec
91
111
 
92
112
 
93
113
  == LICENSE:
114
+ =======
115
+ More options:
116
+
117
+ Usage: annotate [options]
118
+ -d, --delete Remove annotations from all model files
119
+ -p, --position [before|after] Place the annotations at the top (before) or the bottom (after) of the model file
120
+ -r, --routes Annotate routes.rb with the output of 'rake routes'
121
+ -v, --version Show the current version of this gem
122
+ -m, --show-migration Include the migration version number in the annotation
123
+ -i, --show-indexes List the table's database indexes in the annotation
124
+ --model-dir dir Annotate model files stored in dir rather than app/models
94
125
 
95
- Original code by:
126
+ == LICENSE:
96
127
 
97
- Dave Thomas -- Pragmatic Programmers, LLC
128
+ Released under the same license as Ruby. No Support. No Warranty.
98
129
 
99
- Refactored, improved and maintained by:
130
+ == Author:
100
131
 
101
- Marcos Piccinini ( http://github.com/nofxx/annotate )
132
+ Original code by:
133
+
134
+ Dave Thomas -- Pragmatic Programmers, LLC
102
135
 
103
136
  AnnotateModels mods by:
104
137
 
@@ -112,14 +145,22 @@ AnnotateRoutes originally by:
112
145
  == Forked from:
113
146
 
114
147
  http://github.com/ctran/annotate_models
115
-
148
+
116
149
 
117
150
  == Modifications
118
151
  - alex@pivotallabs.com
152
+ =======
153
+ Modifications by:
154
+
155
+ - Alex Chaffee - http://github.com/alexch - alex@pivotallabs.com
119
156
  - Cuong Tran - http://github.com/ctran
120
157
  - Jack Danger - http://github.com/JackDanger
121
158
  - Michael Bumann - http://github.com/bumi
122
159
  - Henrik Nyh - http://github.com/henrik
160
+ - Marcos Piccinini - http://github.com/nofxx
123
161
 
162
+ and many others that I may have missed to add.
124
163
 
125
- Released under the same license as Ruby. No Support. No Warranty.
164
+ == This fork
165
+
166
+ Marcos Piccinini ( http://github.com/nofxx/annotate )
data/Rakefile CHANGED
@@ -1,28 +1,48 @@
1
- %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
- require File.dirname(__FILE__) + '/lib/annotate'
3
-
4
- # Generate all the Rake tasks
5
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
- $hoe = Hoe.new('annotate', Annotate::VERSION) do |p|
7
- p.developer('Marcos Piccinini', 'x@nofxx.com')
8
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
- p.rubyforge_name = p.name
10
- p.url = "http://github.com/nofxx/annotate"
11
- p.summary = "Annotates Rails Models and Routes"
12
- p.description = "Annotates Rails Models and Routes"
13
-
14
- p.extra_dev_deps = [
15
- ['newgem', ">= #{::Newgem::VERSION}"]
16
- ]
17
-
18
- p.clean_globs |= %w[**/.DS_Store tmp *.log]
19
- path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
20
- p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
21
- p.rsync_args = '-av --delete --ignore-errors'
22
- end
23
-
24
- require 'newgem/tasks' # load /tasks/*.rake
25
- Dir['tasks/**/*.rake'].each { |t| load t }
26
-
27
- # TODO - want other tests/tasks run by default? Add them to the list
28
- # task :default => [:spec, :features]
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "annotate"
8
+ gem.summary = "Annotates Rails Models, routes, and others"
9
+ gem.email = "x@nofxx.com"
10
+ gem.homepage = "http://github.com/nofxx/annotate"
11
+ gem.authors = ['Cuong Tran',"Marcos Piccinini"]
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ end
14
+
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
+ end
18
+
19
+ require 'spec/rake/spectask'
20
+ Spec::Rake::SpecTask.new(:spec) do |spec|
21
+ spec.libs << 'lib' << 'spec'
22
+ spec.spec_files = FileList['spec/**/*_spec.rb']
23
+ end
24
+
25
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.pattern = 'spec/**/*_spec.rb'
28
+ spec.rcov = true
29
+ end
30
+
31
+
32
+ task :default => :spec
33
+
34
+ require 'rake/rdoctask'
35
+ Rake::RDocTask.new do |rdoc|
36
+ if File.exist?('VERSION.yml')
37
+ config = YAML.load(File.read('VERSION.yml'))
38
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
39
+ else
40
+ version = ""
41
+ end
42
+
43
+ rdoc.rdoc_dir = 'rdoc'
44
+ rdoc.title = "annotate #{version}"
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
48
+
data/bin/annotate CHANGED
@@ -7,15 +7,17 @@ task = :annotate_models
7
7
 
8
8
  OptionParser.new do |opts|
9
9
  opts.banner = "Usage: annotate [options]"
10
- opts.on('-d', '--delete') { task = :remove_annotation }
11
- opts.on('-p', '--position [before|after]', ['before', 'after']) { |p| ENV['position'] = p }
12
- opts.on('-r', '--routes') { task = :annotate_routes }
13
- opts.on('-v', '--version') { puts "Annotate v#{Annotate::VERSION}"; exit }
10
+ opts.on('-d', '--delete', "Remove annotations from all model files") { task = :remove_annotation }
11
+ opts.on('-p', '--position [before|after]', ['before', 'after'], "Place the annotations at the top (before) or the bottom (after) of the model file") { |p| ENV['position'] = p }
12
+ opts.on('-r', '--routes', "Annotate routes.rb with the output of 'rake routes'") { task = :annotate_routes }
13
+ opts.on('-v', '--version', "Show the current version of this gem") { puts "Annotate v#{Annotate::VERSION}"; exit }
14
+ opts.on('-m', '--show-migration', "Include the migration version number in the annotation") { ENV['include_version'] = "yes" }
15
+ opts.on('-i', '--show-indexes', "List the table's database indexes in the annotation") { ENV['show_indexes'] = "yes" }
16
+ opts.on('--model-dir dir', "Annotate model files stored in dir rather than app/models") {|dir| ENV['model_dir'] = dir }
14
17
  end.parse!
15
18
 
16
- begin
19
+ if Annotate.load_tasks
17
20
  Rake::Task[task].invoke
18
- #TODO: rescue only rake error
19
- rescue NameError => e
20
- puts "Can`t find Rake. Are we in a Rails folder?"
21
+ else
22
+ STDERR.puts "Can't find Rakefile. Are we in a Rails folder?"
21
23
  end
@@ -3,8 +3,6 @@ module AnnotateModels
3
3
  # Annotate Models plugin use this header
4
4
  COMPAT_PREFIX = "== Schema Info"
5
5
  PREFIX = "== Schema Information"
6
-
7
- MODEL_DIR = "app/models"
8
6
  FIXTURE_DIRS = ["test/fixtures","spec/fixtures"]
9
7
  # File.join for windows reverse bar compat?
10
8
  # I dont use windows, can`t test
@@ -12,7 +10,14 @@ module AnnotateModels
12
10
  SPEC_MODEL_DIR = File.join("spec", "models")
13
11
  # Object Daddy http://github.com/flogic/object_daddy/tree/master
14
12
  EXEMPLARS_DIR = File.join("spec", "exemplars")
15
-
13
+
14
+ def model_dir
15
+ @model_dir || "app/models"
16
+ end
17
+
18
+ def model_dir=(dir)
19
+ @model_dir = dir
20
+ end
16
21
 
17
22
  # Simple quoting for the default column value
18
23
  def quote(value)
@@ -32,14 +37,14 @@ module AnnotateModels
32
37
  # to create a comment block containing a line for
33
38
  # each column. The line contains the column name,
34
39
  # the type (and length), and any optional attributes
35
- def get_schema_info(klass, header)
40
+ def get_schema_info(klass, header, options = {})
36
41
  info = "# #{header}\n#\n"
37
42
  info << "# Table name: #{klass.table_name}\n#\n"
38
43
 
39
44
  max_size = klass.column_names.collect{|name| name.size}.max + 1
40
45
  klass.columns.each do |col|
41
46
  attrs = []
42
- attrs << "default(#{quote(col.default)})" if col.default
47
+ attrs << "default(#{quote(col.default)})" unless col.default.nil?
43
48
  attrs << "not null" unless col.null
44
49
  attrs << "primary key" if col.name == klass.primary_key
45
50
 
@@ -49,19 +54,36 @@ module AnnotateModels
49
54
  else
50
55
  col_type << "(#{col.limit})" if col.limit
51
56
  end
52
-
57
+
53
58
  # Check out if we got a geometric column
54
59
  # and print the type and SRID
55
60
  if col.respond_to?(:geometry_type)
56
61
  attrs << "#{col.geometry_type}, #{col.srid}"
57
- end
58
-
62
+ end
63
+
59
64
  info << sprintf("# %-#{max_size}.#{max_size}s:%-15.15s %s", col.name, col_type, attrs.join(", ")).rstrip + "\n"
60
65
  end
61
66
 
67
+ if options[:show_indexes]
68
+ info << get_index_info(klass)
69
+ end
70
+
62
71
  info << "#\n\n"
63
72
  end
64
73
 
74
+ def get_index_info(klass)
75
+ index_info = "#\n# Indexes\n#\n"
76
+
77
+ indexes = klass.connection.indexes(klass.table_name)
78
+ return "" if indexes.empty?
79
+
80
+ max_size = indexes.collect{|index| index.name.size}.max + 1
81
+ indexes.each do |index|
82
+ index_info << sprintf("# %-#{max_size}.#{max_size}s %s %s", index.name, "(#{index.columns.join(",")})", index.unique ? "UNIQUE" : "").rstrip + "\n"
83
+ end
84
+ return index_info
85
+ end
86
+
65
87
  # Add a schema block to a file. If the file already contains
66
88
  # a schema info block (a comment starting with "== Schema Information"), check if it
67
89
  # matches the block that is already there. If so, leave it be. If not, remove the old
@@ -69,10 +91,12 @@ module AnnotateModels
69
91
  # Returns true or false depending on whether the file was modified.
70
92
  #
71
93
  # === Options (opts)
72
- # :position<Symbol>:: where to place the annotated section in fixture or model file,
94
+ # :position<Symbol>:: where to place the annotated section in fixture or model file,
73
95
  # "before" or "after". Default is "before".
74
96
  # :position_in_class<Symbol>:: where to place the annotated section in model file
75
97
  # :position_in_fixture<Symbol>:: where to place the annotated section in fixture file
98
+ # :position_in_others<Symbol>:: where to place the annotated section in the rest of
99
+ # supported files
76
100
  #
77
101
  def annotate_one_file(file_name, info_block, options={})
78
102
  if File.exist?(file_name)
@@ -82,7 +106,7 @@ module AnnotateModels
82
106
  header = Regexp.new(/(^# Table name:.*?\n(#.*\n)*\n)/)
83
107
  old_header = old_content.match(header).to_s
84
108
  new_header = info_block.match(header).to_s
85
-
109
+
86
110
  if old_header == new_header
87
111
  false
88
112
  else
@@ -90,20 +114,20 @@ module AnnotateModels
90
114
  old_content.sub!(/^# #{COMPAT_PREFIX}.*?\n(#.*\n)*\n/, '')
91
115
 
92
116
  # Write it back
93
- new_content = options[:position] == "before" ? (info_block + old_content) : (old_content + "\n" + info_block)
117
+ new_content = options[:position].to_sym == :before ? (info_block + old_content) : (old_content + "\n" + info_block)
94
118
 
95
119
  File.open(file_name, "wb") { |f| f.puts new_content }
96
120
  true
97
121
  end
98
122
  end
99
123
  end
100
-
124
+
101
125
  def remove_annotation_of_file(file_name)
102
126
  if File.exist?(file_name)
103
127
  content = File.read(file_name)
104
128
 
105
129
  content.sub!(/^# #{COMPAT_PREFIX}.*?\n(#.*\n)*\n/, '')
106
-
130
+
107
131
  File.open(file_name, "wb") { |f| f.puts content }
108
132
  end
109
133
  end
@@ -116,10 +140,10 @@ module AnnotateModels
116
140
  # files were modified.
117
141
 
118
142
  def annotate(klass, file, header,options={})
119
- info = get_schema_info(klass, header)
143
+ info = get_schema_info(klass, header, options)
120
144
  annotated = false
121
145
  model_name = klass.name.underscore
122
- model_file_name = File.join(MODEL_DIR, file)
146
+ model_file_name = File.join(model_dir, file)
123
147
  if annotate_one_file(model_file_name, info, options.merge(
124
148
  :position=>(options[:position_in_class] || options[:position])))
125
149
  annotated = true
@@ -128,7 +152,7 @@ module AnnotateModels
128
152
  [
129
153
  File.join(UNIT_TEST_DIR, "#{model_name}_test.rb"), # test
130
154
  File.join(SPEC_MODEL_DIR, "#{model_name}_spec.rb"), # spec
131
- File.join(EXEMPLARS_DIR, "#{model_name}_exemplar.rb"), # Object Daddy
155
+ File.join(EXEMPLARS_DIR, "#{model_name}_exemplar.rb"), # Object Daddy
132
156
  ].each { |file| annotate_one_file(file, info) }
133
157
 
134
158
  FIXTURE_DIRS.each do |dir|
@@ -142,23 +166,24 @@ module AnnotateModels
142
166
  # command line arguments, they're assumed to be either
143
167
  # the underscore or CamelCase versions of model names.
144
168
  # Otherwise we take all the model files in the
145
- # app/models directory.
169
+ # model_dir directory.
146
170
  def get_model_files
147
171
  models = ARGV.dup
148
172
  models.shift
149
173
  models.reject!{|m| m.starts_with?("position=")}
150
174
  if models.empty?
151
- Dir.chdir(MODEL_DIR) do
175
+ Dir.chdir(model_dir) do
152
176
  models = Dir["**/*.rb"]
153
177
  end
154
178
  end
155
179
  models
156
180
  end
157
-
181
+
158
182
  # Retrieve the classes belonging to the model names we're asked to process
159
183
  # Check for namespaced models in subdirectories as well as models
160
184
  # in subdirectories without namespacing.
161
185
  def get_model_class(file)
186
+ require "#{model_dir}/#{file}" # this is for non-rails projects, which don't get Rails auto-require magic
162
187
  model = file.gsub(/\.rb$/, '').camelize
163
188
  parts = model.split('::')
164
189
  begin
@@ -174,9 +199,16 @@ module AnnotateModels
174
199
  # then pas it to the associated block
175
200
  def do_annotations(options={})
176
201
  header = PREFIX.dup
177
- version = ActiveRecord::Migrator.current_version rescue 0
178
- if version > 0
179
- header << "\n# Schema version: #{version}"
202
+
203
+ if options[:include_version]
204
+ version = ActiveRecord::Migrator.current_version rescue 0
205
+ if version > 0
206
+ header << "\n# Schema version: #{version}"
207
+ end
208
+ end
209
+
210
+ if options[:model_dir]
211
+ self.model_dir = options[:model_dir]
180
212
  end
181
213
 
182
214
  annotated = []
@@ -189,7 +221,7 @@ module AnnotateModels
189
221
  end
190
222
  end
191
223
  rescue Exception => e
192
- puts "Unable to annotate #{file}: #{e.message}"
224
+ puts "Unable to annotate #{file}: #{e.message} (#{e.backtrace.first})"
193
225
  end
194
226
  end
195
227
  if annotated.empty?
@@ -198,18 +230,23 @@ module AnnotateModels
198
230
  puts "Annotated (#{annotated.length}): #{annotated.join(', ')}"
199
231
  end
200
232
  end
201
-
202
- def remove_annotations
233
+
234
+ def remove_annotations(options={})
235
+ p options
236
+ if options[:model_dir]
237
+ puts "removing"
238
+ self.model_dir = options[:model_dir]
239
+ end
203
240
  deannotated = []
204
241
  get_model_files.each do |file|
205
242
  begin
206
243
  klass = get_model_class(file)
207
244
  if klass < ActiveRecord::Base && !klass.abstract_class?
208
245
  deannotated << klass
209
-
210
- model_file_name = File.join(MODEL_DIR, file)
246
+
247
+ model_file_name = File.join(model_dir, file)
211
248
  remove_annotation_of_file(model_file_name)
212
-
249
+
213
250
  FIXTURE_DIRS.each do |dir|
214
251
  fixture_file_name = File.join(dir,klass.table_name + ".yml")
215
252
  remove_annotation_of_file(fixture_file_name) if File.exist?(fixture_file_name)
data/lib/annotate.rb CHANGED
@@ -2,13 +2,13 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module Annotate
5
- VERSION = '2.2.5'
5
+ def self.load_tasks
6
+ if File.exists?('Rakefile')
7
+ load 'Rakefile'
8
+ Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
9
+ return true
10
+ else
11
+ return false
12
+ end
13
+ end
6
14
  end
7
-
8
- begin
9
- load 'Rakefile'
10
- Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
11
- rescue LoadError => e
12
- nil
13
- end
14
-
@@ -2,13 +2,18 @@ desc "Add schema information (as comments) to model and fixture files"
2
2
  task :annotate_models => :environment do
3
3
  require 'annotate/annotate_models'
4
4
  options={}
5
- options[:position_in_class] = ENV['position_in_class'] || ENV['position']
6
- options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position']
5
+ options[:position_in_class] = ENV['position_in_class'] || ENV['position'] || :before
6
+ options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position'] || :before
7
+ options[:show_indexes] = ENV['show_indexes']
8
+ options[:model_dir] = ENV['model_dir']
9
+ options[:include_version] = ENV['include_version']
7
10
  AnnotateModels.do_annotations(options)
8
11
  end
9
12
 
10
13
  desc "Remove schema information from model and fixture files"
11
14
  task :remove_annotation => :environment do
12
- require 'annotate_models'
13
- AnnotateModels.remove_annotations
15
+ require 'annotate/annotate_models'
16
+ options={}
17
+ options[:model_dir] = ENV['model_dir']
18
+ AnnotateModels.remove_annotations(options)
14
19
  end
@@ -27,8 +27,16 @@ describe AnnotateModels do
27
27
  :columns => [
28
28
  mock_column(:type => "integer", :default => nil, :null => false, :name => "id", :limit => nil),
29
29
  mock_column(:type => "string", :default => nil, :null => false, :name => "name", :limit => 50)
30
- ]), "Hello").should eql("# Hello\n#\n# Table name: users\n#\n# id :integer not null, primary key\n# id :integer not null, primary key\n#\n\n")
31
-
30
+ ]), "Schema Info").should eql(<<-EOS)
31
+ # Schema Info
32
+ #
33
+ # Table name: users
34
+ #
35
+ # id :integer not null, primary key
36
+ # id :integer not null, primary key
37
+ #
38
+
39
+ EOS
32
40
 
33
41
  end
34
42
 
@@ -25,7 +25,7 @@ describe AnnotateRoutes do
25
25
  File.should_receive(:exists?).with("config/routes.rb").and_return(true)
26
26
  AnnotateRoutes.should_receive(:`).with("rake routes").and_return("bad line\ngood line")
27
27
  File.should_receive(:open).with("config/routes.rb", "wb").and_yield(mock_file)
28
- AnnotateRoutes.should_receive(:puts).with("Route map annotated.")
28
+ AnnotateRoutes.should_receive(:puts).with("Route file annotated.")
29
29
  end
30
30
 
31
31
  it "should annotate and add a newline!" do
@@ -1,9 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  describe Annotate do
4
-
5
- it "should have a version" do
6
- Annotate::VERSION.should be_instance_of(String)
4
+
5
+ it "should have more tests..heh" do
7
6
  end
8
-
7
+
9
8
  end