Skip to content

Commit 98d0063

Browse files
committed
improve tests, including correct gems for Rails 3.2.7
1 parent 104a76e commit 98d0063

File tree

4 files changed

+88
-49
lines changed

4 files changed

+88
-49
lines changed

spec/annotate/annotate_models_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ def annotate_one_file options = {}
344344
File.read(@model_file_name).should == "#{@file_content}\n#{another_schema_info}"
345345
end
346346

347+
it "works with namepaced models (i.e. models inside modules/subdirectories"
348+
347349
describe "if a file can't be annotated" do
348350
before do
349351
write_model('user.rb', <<-EOS)

spec/integration/rails-3.2.gems

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ source :rubygems
22

33
gem 'rails', "~>3.2"
44
gem "sqlite3"
5+
gem "jquery-rails"
6+
gem "coffee-rails"
7+
gem "sass-rails"
8+
gem "uglifier"

spec/integration/rails-3.2.gems.lock

Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,58 @@
11
GEM
22
remote: http://rubygems.org/
33
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)
4+
actionmailer (3.2.7)
5+
actionpack (= 3.2.7)
6+
mail (~> 2.4.4)
7+
actionpack (3.2.7)
8+
activemodel (= 3.2.7)
9+
activesupport (= 3.2.7)
1010
builder (~> 3.0.0)
1111
erubis (~> 2.7.0)
12-
journey (~> 1.0.1)
12+
journey (~> 1.0.4)
1313
rack (~> 1.4.0)
14-
rack-cache (~> 1.1)
14+
rack-cache (~> 1.2)
1515
rack-test (~> 0.6.1)
16-
sprockets (~> 2.1.2)
17-
activemodel (3.2.2)
18-
activesupport (= 3.2.2)
16+
sprockets (~> 2.1.3)
17+
activemodel (3.2.7)
18+
activesupport (= 3.2.7)
1919
builder (~> 3.0.0)
20-
activerecord (3.2.2)
21-
activemodel (= 3.2.2)
22-
activesupport (= 3.2.2)
20+
activerecord (3.2.7)
21+
activemodel (= 3.2.7)
22+
activesupport (= 3.2.7)
2323
arel (~> 3.0.2)
2424
tzinfo (~> 0.3.29)
25-
activeresource (3.2.2)
26-
activemodel (= 3.2.2)
27-
activesupport (= 3.2.2)
28-
activesupport (3.2.2)
25+
activeresource (3.2.7)
26+
activemodel (= 3.2.7)
27+
activesupport (= 3.2.7)
28+
activesupport (3.2.7)
2929
i18n (~> 0.6)
3030
multi_json (~> 1.0)
3131
arel (3.0.2)
3232
builder (3.0.0)
33+
coffee-rails (3.2.2)
34+
coffee-script (>= 2.2.0)
35+
railties (~> 3.2.0)
36+
coffee-script (2.2.0)
37+
coffee-script-source
38+
execjs
39+
coffee-script-source (1.3.3)
3340
erubis (2.7.0)
41+
execjs (1.4.0)
42+
multi_json (~> 1.0)
3443
hike (1.2.1)
3544
i18n (0.6.0)
36-
journey (1.0.3)
37-
json (1.6.6)
45+
journey (1.0.4)
46+
jquery-rails (2.0.2)
47+
railties (>= 3.2.0, < 5.0)
48+
thor (~> 0.14)
49+
json (1.7.4)
3850
mail (2.4.4)
3951
i18n (>= 0.4.0)
4052
mime-types (~> 1.16)
4153
treetop (~> 1.4.8)
42-
mime-types (1.18)
43-
multi_json (1.1.0)
54+
mime-types (1.19)
55+
multi_json (1.3.6)
4456
polyglot (0.3.3)
4557
rack (1.4.1)
4658
rack-cache (1.2)
@@ -49,39 +61,51 @@ GEM
4961
rack
5062
rack-test (0.6.1)
5163
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)
64+
rails (3.2.7)
65+
actionmailer (= 3.2.7)
66+
actionpack (= 3.2.7)
67+
activerecord (= 3.2.7)
68+
activeresource (= 3.2.7)
69+
activesupport (= 3.2.7)
5870
bundler (~> 1.0)
59-
railties (= 3.2.2)
60-
railties (3.2.2)
61-
actionpack (= 3.2.2)
62-
activesupport (= 3.2.2)
71+
railties (= 3.2.7)
72+
railties (3.2.7)
73+
actionpack (= 3.2.7)
74+
activesupport (= 3.2.7)
6375
rack-ssl (~> 1.3.2)
6476
rake (>= 0.8.7)
6577
rdoc (~> 3.4)
66-
thor (~> 0.14.6)
78+
thor (>= 0.14.6, < 2.0)
6779
rake (0.9.2.2)
6880
rdoc (3.12)
6981
json (~> 1.4)
70-
sprockets (2.1.2)
82+
sass (3.1.20)
83+
sass-rails (3.2.5)
84+
railties (~> 3.2.0)
85+
sass (>= 3.1.10)
86+
tilt (~> 1.3)
87+
sprockets (2.1.3)
7188
hike (~> 1.2)
7289
rack (~> 1.0)
7390
tilt (~> 1.1, != 1.3.0)
74-
sqlite3 (1.3.5)
75-
thor (0.14.6)
91+
sqlite3 (1.3.6)
92+
thor (0.15.4)
7693
tilt (1.3.3)
7794
treetop (1.4.10)
7895
polyglot
7996
polyglot (>= 0.3.1)
80-
tzinfo (0.3.32)
97+
tzinfo (0.3.33)
98+
uglifier (1.2.6)
99+
execjs (>= 0.3.0)
100+
multi_json (~> 1.3)
81101

82102
PLATFORMS
83103
ruby
84104

85105
DEPENDENCIES
106+
coffee-rails
107+
jquery-rails
86108
rails (~> 3.2)
109+
sass-rails
87110
sqlite3
111+
uglifier

spec/integration/rails_integration_spec.rb

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,40 @@
3737
rails_version.should =~ /^#{base_version}/
3838
puts "\nUsing Rails #{rails_version}"
3939

40+
def process_model text, base_version
41+
if base_version == "2.3"
42+
# for some reason timestamps are nullable in Rails 2.3.14
43+
text.gsub!(/datetime +not null/, "datetime")
44+
text.gsub!(" attr_accessible :content\n", '')
45+
end
46+
end
47+
4048
`#{new_cmd} todo`
4149
Dir.chdir("#{temp_dir}/todo") do
4250
`#{generate_cmd} scaffold Task content:string`.should =~ %r{db/migrate/.*_create_tasks.rb}
4351
`../rake db:migrate`.should =~ /CreateTasks: migrated/
44-
File.read("app/models/task.rb").should == "class Task < ActiveRecord::Base\nend\n"
45-
`#{annotate_bin}`.chomp.should == "Annotated (1): Task"
4652
expected_model = <<-RUBY
53+
class Task < ActiveRecord::Base
54+
attr_accessible :content
55+
end
56+
RUBY
57+
process_model(expected_model, base_version)
58+
File.read("app/models/task.rb").should == expected_model
59+
60+
`#{annotate_bin}`.chomp.should == "Annotated (1): Task"
61+
expected_model = <<-RUBY + expected_model
4762
# == Schema Information
4863
#
4964
# Table name: tasks
5065
#
51-
# id :integer not null, primary key
66+
# id :integer not null, primary key
5267
# content :string(255)
53-
# created_at :datetime not null
54-
# updated_at :datetime not null
68+
# created_at :datetime not null
69+
# updated_at :datetime not null
5570
#
5671
57-
class Task < ActiveRecord::Base
58-
end
5972
RUBY
60-
61-
if base_version == "2.3"
62-
# for some reason timestamps are not required in Rails 2.3.14
63-
expected_model.gsub!(/datetime +not null/, "datetime")
64-
end
73+
process_model(expected_model, base_version)
6574
File.read("app/models/task.rb").should == expected_model
6675

6776
end

0 commit comments

Comments
 (0)