Commit 9e3b6385 by Marcos Piccinini

merge ctran new stuff

parents 3d1d6a1c 8ecd23ee
== 1.0.2 2008-03-22
* Add contributions from Michael Bumann (http://github.com/bumi)
* added an option "position" to choose to put the annotation,
* spec/fixtures now also get annotated
* added a task to remove the annotations
* these options can be specified from command line as -d and -p [before|after]
== 1.0.3 2008-05-02
* Add misc changes from Dustin Sallings and Henrik N
* Remove trailing whitespace
* More intuitive info messages
* Update README file with update-to-date example
== 2.0.0 2008-12-25
== 2.0 2009-02-03
* Add annotate_models plugin fork additions
* Annotates Rspec and Test Unit models
......@@ -22,6 +7,21 @@
* Add AnnotateRoutes rake task
* Up gem structure to newgem defaults
== 1.0.4 2008-09-04
* Only update modified models since last run, thanks to sant0sk1
== 1.0.3 2008-05-02
* Add misc changes from Dustin Sallings and Henrik N
* Remove trailing whitespace
* More intuitive info messages
* Update README file with update-to-date example
== 1.0.2 2008-03-22
* Add contributions from Michael Bumann (http://github.com/bumi)
* added an option "position" to choose to put the annotation,
* spec/fixtures now also get annotated
* added a task to remove the annotations
* these options can be specified from command line as -d and -p [before|after]
The MIT License
Copyright (c) 2008 Dave Thomas
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
History.txt
License.txt
Manifest.txt
README.rdoc
Rakefile
annotate.gemspec
bin/annotate
lib/annotate.rb
lib/annotate/annotate_models.rb
lib/annotate/annotate_routes.rb
lib/tasks/annotate_models.rake
lib/tasks/annotate_routes.rake
script/console
script/destroy
script/generate
setup.rb
spec/annotate/annotate_models_spec.rb
spec/annotate/annotate_routes_spec.rb
spec/annotate_spec.rb
spec/spec.opts
spec/spec_helper.rb
tasks/rspec.rake
History.txt
License.txt
Manifest.txt
README.rdoc
Rakefile
annotate.gemspec
bin/annotate
lib/annotate.rb
lib/annotate/annotate_models.rb
lib/annotate/annotate_routes.rb
lib/tasks/annotate_models.rake
lib/tasks/annotate_routes.rake
script/console
script/destroy
script/generate
setup.rb
spec/annotate/annotate_models_spec.rb
spec/annotate/annotate_routes_spec.rb
spec/annotate_spec.rb
spec/spec.opts
spec/spec_helper.rb
tasks/rspec.rake
History.txt
License.txt
Manifest.txt
README.rdoc
Rakefile
annotate.gemspec
bin/annotate
lib/annotate.rb
lib/annotate/annotate_models.rb
lib/annotate/annotate_routes.rb
lib/tasks/annotate_models.rake
lib/tasks/annotate_routes.rake
script/console
script/destroy
script/generate
setup.rb
spec/annotate/annotate_models_spec.rb
spec/annotate/annotate_routes_spec.rb
spec/annotate_spec.rb
spec/spec.opts
spec/spec_helper.rb
tasks/rspec.rake
_
/_| _/__/_
/_| _/__/_
( |/)/)()/(//(-
________________
Add a comment summarizing the current schema to the bottom of each
ActiveRecord model, test file and fixture.
Add a comment summarizing the current schema to the bottom of each
ActiveRecord model, fixture file.
If you are using Object Daddy, it`ll annotate your example files too.
# == Schema Info
# Schema version: 20081001061831
#
# Table name: line_item
# Table name: line_items
#
# id :integer(11) not null, primary key
# quantity :integer(11) not null
......@@ -23,17 +23,16 @@ If you are using Object Daddy, it`ll annotate your example files too.
class LineItem < ActiveRecord::Base
belongs_to :product
. . .
Annotates geometrical columns, geom type and srid, when using SpatialAdapter or PostgisAdapter:
# == Schema Info
# Schema version: 20081213204851
#
# Table name: trips
#
# local :geometry point, 4326
# path :geometry line_string, 4326
== INSTALL
......@@ -41,6 +40,28 @@ Annotates geometrical columns, geom type and srid, when using SpatialAdapter or
== HOW TO USE:
=======
== Warning
Note that this code will blow away the initial/final comment
block in your models if it looks like it was previously added
by annotate models, so you don't want to add additional text
to an automatically created comment block.
* * Back up your model files before using... * *
== Install
From rubyforge:
sudo gem install annotate
From github:
gem sources -a http://gems.github.com
sudo gem install ctran-annotate
== Usage
To annotate all your models:
......@@ -51,7 +72,6 @@ To annotate routes.rb:
annotate -r
More:
annotate -h
......@@ -66,7 +86,7 @@ Annotate on the head of the file:
annotate -p [before|after]
== WARNING
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
to an automatically created comment block.
* * Back up your model files before using... * *
== LINKS
* Factory Girl => http://github.com/thoughtbot/factory_girl (NOT IMPLEMENTED)
......@@ -87,18 +107,31 @@ to an automatically created comment block.
== TODO
* Spec
* Spec
== LICENSE:
=======
More options:
Usage: annotate [options]
-d, --delete Remove annotations from all model files
-p, --position [before|after] Place the annotations at the top (before) or the bottom (after) of the model file
-r, --routes Annotate routes.rb with the output of 'rake routes'
-v, --version Show the current version of this gem
-m, --show-migration Include the migration version number in the annotation
-i, --show-indexes List the table's database indexes in the annotation
--model-dir dir Annotate model files stored in dir rather than app/models
Original code by:
== LICENSE:
Dave Thomas -- Pragmatic Programmers, LLC
Released under the same license as Ruby. No Support. No Warranty.
Refactored, improved and maintained by:
== Author:
Marcos Piccinini ( http://github.com/nofxx/annotate )
Original code by:
Dave Thomas -- Pragmatic Programmers, LLC
AnnotateModels mods by:
......@@ -112,14 +145,22 @@ AnnotateRoutes originally by:
== Forked from:
http://github.com/ctran/annotate_models
== Modifications
- alex@pivotallabs.com
=======
Modifications by:
- Alex Chaffee - http://github.com/alexch - alex@pivotallabs.com
- Cuong Tran - http://github.com/ctran
- Jack Danger - http://github.com/JackDanger
- Michael Bumann - http://github.com/bumi
- Henrik Nyh - http://github.com/henrik
- Marcos Piccinini - http://github.com/nofxx
and many others that I may have missed to add.
Released under the same license as Ruby. No Support. No Warranty.
== This fork
Marcos Piccinini ( http://github.com/nofxx/annotate )
\ No newline at end of file
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
require File.dirname(__FILE__) + '/lib/annotate'
# Generate all the Rake tasks
# Run 'rake -T' to see list of generated tasks (from gem root directory)
$hoe = Hoe.new('annotate', Annotate::VERSION) do |p|
p.developer('Marcos Piccinini', 'x@nofxx.com')
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
p.rubyforge_name = p.name
p.url = "http://github.com/nofxx/annotate"
p.summary = "Annotates Rails Models and Routes"
p.description = "Annotates Rails Models and Routes"
p.extra_dev_deps = [
['newgem', ">= #{::Newgem::VERSION}"]
]
p.clean_globs |= %w[**/.DS_Store tmp *.log]
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
p.rsync_args = '-av --delete --ignore-errors'
end
require 'newgem/tasks' # load /tasks/*.rake
Dir['tasks/**/*.rake'].each { |t| load t }
# TODO - want other tests/tasks run by default? Add them to the list
# task :default => [:spec, :features]
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
require File.dirname(__FILE__) + '/lib/annotate'
# Generate all the Rake tasks
# Run 'rake -T' to see list of generated tasks (from gem root directory)
$hoe = Hoe.new('annotate', Annotate::VERSION) do |p|
p.developer('Cuong Tran', 'ctran@pragmaquest.com')
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
p.rubyforge_name = 'annotate-models'
p.url = "http://github.com/ctran/annotate_models"
p.summary = "Annotates Rails Models, routes, and others"
p.description = "Annotates Rails Models, routes, and others"
p.extra_dev_deps = [
['newgem', ">= #{::Newgem::VERSION}"]
]
p.clean_globs |= %w[**/.DS_Store tmp *.log]
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
p.rsync_args = '-av --delete --ignore-errors'
end
require 'newgem/tasks' # load /tasks/*.rake
Dir['tasks/**/*.rake'].each { |t| load t }
# TODO - want other tests/tasks run by default? Add them to the list
# task :default => [:spec, :features]
......@@ -2,6 +2,7 @@
Gem::Specification.new do |s|
s.name = %q{annotate}
<<<<<<< HEAD:annotate.gemspec
s.version = "2.2.7"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
......@@ -20,12 +21,33 @@ Gem::Specification.new do |s|
s.rubyforge_project = %q{annotate}
s.rubygems_version = %q{1.3.1}
s.summary = %q{Annotates Rails Models and Routes}
=======
s.version = "2.0.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Cuong Tran"]
s.date = %q{2009-05-06}
s.default_executable = %q{annotate}
s.description = %q{Annotates Rails Models, routes, and others}
s.email = ["ctran@pragmaquest.com"]
s.executables = ["annotate"]
s.extra_rdoc_files = ["History.txt", "README.rdoc"]
s.files = ["History.txt", "README.rdoc", "Rakefile", "annotate_models.gemspec", "bin/annotate", "lib/annotate.rb", "lib/annotate/annotate_models.rb", "lib/annotate/annotate_routes.rb", "lib/tasks/annotate_models.rake", "lib/tasks/annotate_routes.rake"]
s.has_rdoc = true
s.homepage = %q{http://github.com/ctran/annotate_models}
s.rdoc_options = ["--main", "README.rdoc"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{annotate-models}
s.rubygems_version = %q{1.3.1}
s.summary = %q{Annotates Rails Models, routes, and others}
>>>>>>> ctran/master:annotate.gemspec
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
<<<<<<< HEAD:annotate.gemspec
s.add_development_dependency(%q<newgem>, [">= 1.3.0"])
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
else
......@@ -34,6 +56,16 @@ Gem::Specification.new do |s|
end
else
s.add_dependency(%q<newgem>, [">= 1.3.0"])
=======
s.add_development_dependency(%q<newgem>, [">= 1.4.1"])
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
else
s.add_dependency(%q<newgem>, [">= 1.4.1"])
s.add_dependency(%q<hoe>, [">= 1.8.0"])
end
else
s.add_dependency(%q<newgem>, [">= 1.4.1"])
>>>>>>> ctran/master:annotate.gemspec
s.add_dependency(%q<hoe>, [">= 1.8.0"])
end
end
./annotate.gemspec
\ No newline at end of file
......@@ -7,15 +7,17 @@ task = :annotate_models
OptionParser.new do |opts|
opts.banner = "Usage: annotate [options]"
opts.on('-d', '--delete') { task = :remove_annotation }
opts.on('-p', '--position [before|after]', ['before', 'after']) { |p| ENV['position'] = p }
opts.on('-r', '--routes') { task = :annotate_routes }
opts.on('-v', '--version') { puts "Annotate v#{Annotate::VERSION}"; exit }
opts.on('-d', '--delete', "Remove annotations from all model files") { task = :remove_annotation }
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 }
opts.on('-r', '--routes', "Annotate routes.rb with the output of 'rake routes'") { task = :annotate_routes }
opts.on('-v', '--version', "Show the current version of this gem") { puts "Annotate v#{Annotate::VERSION}"; exit }
opts.on('-m', '--show-migration', "Include the migration version number in the annotation") { ENV['include_version'] = "yes" }
opts.on('-i', '--show-indexes', "List the table's database indexes in the annotation") { ENV['show_indexes'] = "yes" }
opts.on('--model-dir dir', "Annotate model files stored in dir rather than app/models") {|dir| ENV['model_dir'] = dir }
end.parse!
begin
if Annotate.load_tasks
Rake::Task[task].invoke
#TODO: rescue only rake error
rescue NameError => e
puts "Can`t find Rake. Are we in a Rails folder?"
else
STDERR.puts "Can't find Rakefile. Are we in a Rails folder?"
end
......@@ -2,13 +2,15 @@ $:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
module Annotate
VERSION = '2.2.7'
end
VERSION = '2.3'
begin
load 'Rakefile'
Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
rescue LoadError => e
nil
def self.load_tasks
if File.exists?('Rakefile')
load 'Rakefile'
Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
return true
else
return false
end
end
end
......@@ -3,8 +3,6 @@ module AnnotateModels
# Annotate Models plugin use this header
COMPAT_PREFIX = "== Schema Info"
PREFIX = "== Schema Information"
MODEL_DIR = "app/models"
FIXTURE_DIRS = ["test/fixtures","spec/fixtures"]
# File.join for windows reverse bar compat?
# I dont use windows, can`t test
......@@ -12,7 +10,14 @@ module AnnotateModels
SPEC_MODEL_DIR = File.join("spec", "models")
# Object Daddy http://github.com/flogic/object_daddy/tree/master
EXEMPLARS_DIR = File.join("spec", "exemplars")
def model_dir
@model_dir || "app/models"
end
def model_dir=(dir)
@model_dir = dir
end
# Simple quoting for the default column value
def quote(value)
......@@ -32,7 +37,7 @@ module AnnotateModels
# to create a comment block containing a line for
# each column. The line contains the column name,
# the type (and length), and any optional attributes
def get_schema_info(klass, header)
def get_schema_info(klass, header, options = {})
info = "# #{header}\n#\n"
info << "# Table name: #{klass.table_name}\n#\n"
......@@ -49,19 +54,36 @@ module AnnotateModels
else
col_type << "(#{col.limit})" if col.limit
end
# Check out if we got a geometric column
# and print the type and SRID
if col.respond_to?(:geometry_type)
attrs << "#{col.geometry_type}, #{col.srid}"
end
end
info << sprintf("# %-#{max_size}.#{max_size}s:%-15.15s %s", col.name, col_type, attrs.join(", ")).rstrip + "\n"
end
if options[:show_indexes]
info << get_index_info(klass)
end
info << "#\n\n"
end
def get_index_info(klass)
index_info = "#\n# Indexes\n#\n"
indexes = klass.connection.indexes(klass.table_name)
return "" if indexes.empty?
max_size = indexes.collect{|index| index.name.size}.max + 1
indexes.each do |index|
index_info << sprintf("# %-#{max_size}.#{max_size}s %s %s", index.name, "(#{index.columns.join(",")})", index.unique ? "UNIQUE" : "").rstrip + "\n"
end
return index_info
end
# Add a schema block to a file. If the file already contains
# a schema info block (a comment starting with "== Schema Information"), check if it
# matches the block that is already there. If so, leave it be. If not, remove the old
......@@ -69,7 +91,7 @@ module AnnotateModels
# Returns true or false depending on whether the file was modified.
#
# === Options (opts)
# :position<Symbol>:: where to place the annotated section in fixture or model file,
# :position<Symbol>:: where to place the annotated section in fixture or model file,
# "before" or "after". Default is "before".
# :position_in_class<Symbol>:: where to place the annotated section in model file
# :position_in_fixture<Symbol>:: where to place the annotated section in fixture file
......@@ -84,7 +106,7 @@ module AnnotateModels
header = Regexp.new(/(^# Table name:.*?\n(#.*\n)*\n)/)
old_header = old_content.match(header).to_s
new_header = info_block.match(header).to_s
if old_header == new_header
false
else
......@@ -92,20 +114,20 @@ module AnnotateModels
old_content.sub!(/^# #{COMPAT_PREFIX}.*?\n(#.*\n)*\n/, '')
# Write it back
new_content = options[:position] == "before" ? (info_block + old_content) : (old_content + "\n" + info_block)
new_content = ((options[:position] || :before).to_sym == :before) ? (info_block + old_content) : (old_content + "\n" + info_block)
File.open(file_name, "wb") { |f| f.puts new_content }
true
end
end
end
def remove_annotation_of_file(file_name)
if File.exist?(file_name)
content = File.read(file_name)
content.sub!(/^# #{COMPAT_PREFIX}.*?\n(#.*\n)*\n/, '')
File.open(file_name, "wb") { |f| f.puts content }
end
end
......@@ -118,10 +140,10 @@ module AnnotateModels
# files were modified.
def annotate(klass, file, header,options={})
info = get_schema_info(klass, header)
info = get_schema_info(klass, header, options)
annotated = false
model_name = klass.name.underscore
model_file_name = File.join(MODEL_DIR, file)
model_file_name = File.join(model_dir, file)
if annotate_one_file(model_file_name, info, options.merge(
:position=>(options[:position_in_class] || options[:position])))
annotated = true
......@@ -130,8 +152,8 @@ module AnnotateModels
[
File.join(UNIT_TEST_DIR, "#{model_name}_test.rb"), # test
File.join(SPEC_MODEL_DIR, "#{model_name}_spec.rb"), # spec
File.join(EXEMPLARS_DIR, "#{model_name}_exemplar.rb"), # Object Daddy
].each { |file| annotate_one_file(file, info, options.merge(:position=>(options[:position_in_others] || options[:position]))) }
File.join(EXEMPLARS_DIR, "#{model_name}_exemplar.rb"), # Object Daddy
].each { |file| annotate_one_file(file, info) }
FIXTURE_DIRS.each do |dir|
fixture_file_name = File.join(dir,klass.table_name + ".yml")
......@@ -144,23 +166,24 @@ module AnnotateModels
# command line arguments, they're assumed to be either
# the underscore or CamelCase versions of model names.
# Otherwise we take all the model files in the
# app/models directory.
# model_dir directory.
def get_model_files
models = ARGV.dup
models.shift
models.reject!{|m| m.starts_with?("position=")}
if models.empty?
Dir.chdir(MODEL_DIR) do
Dir.chdir(model_dir) do
models = Dir["**/*.rb"]
end
end
models
end
# Retrieve the classes belonging to the model names we're asked to process
# Check for namespaced models in subdirectories as well as models
# in subdirectories without namespacing.
def get_model_class(file)
require "#{model_dir}/#{file}" # this is for non-rails projects, which don't get Rails auto-require magic
model = file.gsub(/\.rb$/, '').camelize
parts = model.split('::')
begin
......@@ -176,9 +199,16 @@ module AnnotateModels
# then pas it to the associated block
def do_annotations(options={})
header = PREFIX.dup
version = ActiveRecord::Migrator.current_version rescue 0
if version > 0
header << "\n# Schema version: #{version}"
if options[:include_version]
version = ActiveRecord::Migrator.current_version rescue 0
if version > 0
header << "\n# Schema version: #{version}"
end
end
if options[:model_dir]
self.model_dir = options[:model_dir]
end
annotated = []
......@@ -191,7 +221,7 @@ module AnnotateModels
end
end
rescue Exception => e
puts "Unable to annotate #{file}: #{e.message}"
puts "Unable to annotate #{file}: #{e.message} (#{e.backtrace.first})"
end
end
if annotated.empty?
......@@ -200,18 +230,23 @@ module AnnotateModels
puts "Annotated (#{annotated.length}): #{annotated.join(', ')}"
end
end
def remove_annotations
def remove_annotations(options={})
p options
if options[:model_dir]
puts "removing"
self.model_dir = options[:model_dir]
end
deannotated = []
get_model_files.each do |file|
begin
klass = get_model_class(file)
if klass < ActiveRecord::Base && !klass.abstract_class?
deannotated << klass
model_file_name = File.join(MODEL_DIR, file)
model_file_name = File.join(model_dir, file)
remove_annotation_of_file(model_file_name)
FIXTURE_DIRS.each do |dir|
fixture_file_name = File.join(dir,klass.table_name + ".yml")
remove_annotation_of_file(fixture_file_name) if File.exist?(fixture_file_name)
......
......@@ -2,14 +2,18 @@ desc "Add schema information (as comments) to model and fixture files"
task :annotate_models => :environment do
require 'annotate/annotate_models'
options={}
options[:position_in_class] = ENV['position_in_class'] || ENV['position']
options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position']
options[:position_in_others] = ENV['position_in_others'] || ENV['position']
options[:position_in_class] = ENV['position_in_class'] || ENV['position'] || :before
options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position'] || :before
options[:show_indexes] = ENV['show_indexes']
options[:model_dir] = ENV['model_dir']
options[:include_version] = ENV['include_version']
AnnotateModels.do_annotations(options)
end
desc "Remove schema information from model and fixture files"
task :remove_annotation => :environment do
require 'annotate_models'
AnnotateModels.remove_annotations
require 'annotate/annotate_models'
options={}
options[:model_dir] = ENV['model_dir']
AnnotateModels.remove_annotations(options)
end
......@@ -5,6 +5,11 @@ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
libs = " -r irb/completion"
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
<<<<<<< HEAD:script/console
libs << " -r #{File.dirname(__FILE__) + '/../lib/annotate.rb'}"
puts "Loading annotate gem"
=======
libs << " -r #{File.dirname(__FILE__) + '/../lib/annotate_models.rb'}"
puts "Loading annotate_models gem"
>>>>>>> ctran/master:script/console
exec "#{irb} #{libs} --simple-prompt"
\ No newline at end of file
......@@ -27,8 +27,16 @@ describe AnnotateModels do
:columns => [
mock_column(:type => "integer", :default => nil, :null => false, :name => "id", :limit => nil),
mock_column(:type => "string", :default => nil, :null => false, :name => "name", :limit => 50)
]), "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")
]), "Schema Info").should eql(<<-EOS)
# Schema Info
#
# Table name: users
#
# id :integer not null, primary key
# id :integer not null, primary key
#
EOS
end
......
......@@ -25,7 +25,7 @@ describe AnnotateRoutes do
File.should_receive(:exists?).with("config/routes.rb").and_return(true)
AnnotateRoutes.should_receive(:`).with("rake routes").and_return("bad line\ngood line")
File.should_receive(:open).with("config/routes.rb", "wb").and_yield(mock_file)
AnnotateRoutes.should_receive(:puts).with("Route map annotated.")
AnnotateRoutes.should_receive(:puts).with("Route file annotated.")
end
it "should annotate and add a newline!" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment