Reputation: 2257
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
Upvotes: 2
Views: 3253
Reputation: 66
One option is to use a FileList
with the test_files
attribute. It may be more concise (and/or precise) than performing the reject manually.
So the OP's example would become:
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.test_files = FileList['test/**/*_test.rb'].exclude('test/skipped_tests/**/*')
t.verbose = false
end
Upvotes: 0
Reputation: 19228
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
Upvotes: 3