Search code examples
ruby-on-railsrubyautotest

How autotest in rails can run integration tests?


I have this in .autotest:

Autotest.add_hook :initialize do |autotest|
  autotest.add_mapping(/^spec\/requests\/.*_spec\.rb$/) do
    autotest.files_matching(/^spec\/requests\/.*_spec\.rb$/)
  end  
end

when I run autotest it initially runs all unit and integration (\requests) tests. Then when I change a file it runs only its unit tests and not the integrations.

any idea?


Solution

  • You need to install and require the fsevent gem.

    So:

    sudo gem install autotest-fsevent
    

    Or just gem install depending if you are using RVM

    Then in your .autotest put the following require:

    require 'autotest/fsevent'
    

    You should also insure that it isn't running the whole test suite by going into the window/tab that is running autotest and hit ctrl-c once. That will restart your autotest and run all the tests that autotest is covering. I have found that autotest runs the most recent spec first then all the tests.

    Hope this helps!