Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add 'rake test' to project

When I ran rake -T, I discovered rake test was missing. What do I need to do to get this task in there? Specifically, I want to run rake test:benchmark but that doesn't seem to be loaded. For example...

$rake test:benchmark

rake aborted!
Don't know how to build task 'test:benchmark'
like image 274
Larsenal Avatar asked Jan 27 '11 20:01

Larsenal


People also ask

How do you run a rake test?

Go to Websites & Domains and click Ruby. After gems installation you can try to run a Rake task by clicking Run rake task. In the opened dialog, you can provide some parameters and click OK - this will be equivalent to running the rake utility with the specified parameters in the command line.

Where do I put rake tasks?

rake extension and are placed in Rails. root/lib/tasks . You can create these custom rake tasks with the bin/rails generate task command. If your need to interact with your application models, perform database queries and so on, your task should depend on the environment task, which will load your application code.

How do you define a rake task?

Rake enables you to define a set of tasks and the dependencies between them in a file, and then have the right thing happen when you run any given task. The combination of convenience and flexibility that Rake provides has made it the standard method of job automation for Ruby projects.


2 Answers

My config/application.rb file was missing this line:

require 'rails/all'
like image 74
Larsenal Avatar answered Jan 04 '23 10:01

Larsenal


You only need:

require "rails/test_unit/railtie"

in your config/application.rb

like image 35
Piotrek Okoński Avatar answered Jan 04 '23 11:01

Piotrek Okoński