Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8785533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:23:37+00:00 2026-06-13T21:23:37+00:00

I am using Ruby 1.9.3 and Rails 3.2.8. This uses rake 0.9.2.2. I wish

  • 0

I am using Ruby 1.9.3 and Rails 3.2.8. This uses rake 0.9.2.2.

I wish to detect a failing unit test and, in Rails 2.3, we did this by checking the exit code. This no longer works.

I try:

rake test:units TEST=test/unit/failing_test.rb RAILS_ENV=test && echo "OK"

failing_test.rb consists of a single test which asserts false. I expect to see a test failure and not to see “OK”, but instead, I see:

Started
F
===============================================================================
Failure: <false> is not true.
test: failing test case should fail. (FailingTest)
test/unit/failing_test.rb:6:in `block (2 levels) in <class:FailingTest>'
shoulda-context (1.0.0) lib/shoulda/context/context.rb:398:in `call'
shoulda-context (1.0.0) lib/shoulda/context/context.rb:398:in `block in create_test_from_should_hash'
activesupport (3.2.8) lib/active_support/testing/setup_and_teardown.rb:72:in `block in run'
activesupport (3.2.8) lib/active_support/callbacks.rb:425:in `_run__3774233495015181374__setup__985181848351195933__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_setup_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
activesupport (3.2.8) lib/active_support/testing/setup_and_teardown.rb:70:in `run'
===============================================================================


Finished in 0.002753 seconds.

1 tests, 1 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
0% passed

363.24 tests/s, 363.24 assertions/s
rake aborted!
Command failed with status (1): [/Users/chris/.rvm/rubies/ruby-1.9.3-p194/b...]

Tasks: TOP => test:units
(See full trace by running task with --trace)
OK

Specifically, I see “Command failed with status (1)”, but this seems to get eaten up by rake as I also see “OK”. Note that if I do echo $?, I see the exit code is 0 (success). I’m trying to get this to work in the context of our continuous integration and also with our release script, both of which assume the exit code will be non-zero in the case of an error, as happened with Rails 2.3.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:23:40+00:00Added an answer on June 13, 2026 at 9:23 pm

    My failing test with the same rails/ruby/rake is exiting 1 unlike yours. Perhaps you have something calling at_exit { exit 0 } or trap('EXIT') { exit 0 } somewhere in your code base. This would modify the exit code for rake.

    If you want a non-Ruby way of detecting failures you could try reading the output of the test using grep. grep will return 0 if it finds a match and 1 if it did not.

    the regular expression looks for " 0 failures, 0 errors", returning 0 if it found and 1 if not.

    rake test:units TEST=test/unit/failing_test.rb RAILS_ENV=test | \
      tee >(xargs -0 echo {}) | \ 
      grep '\([[:space:]]0[[:space:]]\)failures,\1errors' && 
      echo OK
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Ruby on Rails, but I think this question could be applied
I am trying to learn Ruby on Rails using this Rails Tutorial. Earlier, I
I'm using ruby on rails 2.3.8 and I'm kind of knew at this technology.
Authorize.net provides some sample code for using CIM with ruby but its uses XML.
I'm following this tutorial http://ruby.railstutorial.org/ The tutorial seems to be using Rails 3.0. I
Novice here! I'm currently creating an application using Ruby on Rails. This particular application
My Ruby on Rails application uses the following controller code to generate a sitemap.xml
I am getting this error when running some unit tests (using the Test::Unit module
Using Ruby on Rails. I'm trying to sort a query by number (saved as
using Ruby on Rails 2.3.2, since I already created Scaffold for Story, so instead

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.