ruby-on-railsrspecautotestzentest

Rails: using ZenTest / autospec to test specs in new directories


I am adding a directory for services classes in my rails application: app/services

I would like to add specs for these classes in the directory: spec/services

I added a spec to spec/services, but running autospec does not run the example.

Is there a way to configure autospec to run examples in new directories?

Thanks.


Solution

  • I believe I have found the answer to my question. I added a file ".autotest" to the root of my project with the following content:

    Autotest.add_hook :initialize do |at|      
      at.add_mapping(%r%^spec/services/.*_spec\.rb$%) do
        at.files_matching(%r%^spec/services/.*_spec\.rb$%)
      end
    end
    

    Source: http://www.ruby-forum.com/topic/187144