rake icon indicating copy to clipboard operation
rake copied to clipboard

Rake FileList doesn't resolve paths inside namespace

Open abhijitnandy opened this issue 7 years ago • 2 comments

Faced this issue in Windows. Haven't tried it on Linux.

In the following, the test files don't get picked up.

namespace :app do
  task :test do
    Rake::TestTask.new do |t|
      t.libs << "tests"
      t.test_files = FileList["server/tests/ts_*.rb"]
    end
  end
end

However, from inside the 'server' folder, this works perfectly fine -

task :test do
  Rake::TestTask.new do |t|
    t.libs << "tests"
    t.test_files = FileList["tests/ts_*.rb"]
  end
end

Am I doing something wrong? I tried many different variations but couldn't get it to work at all.

abhijitnandy avatar Jun 03 '18 02:06 abhijitnandy

Hi, I cannot explain about it well, But I wrote codes with two ways. Please try it.

namespace :app do
  Rake::TestTask.new(:test) do |t|
    t.libs << "tests"
    t.test_files = FileList["server/tests/ts_*.rb"]
  end
end
Rake::TestTask.new('app:test') do |t|
  t.libs << "tests"
  t.test_files = FileList["server/tests/ts_*.rb"]
end

I hope this will be of some help.

owlworks avatar Jun 22 '18 06:06 owlworks

This did work although now I can't add description for the specific task.

How I ended up resolving it was creating another rakefile under 'server' by a different name - 'raketest' and called that from my parent rakefile -

namespace :app do
  desc "to test all apis"
  task :test do
    Dir.chdir 'server' do
      puts `rake -f raketest.rb test`
    end
  end
end

abhijitnandy avatar Jun 23 '18 11:06 abhijitnandy