I would like to write rake tasks to customize tests. For example, to run unit tests, I created a file with the following code and saved it as lib/tasks/test.rake:
task :do_unit_tests do
cd #{Rails.root}
rake test:units
end
Running rake do_unit_tests throws an error: can't convert Hash into String.
Working in Rails 3.0.7 and using built-in unit test framework.
Thanks.
There is no need to
cd. You can simply…But if you really want to
cd, that’s how you call shell instructions:Well, in fact there is a shorter version. The
cdinstruction have a special alias as Chris mentioned in the other answer, so you can just…If you want to go further, I recommend Jason Seifer’s Rake Tutorial and Martin Fowler’s Using the Rake Build Language articles. Both are great.