Questions tagged [rake-task]

Task is the basic unit of work in a Rakefile.

Tasks have associated actions (possibly more than one) and a list of prerequisites. When invoked, a task will first ensure that all of its prerequisites have an opportunity to run and then it will execute its own actions.

Tasks are not usually created directly using the new method, but rather use the file and task convenience methods.

689 questions
4
votes
2 answers

RAILS - Passing parameters to a Rake task

i need some help :( well, i need to pass 1 parameter to a rake task. And I'm not 100% sure how to do this, I've tried a lot of things, but nothing actually works. it's look like this : { task :export, [:arg1] => :environment do puts…
miss_M
  • 129
  • 2
  • 11
4
votes
3 answers

Executing a rake task after `rake test`

I'm trying to create a rake task for a Rails 4.0.2 (Ruby 2.2.3) project that creates the test database along with seeding, then runs the test suite, and finally cleanups afterwards by dropping the test database. Here's a simple example below: task…
Tyler Amos
  • 101
  • 7
4
votes
1 answer

How can I call a rake task with default args from the commad line?

I have a rake task to generate a given amount of items in a xml file. If nothing is given I want to have a default. By now only 50 gets printed, but I would like to have a variable amount here, how would I call it from the command line? namespace…
Daniel Schmidt
  • 11,605
  • 5
  • 38
  • 70
4
votes
0 answers

Pass test arguments via my Rake::TestTask . What am I doing wrong?

I have a Rakefile defined with code like so: namespace :app do |args| desc "Run App tests from lib/app_tests/test_*.rb" Rake::TestTask.new do |t,args| t.name = "testApp" t.libs << 'lib/pageobjects/app_page_objects' t.test_files =…
djangofan
  • 28,471
  • 61
  • 196
  • 289
4
votes
1 answer

How do you use multiple tasks using Rake::TestTask?

I am running Minitest with Rake and would like to have two separate Rake tasks. I have added the following: require 'rake/testtask' task :default => [:test] task :quick => [:unit] Rake::TestTask.new do |t| puts 'within test task' t.libs.push…
Daryn
  • 3,394
  • 5
  • 30
  • 41
4
votes
1 answer

Can you access environment variables in a rake task?

If I set up some environment variables in an application.yml file is there a way to access them inside a rake task? Doing env['VARIABLE_NAME'] doesn't work and neither does Rails.env['VARIABLE_NAME'] My rake task: task :create_new_assignment =>…
TheWebs
  • 12,470
  • 30
  • 107
  • 211
4
votes
2 answers

what is the right way to use CLEAN rake task?

This is what I'm trying to do in my Rakefile: require 'rake/clean' CLEAN = ['coverage'] This is what I see in the log: $ rake /code/foo/Rakefile:29: warning: already initialized constant…
Bernie Noel
  • 304
  • 2
  • 10
4
votes
1 answer

How do I programmatically extract a rake task's description?

I'm attempting to capture the equivalent of rake -D programmatically. I can load the Rakefile I'm targeting and see a list of tasks, but I can not figure out how to get the descriptions. This will let me see the tasks that I am interested in: …
cyberswat
  • 163
  • 1
  • 9
4
votes
3 answers

Rails rake task on Heroku: Disable displaying the SQL log on the screen

I am running a rails 3.2 app in Heroku Cedar stack. When I locally execute rake tasks that involve querying the database, the screen log does not show the detail of the SQL queries. On the other hand, when I run the same task on the Heroku…
idejuan
  • 461
  • 2
  • 4
  • 11
4
votes
2 answers

How can I run a ruby class from rake file?

I want to run a ruby class from a sample.rake file. Consider myruby.rb is a ruby file. I want to run this from sample.rake like ruby myruby.rb
Gnik
  • 7,120
  • 20
  • 79
  • 129
4
votes
1 answer

How can I get access to the app variable in a rake task

How can I get an instance of ActionDispatch::Integration::Session in a rails rake task. I want to be able to call: app.get '/' like you can do in the rails console.
Trent Earl
  • 3,517
  • 1
  • 15
  • 20
4
votes
1 answer

rake db:test:prepare does not setup test database

I am using Rails 4.0.0.rc1 with sqlite3 and trying to setup the test database for testing. bundle exec rake db:test:prepare did not create the tables in the test database. After following this question I managed to setup the test database by running…
Indika K
  • 1,332
  • 17
  • 27
4
votes
1 answer

Run rake db:drop without failure if database doesn't exist

This comment says: db:drop can run without failure when db does not exist This is exactly what I need: I need to run db:drop but without throwing an exception or halt my whole process if the database doesn't exist, just delete the database if it…
Tamer Shlash
  • 9,314
  • 5
  • 44
  • 82
4
votes
1 answer

Rake - Adding to default task

I am using a third party gem that gives me the ability to execute some tests using the rake command: rake jasminerice:run Is it possible to include the task as part of default rake task? (i.e. when I run rake then rake jasminerice:run is added to…
alexs333
  • 12,143
  • 11
  • 51
  • 89
4
votes
2 answers

Make a rake task fail if system call return error

I have a Rakefile that I use to automate some tasks in my project. Inside some tasks, I call system, but, even if the process return an error, task continues without any issue. How can I avoid that? I want to make rake exit when some subprocess…
caarlos0
  • 20,020
  • 27
  • 85
  • 160