Search code examples
ruby-on-railsrubyrakerake-taskrake-test

How to skip some test folder when running rake test


I have the following configuration for running tests of a gem:

require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
  t.libs << 'lib'
  t.libs << 'test'
  t.pattern = 'test/**/*_test.rb'
  t.verbose = false
end

inside my test folder I have a folder (let's say skipped_tests) with tests which I don't want to test with this task. Is it possible to adjust pattern to skip particular folder, something like the following:

t.pattern = 'test/^skipped_tests/*_test.rb'

Please share your thoughts on this.

Thanks


Solution

  • You could use test_files instead of pattern like this:

    t.test_files = Dir['test/**/*_test.rb'].reject do |path| 
      path.include?('skipped_test')
    end