# How to unit test Rails itself (API)?

**URL:** <https://www.ruby-forum.com/t/how-to-unit-test-rails-itself-api/132459>\
**Category:** Rails\
**Created:** [March 20, 2008, 11:21am UTC](https://www.ruby-forum.com/t/how-to-unit-test-rails-itself-api/132459 "2008-03-20T11:21:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![liuxlsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f9ae1b/32.png) [@liuxlsh](https://www.ruby-forum.com/u/liuxlsh)\
**Post date:** [March 20, 2008, 11:21am UTC](https://www.ruby-forum.com/t/how-to-unit-test-rails-itself-api/132459/1 "2008-03-20T11:21:46Z")

</div>

Hello,

I searched unit test for Rails on internet, but all the results are  
for testing Rails APPLICATION generated by Rails.

But I think Rails itself needs unit test, too. I need to make sure  
that all APIs/methods of Rails work fine in different scenarios.

I didn’t see any unit test files in the Rails package. Does anyone  
know how to unit test Rails itself?

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![liuxlsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f9ae1b/32.png) [@liuxlsh](https://www.ruby-forum.com/u/liuxlsh)\
**Post date:** [March 20, 2008, 11:24am UTC](https://www.ruby-forum.com/t/how-to-unit-test-rails-itself-api/132459/2 "2008-03-20T11:24:07Z")

</div>

On 20 Mar 2008, at 10:21, liuxlsh wrote:

> know how to unit test Rails itself?

I don’t know where you’ve got your rails from but each of the rails  
bits has a test folder with a bunch of unit tests.

Fred

---

<div class="post-metadata">

**Author:** ![liuxlsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f9ae1b/32.png) [@liuxlsh](https://www.ruby-forum.com/u/liuxlsh)\
**Post date:** [March 20, 2008, 11:31am UTC](https://www.ruby-forum.com/t/how-to-unit-test-rails-itself-api/132459/3 "2008-03-20T11:31:49Z")

</div>

My rails is version 1.2.6. There does be a “test” directory, but all  
subdirectories in it are empty.

On Mar 20, 6:22 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![liuxlsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f9ae1b/32.png) [@liuxlsh](https://www.ruby-forum.com/u/liuxlsh)\
**Post date:** [March 20, 2008, 11:43am UTC](https://www.ruby-forum.com/t/how-to-unit-test-rails-itself-api/132459/4 "2008-03-20T11:43:03Z")

</div>

On 20 Mar 2008, at 10:31, liuxlsh wrote:

> My rails is version 1.2.6. There does be a “test” directory, but all  
> subdirectories in it are empty.

Which directory exactly are you talking about? Rails has always had  
pretty good test coverage.

Fred

---

<div class="post-metadata">

**Author:** ![liuxlsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f9ae1b/32.png) [@liuxlsh](https://www.ruby-forum.com/u/liuxlsh)\
**Post date:** [March 20, 2008, 12:30pm UTC](https://www.ruby-forum.com/t/how-to-unit-test-rails-itself-api/132459/5 "2008-03-20T12:30:50Z")

</div>

On 3/20/08, liuxlsh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> My rails is version 1.2.6. There does be a “test” directory, but all  
> subdirectories in it are empty.

If you have frozen rails in your project then the many rails tests  
will be distributed in various directories like

vendor  
rails  
actionmailer  
test  
actionpack  
test  
activerecord  
test  
…

And actionpack (which contains ActionController and ActionView) and  
activerecord also have readme files called RUNNING\_UNIT\_TESTS with  
instructions on how to run those tests.

If you are using rails from gems they will be in the individual gems.

But normally you don’t run these tests in projects, they are really  
for testing when rails itself is modified/patched, and the tests are  
run by patch developers and the rails committers before changes are  
accepted.

Bear in mind that some of the rails tests require their own databases  
to be set up, which is covered in those RUNNING\_UNIT\_TESTS readmes.

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![liuxlsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f9ae1b/32.png) [@liuxlsh](https://www.ruby-forum.com/u/liuxlsh)\
**Post date:** [March 21, 2008, 3:01am UTC](https://www.ruby-forum.com/t/how-to-unit-test-rails-itself-api/132459/6 "2008-03-21T03:01:33Z")

</div>

Hi Rick,

Thank you very much for your reply.

So do you mean that I just need not to test Rails itself, but the  
prerequisites of Rails, like active\*, if the Rails package I got is a  
frozen version? Or need I get a develop trunk of Rails to get the unit  
test files?

Thanks a lot.

On Mar 20, 7:30 pm, “Rick DeNatale” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> vendor  
> activerecord also have readme files called RUNNING\_UNIT\_TESTS with  
> to be set up, which is covered in those RUNNING\_UNIT\_TESTS readmes.
> 
> –  
> Rick DeNatale
> 
> My  
> blog on Rubyhttp://talklikeaduck.denhaven2.com/
