Commit 98d00635 by Alex Chaffee

improve tests, including correct gems for Rails 3.2.7

parent 104a76e3
...@@ -344,6 +344,8 @@ end ...@@ -344,6 +344,8 @@ end
File.read(@model_file_name).should == "#{@file_content}\n#{another_schema_info}" File.read(@model_file_name).should == "#{@file_content}\n#{another_schema_info}"
end end
it "works with namepaced models (i.e. models inside modules/subdirectories"
describe "if a file can't be annotated" do describe "if a file can't be annotated" do
before do before do
write_model('user.rb', <<-EOS) write_model('user.rb', <<-EOS)
......
...@@ -2,3 +2,7 @@ source :rubygems ...@@ -2,3 +2,7 @@ source :rubygems
gem 'rails', "~>3.2" gem 'rails', "~>3.2"
gem "sqlite3" gem "sqlite3"
gem "jquery-rails"
gem "coffee-rails"
gem "sass-rails"
gem "uglifier"
GEM GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
actionmailer (3.2.2) actionmailer (3.2.7)
actionpack (= 3.2.2) actionpack (= 3.2.7)
mail (~> 2.4.0) mail (~> 2.4.4)
actionpack (3.2.2) actionpack (3.2.7)
activemodel (= 3.2.2) activemodel (= 3.2.7)
activesupport (= 3.2.2) activesupport (= 3.2.7)
builder (~> 3.0.0) builder (~> 3.0.0)
erubis (~> 2.7.0) erubis (~> 2.7.0)
journey (~> 1.0.1) journey (~> 1.0.4)
rack (~> 1.4.0) rack (~> 1.4.0)
rack-cache (~> 1.1) rack-cache (~> 1.2)
rack-test (~> 0.6.1) rack-test (~> 0.6.1)
sprockets (~> 2.1.2) sprockets (~> 2.1.3)
activemodel (3.2.2) activemodel (3.2.7)
activesupport (= 3.2.2) activesupport (= 3.2.7)
builder (~> 3.0.0) builder (~> 3.0.0)
activerecord (3.2.2) activerecord (3.2.7)
activemodel (= 3.2.2) activemodel (= 3.2.7)
activesupport (= 3.2.2) activesupport (= 3.2.7)
arel (~> 3.0.2) arel (~> 3.0.2)
tzinfo (~> 0.3.29) tzinfo (~> 0.3.29)
activeresource (3.2.2) activeresource (3.2.7)
activemodel (= 3.2.2) activemodel (= 3.2.7)
activesupport (= 3.2.2) activesupport (= 3.2.7)
activesupport (3.2.2) activesupport (3.2.7)
i18n (~> 0.6) i18n (~> 0.6)
multi_json (~> 1.0) multi_json (~> 1.0)
arel (3.0.2) arel (3.0.2)
builder (3.0.0) builder (3.0.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.3.3)
erubis (2.7.0) erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
hike (1.2.1) hike (1.2.1)
i18n (0.6.0) i18n (0.6.0)
journey (1.0.3) journey (1.0.4)
json (1.6.6) jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
json (1.7.4)
mail (2.4.4) mail (2.4.4)
i18n (>= 0.4.0) i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
mime-types (1.18) mime-types (1.19)
multi_json (1.1.0) multi_json (1.3.6)
polyglot (0.3.3) polyglot (0.3.3)
rack (1.4.1) rack (1.4.1)
rack-cache (1.2) rack-cache (1.2)
...@@ -49,39 +61,51 @@ GEM ...@@ -49,39 +61,51 @@ GEM
rack rack
rack-test (0.6.1) rack-test (0.6.1)
rack (>= 1.0) rack (>= 1.0)
rails (3.2.2) rails (3.2.7)
actionmailer (= 3.2.2) actionmailer (= 3.2.7)
actionpack (= 3.2.2) actionpack (= 3.2.7)
activerecord (= 3.2.2) activerecord (= 3.2.7)
activeresource (= 3.2.2) activeresource (= 3.2.7)
activesupport (= 3.2.2) activesupport (= 3.2.7)
bundler (~> 1.0) bundler (~> 1.0)
railties (= 3.2.2) railties (= 3.2.7)
railties (3.2.2) railties (3.2.7)
actionpack (= 3.2.2) actionpack (= 3.2.7)
activesupport (= 3.2.2) activesupport (= 3.2.7)
rack-ssl (~> 1.3.2) rack-ssl (~> 1.3.2)
rake (>= 0.8.7) rake (>= 0.8.7)
rdoc (~> 3.4) rdoc (~> 3.4)
thor (~> 0.14.6) thor (>= 0.14.6, < 2.0)
rake (0.9.2.2) rake (0.9.2.2)
rdoc (3.12) rdoc (3.12)
json (~> 1.4) json (~> 1.4)
sprockets (2.1.2) sass (3.1.20)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sprockets (2.1.3)
hike (~> 1.2) hike (~> 1.2)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5) sqlite3 (1.3.6)
thor (0.14.6) thor (0.15.4)
tilt (1.3.3) tilt (1.3.3)
treetop (1.4.10) treetop (1.4.10)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
tzinfo (0.3.32) tzinfo (0.3.33)
uglifier (1.2.6)
execjs (>= 0.3.0)
multi_json (~> 1.3)
PLATFORMS PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
coffee-rails
jquery-rails
rails (~> 3.2) rails (~> 3.2)
sass-rails
sqlite3 sqlite3
uglifier
...@@ -37,13 +37,28 @@ describe "annotate inside Rails" do ...@@ -37,13 +37,28 @@ describe "annotate inside Rails" do
rails_version.should =~ /^#{base_version}/ rails_version.should =~ /^#{base_version}/
puts "\nUsing Rails #{rails_version}" puts "\nUsing Rails #{rails_version}"
def process_model text, base_version
if base_version == "2.3"
# for some reason timestamps are nullable in Rails 2.3.14
text.gsub!(/datetime +not null/, "datetime")
text.gsub!(" attr_accessible :content\n", '')
end
end
`#{new_cmd} todo` `#{new_cmd} todo`
Dir.chdir("#{temp_dir}/todo") do Dir.chdir("#{temp_dir}/todo") do
`#{generate_cmd} scaffold Task content:string`.should =~ %r{db/migrate/.*_create_tasks.rb} `#{generate_cmd} scaffold Task content:string`.should =~ %r{db/migrate/.*_create_tasks.rb}
`../rake db:migrate`.should =~ /CreateTasks: migrated/ `../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"
expected_model = <<-RUBY expected_model = <<-RUBY
class Task < ActiveRecord::Base
attr_accessible :content
end
RUBY
process_model(expected_model, base_version)
File.read("app/models/task.rb").should == expected_model
`#{annotate_bin}`.chomp.should == "Annotated (1): Task"
expected_model = <<-RUBY + expected_model
# == Schema Information # == Schema Information
# #
# Table name: tasks # Table name: tasks
...@@ -54,14 +69,8 @@ describe "annotate inside Rails" do ...@@ -54,14 +69,8 @@ describe "annotate inside Rails" do
# updated_at :datetime not null # updated_at :datetime not null
# #
class Task < ActiveRecord::Base
end
RUBY RUBY
process_model(expected_model, base_version)
if base_version == "2.3"
# for some reason timestamps are not required in Rails 2.3.14
expected_model.gsub!(/datetime +not null/, "datetime")
end
File.read("app/models/task.rb").should == expected_model File.read("app/models/task.rb").should == expected_model
end end
......
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