Skip to content

Commit 7e2cd42

Browse files
committed
renamed script back to annotate; added rails integration test
1 parent 9340715 commit 7e2cd42

File tree

9 files changed

+199
-3
lines changed

9 files changed

+199
-3
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ group :development do
77
gem 'rspec'
88
gem 'wrong', '>=0.6.2'
99
gem 'rdoc'
10+
gem 'files', '>=0.2.1'
1011
end
1112

1213
gem 'activesupport', '>= 3.0.0', :require => nil

History.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666

6767
* Annotates thoughtbot's factory_girl factories (test/factories/<model>_factory.rb)
6868
* Move default annotation position back to top
69-
>>>>>>> mrjoy
7069

7170
== 2.4.0 2009-12-13
7271

bin/annotate_models renamed to bin/annotate

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
#!/usr/bin/env ruby
2-
32
require 'optparse'
4-
require 'annotate'
53
require 'rake/dsl_definition'
64
require 'rake'
5+
begin
6+
require "annotate"
7+
rescue LoadError
8+
here = File.expand_path(File.dirname __FILE__)
9+
$:<< "#{here}/../lib"
10+
require "annotate"
11+
end
712

813
task = :annotate_models
914

spec/integration/.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
BUNDLE_BIN: /private/var/folders/l2/5s19rxtc8v57nw008k8dpy2h0000gp/T/files_1332801849_945/rails-2.3

spec/integration/rails-2.3.gems

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source :rubygems
2+
3+
gem "rails", "~>2.3.14"
4+
gem "sqlite3"

spec/integration/rails-2.3.gems.lock

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
GEM
2+
remote: http://rubygems.org/
3+
specs:
4+
actionmailer (2.3.14)
5+
actionpack (= 2.3.14)
6+
actionpack (2.3.14)
7+
activesupport (= 2.3.14)
8+
rack (~> 1.1.0)
9+
activerecord (2.3.14)
10+
activesupport (= 2.3.14)
11+
activeresource (2.3.14)
12+
activesupport (= 2.3.14)
13+
activesupport (2.3.14)
14+
rack (1.1.3)
15+
rails (2.3.14)
16+
actionmailer (= 2.3.14)
17+
actionpack (= 2.3.14)
18+
activerecord (= 2.3.14)
19+
activeresource (= 2.3.14)
20+
activesupport (= 2.3.14)
21+
rake (>= 0.8.3)
22+
rake (0.9.2.2)
23+
sqlite3 (1.3.5)
24+
25+
PLATFORMS
26+
ruby
27+
28+
DEPENDENCIES
29+
rails (~> 2.3.14)
30+
sqlite3

spec/integration/rails-3.2.gems

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source :rubygems
2+
3+
gem 'rails', "~>3.2.2"
4+
gem "sqlite3"

spec/integration/rails-3.2.gems.lock

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
GEM
2+
remote: http://rubygems.org/
3+
specs:
4+
actionmailer (3.2.2)
5+
actionpack (= 3.2.2)
6+
mail (~> 2.4.0)
7+
actionpack (3.2.2)
8+
activemodel (= 3.2.2)
9+
activesupport (= 3.2.2)
10+
builder (~> 3.0.0)
11+
erubis (~> 2.7.0)
12+
journey (~> 1.0.1)
13+
rack (~> 1.4.0)
14+
rack-cache (~> 1.1)
15+
rack-test (~> 0.6.1)
16+
sprockets (~> 2.1.2)
17+
activemodel (3.2.2)
18+
activesupport (= 3.2.2)
19+
builder (~> 3.0.0)
20+
activerecord (3.2.2)
21+
activemodel (= 3.2.2)
22+
activesupport (= 3.2.2)
23+
arel (~> 3.0.2)
24+
tzinfo (~> 0.3.29)
25+
activeresource (3.2.2)
26+
activemodel (= 3.2.2)
27+
activesupport (= 3.2.2)
28+
activesupport (3.2.2)
29+
i18n (~> 0.6)
30+
multi_json (~> 1.0)
31+
arel (3.0.2)
32+
builder (3.0.0)
33+
erubis (2.7.0)
34+
hike (1.2.1)
35+
i18n (0.6.0)
36+
journey (1.0.3)
37+
json (1.6.6)
38+
mail (2.4.4)
39+
i18n (>= 0.4.0)
40+
mime-types (~> 1.16)
41+
treetop (~> 1.4.8)
42+
mime-types (1.18)
43+
multi_json (1.1.0)
44+
polyglot (0.3.3)
45+
rack (1.4.1)
46+
rack-cache (1.2)
47+
rack (>= 0.4)
48+
rack-ssl (1.3.2)
49+
rack
50+
rack-test (0.6.1)
51+
rack (>= 1.0)
52+
rails (3.2.2)
53+
actionmailer (= 3.2.2)
54+
actionpack (= 3.2.2)
55+
activerecord (= 3.2.2)
56+
activeresource (= 3.2.2)
57+
activesupport (= 3.2.2)
58+
bundler (~> 1.0)
59+
railties (= 3.2.2)
60+
railties (3.2.2)
61+
actionpack (= 3.2.2)
62+
activesupport (= 3.2.2)
63+
rack-ssl (~> 1.3.2)
64+
rake (>= 0.8.7)
65+
rdoc (~> 3.4)
66+
thor (~> 0.14.6)
67+
rake (0.9.2.2)
68+
rdoc (3.12)
69+
json (~> 1.4)
70+
sprockets (2.1.2)
71+
hike (~> 1.2)
72+
rack (~> 1.0)
73+
tilt (~> 1.1, != 1.3.0)
74+
sqlite3 (1.3.5)
75+
thor (0.14.6)
76+
tilt (1.3.3)
77+
treetop (1.4.10)
78+
polyglot
79+
polyglot (>= 0.3.1)
80+
tzinfo (0.3.32)
81+
82+
PLATFORMS
83+
ruby
84+
85+
DEPENDENCIES
86+
rails (~> 3.2.2)
87+
sqlite3
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Smoke test to assure basic functionality works on a variety of Rails versions.
2+
require 'files'
3+
require 'wrong'
4+
include Files
5+
include Wrong::D
6+
7+
describe "annotate inside Rails" do
8+
here = File.expand_path(File.dirname __FILE__)
9+
['3.2', '2.3'].each do |base_version|
10+
it "works under Rails #{base_version}" do
11+
base_dir = "rails-#{base_version}"
12+
gemfile = "#{here}/#{base_dir}.gems"
13+
annotate_bin = File.expand_path "#{here}/../../bin/annotate"
14+
15+
Bundler.with_clean_env do
16+
dir base_dir do
17+
temp_dir = Dir.pwd
18+
File.basename(Dir.pwd).should == base_dir
19+
rails_cmd = "#{temp_dir}/rails"
20+
21+
case base_version
22+
when /^2\./
23+
new_cmd = "#{rails_cmd}"
24+
generate_cmd = "script/generate"
25+
26+
when /^3\./
27+
new_cmd = "#{rails_cmd} new"
28+
generate_cmd = "#{rails_cmd} generate"
29+
end
30+
31+
# todo: optionally use rvm
32+
`bundle install --binstubs=#{temp_dir} --gemfile #{gemfile}`.should =~ /Your bundle is complete/
33+
rails_version = `#{rails_cmd} -v`.chomp
34+
rails_version.should =~ /^Rails/
35+
rails_version = rails_version.split(" ").last
36+
rails_version.should =~ /(\d+)(\.\d+)*/
37+
rails_version.should =~ /^#{base_version}/
38+
39+
`#{new_cmd} todo`
40+
Dir.chdir("#{temp_dir}/todo") do
41+
`#{generate_cmd} scaffold Task content:string`.should =~ %r{db/migrate/.*_create_tasks.rb}
42+
`../rake db:migrate`.should =~ /CreateTasks: migrated/
43+
File.read("app/models/task.rb").should == "class Task < ActiveRecord::Base\nend\n"
44+
`#{annotate_bin}`.chomp.should == "Annotated (1): Task"
45+
File.read("app/models/task.rb").should == <<-RUBY
46+
# == Schema Information
47+
#
48+
# Table name: tasks
49+
#
50+
# content :string(255)
51+
# created_at :datetime not null
52+
# id :integer not null, primary key
53+
# updated_at :datetime not null
54+
#
55+
56+
class Task < ActiveRecord::Base
57+
end
58+
RUBY
59+
end
60+
end
61+
end
62+
end
63+
end
64+
end

0 commit comments

Comments
 (0)