From 947206952e55b8b49e50b8c1ddb1bc41f892dff8 Mon Sep 17 00:00:00 2001 From: kane Date: Wed, 26 May 2010 13:55:58 -0700 Subject: [PATCH] Failing test for rake task --- railties/test/application/rake_test.rb | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 6b7a471..77aea5c 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -33,5 +33,29 @@ module ApplicationTests assert_match "SuperMiddleware", Dir.chdir(app_path){ `rake middleware` } end + + def test_environment_is_test_during_test_prepare + app_file "db/schema.rb", <<-RUBY + ActiveRecord::Schema.define(:version => 1) do + end + RUBY + + app_file "lib/tasks/app.rake", <<-RUBY + Rake::Task['db:test:prepare'].enhance do + puts "Environment: " + RAILS_ENV + puts "Database: " + ActiveRecord::Base.connection.instance_variable_get(:@config)[:database] + puts "Log: " + ActiveRecord::Base.connection.instance_variable_get(:@logger).instance_variable_get(:@log).path + end + RUBY + + require "#{app_path}/config/environment" + ::Rails::Application.load_tasks + + puts Dir.chdir(app_path){ `rake db:test:prepare` } + output = Dir.chdir(app_path){ `rake test:prepare` } + assert_match "Environment: test", output + assert_match /Database: .*test.*/, output + assert_match "Log: test.log", output + end end end \ No newline at end of file -- 1.6.3.3