# Testing modules

**URL:** <https://www.ruby-forum.com/t/testing-modules/152735>\
**Category:** Rails\
**Created:** [November 6, 2008, 11:06pm UTC](https://www.ruby-forum.com/t/testing-modules/152735 "2008-11-06T23:06:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![russianbandit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e36b37/32.png) [@russianbandit](https://www.ruby-forum.com/u/russianbandit)\
**Post date:** [November 6, 2008, 11:06pm UTC](https://www.ruby-forum.com/t/testing-modules/152735/1 "2008-11-06T23:06:55Z")

</div>

I’m curious about standards on unit testing modules.

I have a module file in my lib/ directory. Should I create a unit test  
in test/unit directory and test it as I would any other model?

Is there any kind of naming convention used for unit test files for  
modules (some\_name\_test.rb or some\_name\_module\_test.rb)?

---

<div class="post-metadata">

**Author:** ![russianbandit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e36b37/32.png) [@russianbandit](https://www.ruby-forum.com/u/russianbandit)\
**Post date:** [November 7, 2008, 2:33am UTC](https://www.ruby-forum.com/t/testing-modules/152735/2 "2008-11-07T02:33:44Z")

</div>

On Nov 7, 9:06 am, Greg L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I’m curious about standards on unit testing modules.
> 
> I have a module file in my lib/ directory. Should I create a unit test  
> in test/unit directory and test it as I would any other model?

Don’t know if there’s a standard but I think it makes sense just to  
test  
it in test/unit.

> Is there any kind of naming convention used for unit test files for  
> modules (some\_name\_test.rb or some\_name\_module\_test.rb)?

Don’t know. If it’s lib/some\_name.rb then test/unit/  
some\_name\_test.rb  
seems ok with contents:  
require File.dirname( **FILE** ) + ‘/…/test\_helper’  
class SomeNameTest \< Test::Unit::TestCase  
…  
end  
Works for me at the moment.

–  
Daniel B.
