aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/rake_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/application/rake_test.rb')
-rw-r--r--railties/test/application/rake_test.rb43
1 files changed, 41 insertions, 2 deletions
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index ab36ace5e5..7671c129e9 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -10,6 +10,10 @@ module ApplicationTests
FileUtils.rm_rf("#{app_path}/config/environments")
end
+ def teardown
+ teardown_app
+ end
+
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")
@@ -55,6 +59,32 @@ module ApplicationTests
Dir.chdir(app_path){ `rake stats` }
end
+ def test_rake_test_error_output
+ Dir.chdir(app_path){ `rake db:migrate` }
+
+ app_file "config/database.yml", <<-RUBY
+ development:
+ RUBY
+
+ app_file "test/unit/one_unit_test.rb", <<-RUBY
+ RUBY
+
+ app_file "test/functional/one_functional_test.rb", <<-RUBY
+ raise RuntimeError
+ RUBY
+
+ app_file "test/integration/one_integration_test.rb", <<-RUBY
+ raise RuntimeError
+ RUBY
+
+ silence_stderr do
+ output = Dir.chdir(app_path){ `rake test` }
+ assert_match /Errors running test:units! #<ActiveRecord::AdapterNotSpecified/, output
+ assert_match /Errors running test:functionals! #<RuntimeError/, output
+ assert_match /Errors running test:integration! #<RuntimeError/, output
+ end
+ end
+
def test_rake_routes_output_strips_anchors_from_http_verbs
app_file "config/routes.rb", <<-RUBY
AppTemplate::Application.routes.draw do
@@ -113,7 +143,7 @@ module ApplicationTests
end
require "#{rails_root}/config/environment"
-
+
# loading a specific fixture
errormsg = Dir.chdir(app_path) { `rake db:fixtures:load FIXTURES=products` }
assert $?.success?, errormsg
@@ -121,5 +151,14 @@ module ApplicationTests
assert_equal 2, ::AppTemplate::Application::Product.count
assert_equal 0, ::AppTemplate::Application::User.count
end
+
+ def test_scaffold_tests_pass_by_default
+ content = Dir.chdir(app_path) do
+ `rails generate scaffold user username:string password:string`
+ `bundle exec rake db:migrate db:test:clone test`
+ end
+
+ assert_match(/7 tests, 10 assertions, 0 failures, 0 errors/, content)
+ end
end
-end
+end \ No newline at end of file