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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:42:44+00:00 2026-05-11T07:42:44+00:00

I have a class defined in a file my Rails project’s lib dir that

  • 0

I have a class defined in a file my Rails project’s lib dir that will implement a bunch of utility functions as class methods. I’d like to write tests against those methods using Test::Unit and have them run as part of the project’s regular testing routine.

I tried sticking a file at the top level of the test dir…

require 'test_helper'  class UtilsTest < ActiveSupport::TestCase   should 'be true' do     assert false   end end 

…but that didn’t work. The test didn’t run.

What is the normal way to test code that is not one of the regular parts of Rails?

  • 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. 2026-05-11T07:42:45+00:00Added an answer on May 11, 2026 at 7:42 am

    You can put them in your units directory without any complications.

    My Library:

    [ cpm juno ~/apps/feedback ] cat lib/my_library.rb class MyLib   def look_at_me     puts 'I DO WEIRD STUFF'   end end 

    My Test:

    [ cpm juno ~/apps/feedback ] cat test/unit/fake_test.rb require 'test_helper'  class FakeTest < ActiveSupport::TestCase   # Replace this with your real tests.   def test_truth     require 'my_library'      puts 'RUNNING THIS NOW'     MyLib.new.look_at_me     assert true   end end 

    And running it:

    [ cpm juno ~/apps/feedback ] rake test:units (in /home/cpm/apps/feedback) /usr/bin/ruby1.8 -Ilib:test '/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb' 'test/unit/fake_test.rb' Loaded suite /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader Started RUNNING THIS NOW I DO WEIRD STUFF . Finished in 0.254404 seconds.  1 tests, 1 assertions, 0 failures, 0 errors Loaded suite /var/lib/gems/1.8/bin/rake Started  Finished in 0.00094 seconds.  0 tests, 0 assertions, 0 failures, 0 errors 

    As long as it ends in _test.rb it should pick it up.

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

Sidebar

Ask A Question

Stats

  • Questions 229k
  • Answers 229k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Look in the "Link Binary With Libraries" build phase under… May 13, 2026 at 1:52 am
  • Editorial Team
    Editorial Team added an answer I believe you have to create custom class that implements… May 13, 2026 at 1:52 am
  • Editorial Team
    Editorial Team added an answer According to Building the Connection URL, the general form of… May 13, 2026 at 1:52 am

Related Questions

I have a class defined in a file my Rails project's lib dir that
We recently had a problem where, after a series of commits had occurred, a
Im working on a legacy oracle database with a slightly odd table naming convention
I'm writing my first rails plugin and could use a little help. In a
I'm trying to set up Factory Girl with Test::Unit and Shoulda in Ruby on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.