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 4058518
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:05:22+00:00 2026-05-20T15:05:22+00:00

I’m working on writing simple unit tests for a Rails 3 project, but I’m

  • 0

I’m working on writing simple unit tests for a Rails 3 project, but I’m unable to actually execute any tests.

Case in point, attempting to run the test auto-generated by Rails fails:

require 'test_helper'

class UserTest < ActiveSupport::TestCase
  # Replace this with your real tests.
  test "the truth" do
    assert true
  end
end

Results in the following error:

<internal:lib/rubygems/custom_require>:29:in `require': no such file to load --
test_helper (LoadError)
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from user_test.rb:1:in `<main>'

Commenting out the require ‘test_helper’ line and attempting to run the test results in this error:

user_test.rb:3:in `<main>': uninitialized constant Object::ActiveSupport (NameError)

The action pack gems appear to be properly installed and up to date:

actionmailer (3.0.3, 2.3.5)
actionpack (3.0.3, 2.3.5)
activemodel (3.0.3)
activerecord (3.0.3, 2.3.5)
activeresource (3.0.3, 2.3.5)
activesupport (3.0.3, 2.3.5)

Ruby is at 1.9.2p0 and Rails is at 3.0.3.

The sample dump of my test directory is as follows:

/fixtures
/functional
/integration
/performance
/unit
-- /helpers
   -- user_helper_test.rb
-- user_test.rb
test_helper.rb

I’ve never seen this problem before – I’ve run the typical rake tasks for preparing the test environment. I have nothing out of the ordinary in my application or environment configuration files, nor have I installed any unusual gems that would interfere with the test environment.

Edit March 9th

Xavier Holt‘s suggestion, explicitly specifying the path to the test_helper worked; however, this revealed an issue with ActiveSupport.

Now when I attempt to run the test, I receive the following error message (as also listed above):

user_test.rb:3:in `<main>': uninitialized constant Object::ActiveSupport (NameError)

But as you can see above, Action Pack is all installed and update to date.

Edit March 13th

When attempting to run tests using rake test:units the following stack trace is dumped to the console:

test/unit/bookmark_test.rb:3:in `<top (required)>': uninitialized constant Objec
t::ActiveSupport (NameError)
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `block in <main>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `<main>'
rake aborted!

So looking into the file listed above, I see the following:

#!/usr/bin/env ruby

# Load the test files from the command line.

ARGV.each { |f| load f unless f =~ /^-/  }

To my knowledge, everything looks as expected.

  • 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-05-20T15:05:23+00:00Added an answer on May 20, 2026 at 3:05 pm

    Your test/test_helper file should have been created when you generated the application. It contains this valuable content:

    ENV["RAILS_ENV"] = "test"
    require File.expand_path('../../config/environment', __FILE__)
    require 'rails/test_help'
    
    class ActiveSupport::TestCase
      # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
      #
      # Note: You'll currently still have to declare fixtures explicitly in integration tests
      # -- they do not yet inherit this setting
      fixtures :all
    
      # Add more helper methods to be used by all tests here...
    end
    

    The second line here is the most important: it requires the config/environment.rb file at the root of your application, which in turn requires a lot of other things, including the valuable (I like that word today, ok?) ActiveSupport constant.

    When you generate a controller, model or scaffold it’ll also generate tests for those. I just ran rails g scaffold ticket in my app and it generated test/unit/ticket_test.rb which contains this:

    require 'test_helper'
    
    class TicketTest < ActiveSupport::TestCase
      # Replace this with your real tests.
      test "the truth" do
        assert true
      end
    end
    

    The first line of this file will require the test/test_helper.rb file that we jut saw. This will load ActiveSupport and the TestCase class within it, thereby making this test feasible. Everything else just flows on from there.

    With all that explanation out of the way (even though it’s something that you already know), I’m placing a large wager on it’s something that’s masscaring your LOAD_PATH, causing the test directory to be removed from it.

    What’s really unusual is that when you do specify the full path to the test/test_helper.rb you’re saying it loads it, but ActiveSupport is still undefined. Well, that should be loaded as-per the description above. Is it actually loading config/environment.rb? Can you put something such as:

    puts "LOADING CONFIG/ENVIRONMENT.RB"
    

    At the top of your config/environment.rb file and then run the tests again? It should be output. Very unusual.

    Continuing on the thread about LOAD_PATH… Got a dirty little secret you’re not telling us about?

    Actually, Dan Cheail makes a good point. You could be running the tests using ruby test/unit/ticket_test.rb in which case test_helper wouldn’t be available, but still that still doesn’t explain why when you specify the full path you’re still getting an undefined constant ActiveSupport.

    If you want to run a single test you should be doing this:

    ruby -Itest test/unit/ticket_test.rb
    

    That -I option there adds the test directory to the load path, meaning the test_helper file will be available through a straight require 'test_helper'. If it still errors after this, I reckon your test/test_helper.rb is either empty or broken.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I'm making a simple page using Google Maps API 3. My first. One marker
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I want use html5's new tag to play a wav file (currently only supported
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,

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.