Commit 7e2cd422 by Alex Chaffee

renamed script back to annotate; added rails integration test

parent 9340715f
...@@ -7,6 +7,7 @@ group :development do ...@@ -7,6 +7,7 @@ group :development do
gem 'rspec' gem 'rspec'
gem 'wrong', '>=0.6.2' gem 'wrong', '>=0.6.2'
gem 'rdoc' gem 'rdoc'
gem 'files', '>=0.2.1'
end end
gem 'activesupport', '>= 3.0.0', :require => nil gem 'activesupport', '>= 3.0.0', :require => nil
...@@ -66,7 +66,6 @@ ...@@ -66,7 +66,6 @@
* Annotates thoughtbot's factory_girl factories (test/factories/<model>_factory.rb) * Annotates thoughtbot's factory_girl factories (test/factories/<model>_factory.rb)
* Move default annotation position back to top * Move default annotation position back to top
>>>>>>> mrjoy
== 2.4.0 2009-12-13 == 2.4.0 2009-12-13
......
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'optparse' require 'optparse'
require 'annotate'
require 'rake/dsl_definition' require 'rake/dsl_definition'
require 'rake' require 'rake'
begin
require "annotate"
rescue LoadError
here = File.expand_path(File.dirname __FILE__)
$:<< "#{here}/../lib"
require "annotate"
end
task = :annotate_models task = :annotate_models
......
---
BUNDLE_BIN: /private/var/folders/l2/5s19rxtc8v57nw008k8dpy2h0000gp/T/files_1332801849_945/rails-2.3
source :rubygems
gem "rails", "~>2.3.14"
gem "sqlite3"
GEM
remote: http://rubygems.org/
specs:
actionmailer (2.3.14)
actionpack (= 2.3.14)
actionpack (2.3.14)
activesupport (= 2.3.14)
rack (~> 1.1.0)
activerecord (2.3.14)
activesupport (= 2.3.14)
activeresource (2.3.14)
activesupport (= 2.3.14)
activesupport (2.3.14)
rack (1.1.3)
rails (2.3.14)
actionmailer (= 2.3.14)
actionpack (= 2.3.14)
activerecord (= 2.3.14)
activeresource (= 2.3.14)
activesupport (= 2.3.14)
rake (>= 0.8.3)
rake (0.9.2.2)
sqlite3 (1.3.5)
PLATFORMS
ruby
DEPENDENCIES
rails (~> 2.3.14)
sqlite3
source :rubygems
gem 'rails', "~>3.2.2"
gem "sqlite3"
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.2)
actionpack (= 3.2.2)
mail (~> 2.4.0)
actionpack (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
activerecord (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
json (1.6.6)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.18)
multi_json (1.1.0)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.2)
actionmailer (= 3.2.2)
actionpack (= 3.2.2)
activerecord (= 3.2.2)
activeresource (= 3.2.2)
activesupport (= 3.2.2)
bundler (~> 1.0)
railties (= 3.2.2)
railties (3.2.2)
actionpack (= 3.2.2)
activesupport (= 3.2.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.32)
PLATFORMS
ruby
DEPENDENCIES
rails (~> 3.2.2)
sqlite3
# Smoke test to assure basic functionality works on a variety of Rails versions.
require 'files'
require 'wrong'
include Files
include Wrong::D
describe "annotate inside Rails" do
here = File.expand_path(File.dirname __FILE__)
['3.2', '2.3'].each do |base_version|
it "works under Rails #{base_version}" do
base_dir = "rails-#{base_version}"
gemfile = "#{here}/#{base_dir}.gems"
annotate_bin = File.expand_path "#{here}/../../bin/annotate"
Bundler.with_clean_env do
dir base_dir do
temp_dir = Dir.pwd
File.basename(Dir.pwd).should == base_dir
rails_cmd = "#{temp_dir}/rails"
case base_version
when /^2\./
new_cmd = "#{rails_cmd}"
generate_cmd = "script/generate"
when /^3\./
new_cmd = "#{rails_cmd} new"
generate_cmd = "#{rails_cmd} generate"
end
# todo: optionally use rvm
`bundle install --binstubs=#{temp_dir} --gemfile #{gemfile}`.should =~ /Your bundle is complete/
rails_version = `#{rails_cmd} -v`.chomp
rails_version.should =~ /^Rails/
rails_version = rails_version.split(" ").last
rails_version.should =~ /(\d+)(\.\d+)*/
rails_version.should =~ /^#{base_version}/
`#{new_cmd} todo`
Dir.chdir("#{temp_dir}/todo") do
`#{generate_cmd} scaffold Task content:string`.should =~ %r{db/migrate/.*_create_tasks.rb}
`../rake db:migrate`.should =~ /CreateTasks: migrated/
File.read("app/models/task.rb").should == "class Task < ActiveRecord::Base\nend\n"
`#{annotate_bin}`.chomp.should == "Annotated (1): Task"
File.read("app/models/task.rb").should == <<-RUBY
# == Schema Information
#
# Table name: tasks
#
# content :string(255)
# created_at :datetime not null
# id :integer not null, primary key
# updated_at :datetime not null
#
class Task < ActiveRecord::Base
end
RUBY
end
end
end
end
end
end
\ No newline at end of file
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