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

前端 未结 7 1499

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

7条回答
  •  说谎
    说谎 (楼主)
    2021-01-30 07:27

    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.

提交回复
热议问题