Reputation: 1286
Is there a standard help command for individual rake tasks?
rake -h
displays the options for rake.
rake -D
describes the rake tasks.
rake mytask
runs mytask.
Is there something like rake -h mytask
that would describe mytask, and list its optional and/or required arguments?
For example, the following code will run an individual test in rails:
rake test TEST=path_to_test
How do I discover that TEST=path_to_test is an optional argument to rake test?
Upvotes: 9
Views: 3351
Reputation: 679
TEST=path_to_test
is setting an environment variable. So if rake -D test
doesn't give you any information on how environment variables are being used in the rake task, then you have to resort to looking at the source code or alternative documentation. And looking at the source code, there are only two environment variables being checked in Rails rake test: TEST
and TESTOPTS
, the latter is used in Minitest that is packaged with Ruby and used in Rails testing.
Documentation in Rails gives an example:
rake test TEST=path/to/test.rb TESTOPTS="--name=test_something"
Other options include --color
and --fail-fast
(Reference: https://github.com/rails/rails/blob/df74da026b9210a9cb6258e7029cafcc02aa6d15/guides/source/testing.md)
(I've added this answer for anyone in the future looking into this, like me.)
Alternatively, you can run the test outside of rake. Not sure if that makes it faster.
For example, running "explicit class layout" test in MailLayoutTest can be done by:
ruby -Itest test/mail_layout_test.rb -n test_explicit_class_layout
Upvotes: 0
Reputation: 24815
The command rake -D test
does not on my system. Instead you can use
# list test command with details
rake test -D
# list all test tasks with description
rake test -T
# list all test tasks even without description(Recommened)
rake test -T -A
Upvotes: 5
Reputation: 7616
The -D
accepts a pattern. So you can use that.
Examples:
rake -D db
rake -D db:migrate
Upvotes: 1