2010-04-26 03:36:13 -04:00
|
|
|
require "isolation/abstract_unit"
|
|
|
|
|
|
|
|
module ApplicationTests
|
|
|
|
class RakeTest < Test::Unit::TestCase
|
|
|
|
include ActiveSupport::Testing::Isolation
|
|
|
|
|
|
|
|
def setup
|
|
|
|
build_app
|
|
|
|
boot_rails
|
|
|
|
FileUtils.rm_rf("#{app_path}/config/environments")
|
|
|
|
end
|
2010-06-19 11:51:29 -04:00
|
|
|
|
2010-04-26 03:36:13 -04:00
|
|
|
def test_gems_tasks_are_loaded_first_than_application_ones
|
|
|
|
app_file "lib/tasks/app.rake", <<-RUBY
|
|
|
|
$task_loaded = Rake::Task.task_defined?("db:create:all")
|
|
|
|
RUBY
|
2010-08-14 01:13:00 -04:00
|
|
|
|
2010-04-26 03:36:13 -04:00
|
|
|
require "#{app_path}/config/environment"
|
|
|
|
::Rails.application.load_tasks
|
|
|
|
assert $task_loaded
|
|
|
|
end
|
2010-04-29 02:39:44 -04:00
|
|
|
|
|
|
|
def test_environment_is_required_in_rake_tasks
|
|
|
|
app_file "config/environment.rb", <<-RUBY
|
|
|
|
SuperMiddleware = Struct.new(:app)
|
|
|
|
|
2010-07-01 11:07:48 -04:00
|
|
|
AppTemplate::Application.configure do
|
2010-04-29 02:39:44 -04:00
|
|
|
config.middleware.use SuperMiddleware
|
|
|
|
end
|
|
|
|
|
2010-07-01 11:07:48 -04:00
|
|
|
AppTemplate::Application.initialize!
|
2010-04-29 02:39:44 -04:00
|
|
|
RUBY
|
|
|
|
|
|
|
|
assert_match "SuperMiddleware", Dir.chdir(app_path){ `rake middleware` }
|
|
|
|
end
|
2010-09-24 09:06:35 -04:00
|
|
|
|
|
|
|
def test_code_statistics_sanity
|
|
|
|
assert_match "Code LOC: 5 Test LOC: 0 Code to Test Ratio: 1:0.0",
|
|
|
|
Dir.chdir(app_path){ `rake stats` }
|
|
|
|
end
|
2010-04-26 03:36:13 -04:00
|
|
|
end
|
2010-09-24 09:06:35 -04:00
|
|
|
end
|