Reputation: 4485
When I run rake test
, it doesn't run tests in a new folder that I have created.
By default Rails has this folder inside the test folder:
When I run test, i.e rake test
, it tests the content of the test folder.
I have added an api folder inside the test folder.
The contents of the api folder are tested when I do this: rake test:run TEST=test/api/users_test.rb
But, when I just do rake test
, it doesn't test the content of the api folder. How to configure it?
Upvotes: 4
Views: 784
Reputation: 37617
rake test:all
should run all tests in subdirectories of the test folder, even non-default ones.
If you want to make a rake test:api
task: Do rake -w test | grep '^rake test'
to see the files (in the railties gem) where Rails defines test tasks. In testing.rake you'll see how Rails defines tasks for the default subdirectories. Make a lib/tasks/test.rake and do the same thing for your new subdirectory:
Rails::TestTask.new('api' => "test:prepare") do |t|
t.pattern = "test/api/**/*_test.rb"
end
Upvotes: 3