#test.rake desc 'example rake test that only runs in dev and test' namespace :test do task :do_something do if Rails.env.development? || Rails.env.test? "do your stuff here" end end end # ./Rakefile task test: %w(test:do_something) task default: [:test]