Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: How to test code in the lib/ directory?

I have a model which gets its data from a parser object. I'm thinking that the parser class should live in the lib/ directory (although I could be persuaded that it should live soewhere else). The question is: Where should my unit tests for the parser class be? And how do I ensure that they are run each time I run rake test?

like image 492
KaptajnKold Avatar asked Apr 28 '09 16:04

KaptajnKold


1 Answers

In the Rails application I'm working on, I decided to just place the tests in the test\unit directory. I will also nest them by module/directory as well, for example:

lib/a.rb   => test/unit/a_test.rb lib/b/c.rb => test/unit/b/c_test.rb 

For me, this was the path of last resistance, as these tests ran without having to make any other changes.

like image 51
Matt Haley Avatar answered Sep 20 '22 15:09

Matt Haley