aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-11-11 08:16:25 -0200
committerJosé Valim <jose.valim@gmail.com>2009-11-11 08:16:25 -0200
commit01ae99c681d31803f3a29f8305c9a041aa456660 (patch)
tree7fdb9e32b743aeb254854371349cecfd2499defa /railties/test/generators
parentd002826e54415a340e55fdbf363d005faebf8fc5 (diff)
parentfca32eb6c5b41e4f19a25b7b246c4a8a3d763667 (diff)
downloadrails-01ae99c681d31803f3a29f8305c9a041aa456660.tar.gz
rails-01ae99c681d31803f3a29f8305c9a041aa456660.tar.bz2
rails-01ae99c681d31803f3a29f8305c9a041aa456660.zip
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/actions_test.rb47
-rw-r--r--railties/test/generators/app_generator_test.rb14
-rw-r--r--railties/test/generators/generators_test_helper.rb17
-rw-r--r--railties/test/generators/resource_generator_test.rb2
4 files changed, 36 insertions, 44 deletions
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index 199b5fa8b4..7d03a37f2a 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -54,37 +54,37 @@ class ActionsTest < GeneratorsTestCase
action :plugin, 'rest_auth', {}
end
- def test_gem_should_put_gem_dependency_in_enviroment
+ def test_add_source_adds_source_to_gemfile
run_generator
- action :gem, 'will-paginate'
- assert_file 'config/application.rb', /config\.gem 'will\-paginate'/
+ action :add_source, 'http://gems.github.com'
+ assert_file 'Gemfile', /source "http:\/\/gems\.github\.com"/
end
- def test_gem_with_options_should_include_options_in_gem_dependency_in_environment
+ def test_gem_should_put_gem_dependency_in_gemfile
run_generator
- action :gem, 'mislav-will-paginate', :lib => 'will-paginate', :source => 'http://gems.github.com'
-
- regexp = /#{Regexp.escape("config.gem 'mislav-will-paginate', :lib => 'will-paginate', :source => 'http://gems.github.com'")}/
- assert_file 'config/application.rb', regexp
+ action :gem, 'will-paginate'
+ assert_file 'Gemfile', /gem "will\-paginate"/
end
- def test_gem_with_env_string_should_put_gem_dependency_in_specified_environment
+ def test_gem_with_options_should_include_all_options_in_gemfile
run_generator
- action :gem, 'rspec', :env => 'test'
- assert_file 'config/environments/test.rb', /config\.gem 'rspec'/
- end
- def test_gem_with_env_array_should_put_gem_dependency_in_specified_environments
- run_generator
- action :gem, 'quietbacktrace', :env => %w[ development test ]
- assert_file 'config/environments/development.rb', /config\.gem 'quietbacktrace'/
- assert_file 'config/environments/test.rb', /config\.gem 'quietbacktrace'/
+ assert_deprecated do
+ action :gem, 'mislav-will-paginate', :lib => 'will-paginate', :source => 'http://gems.github.com'
+ end
+
+ assert_file 'Gemfile', /gem "mislav\-will\-paginate", :require_as => "will\-paginate"/
+ assert_file 'Gemfile', /source "http:\/\/gems\.github\.com"/
end
- def test_gem_with_lib_option_set_to_false_should_put_gem_dependency_in_enviroment_correctly
+ def test_gem_with_env_should_include_all_dependencies_in_gemfile
run_generator
- action :gem, 'mislav-will-paginate', :lib => false
- assert_file 'config/application.rb', /config\.gem 'mislav\-will\-paginate'\, :lib => false/
+
+ assert_deprecated do
+ action :gem, 'rspec', :env => %w(development test)
+ end
+
+ assert_file 'Gemfile', /gem "rspec", :only => \["development", "test"\]/
end
def test_environment_should_include_data_in_environment_initializer_block
@@ -163,9 +163,10 @@ class ActionsTest < GeneratorsTestCase
action :capify!
end
- def test_freeze_should_freeze_rails_edge
- generator.expects(:run).once.with('rake rails:freeze:edge', :verbose => false)
- action :freeze!
+ def test_freeze_is_deprecated
+ assert_deprecated do
+ action :freeze!
+ end
end
def test_route_should_add_data_to_the_routes_block_in_config_routes
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 20f2a24e6d..10d0bc6bc2 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -110,20 +110,6 @@ class AppGeneratorTest < GeneratorsTestCase
).each { |path| assert_file "script/#{path}", /#!\/usr\/bin\/env/ }
end
- def test_rails_is_frozen
- generator(:freeze => true, :database => "sqlite3").expects(:run).
- with("rake rails:freeze:edge", :verbose => false)
- silence(:stdout){ generator.invoke }
-
- assert_file 'Gemfile' do |content|
- flag = %(gem "rails", "#{Rails::VERSION::STRING}", :git => "git://github.com/rails/rails.git")
- assert_match /^#{Regexp.escape(flag)}$/, content
-
- flag = %(# gem "rails", "#{Rails::VERSION::STRING}")
- assert_match /^#{Regexp.escape(flag)}$/, content
- end
- end
-
def test_template_from_dir_pwd
FileUtils.cd(Rails.root)
assert_match /It works from file!/, run_generator(["-m", "lib/template.rb"])
diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb
index ccf08c347c..4ce48a453b 100644
--- a/railties/test/generators/generators_test_helper.rb
+++ b/railties/test/generators/generators_test_helper.rb
@@ -1,8 +1,14 @@
# TODO: Fix this RAILS_ENV stuff
-RAILS_ENV = 'test'
-
+RAILS_ENV = 'test' unless defined?(RAILS_ENV)
require 'abstract_unit'
-Rails.application.config.root = File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures'))
+
+module Rails
+ def self.root
+ @root ||= File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures'))
+ end
+end
+Rails.application.config.root = Rails.root
+
require 'rails/generators'
require 'rubygems'
require 'active_record'
@@ -11,12 +17,11 @@ require 'action_dispatch'
CURRENT_PATH = File.expand_path(Dir.pwd)
Rails::Generators.no_color!
-class GeneratorsTestCase < Test::Unit::TestCase
+class GeneratorsTestCase < ActiveSupport::TestCase
include FileUtils
def destination_root
- @destination_root ||= File.expand_path(File.join(File.dirname(__FILE__),
- '..', 'fixtures', 'tmp'))
+ File.join(Rails.root, "tmp")
end
def setup
diff --git a/railties/test/generators/resource_generator_test.rb b/railties/test/generators/resource_generator_test.rb
index dcae81c204..886af01b22 100644
--- a/railties/test/generators/resource_generator_test.rb
+++ b/railties/test/generators/resource_generator_test.rb
@@ -75,7 +75,7 @@ class ResourceGeneratorTest < GeneratorsTestCase
end
def test_plural_names_are_singularized
- content = run_generator ["accounts"]
+ content = run_generator ["accounts".freeze]
assert_file "app/models/account.rb", /class Account < ActiveRecord::Base/
assert_file "test/unit/account_test.rb", /class AccountTest/
assert_match /Plural version of the model detected, using singularized version. Override with --force-plural./, content