Skip to content

Commit

Permalink
Add test to rake test for error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ihower committed Jun 29, 2011
1 parent 89ad062 commit db87e48
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion railties/lib/rails/test_unit/testing.rake
Expand Up @@ -82,7 +82,11 @@ task :test do
{ :task => task, :exception => e } { :task => task, :exception => e }
end end
end.compact end.compact
abort errors.map { |e| "Errors running #{e[:task]}! #{e[:exception].inspect}" }.join("\n") if errors.any?
if errors.any?
puts errors.map { |e| "Errors running #{e[:task]}! #{e[:exception].inspect}" }.join("\n")
abort
end
end end


namespace :test do namespace :test do
Expand Down
26 changes: 26 additions & 0 deletions railties/test/application/rake_test.rb
Expand Up @@ -59,6 +59,32 @@ def test_code_statistics_sanity
Dir.chdir(app_path){ `rake stats` } Dir.chdir(app_path){ `rake stats` }
end 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 def test_rake_routes_output_strips_anchors_from_http_verbs
app_file "config/routes.rb", <<-RUBY app_file "config/routes.rb", <<-RUBY
AppTemplate::Application.routes.draw do AppTemplate::Application.routes.draw do
Expand Down

0 comments on commit db87e48

Please sign in to comment.