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
3
votes
1 answer

In rake, how to create a package that contains a file but renames it inside the package

I would like to create a package that contains a file but renames it inside the package. For example: Rake::PackageTask.new("rake", "1.2.3") do |p| p.package_files.include("aa.rb") end I would like aa.rb to be named bb.rb inside the…
viebel
  • 19,372
  • 10
  • 49
  • 83
3
votes
3 answers

No such file or directory - /dev/null (Errno::ENOENT)

I'm having a similar problem to this gentleman here. I've been trying to run a cucumber feature via a rake task. And I've been picking up the specified error in the title. Here's a full backtrace. And my ruby version. (When I attempted to run the…
RazokKull
  • 477
  • 1
  • 7
  • 14
3
votes
2 answers

How do you avoid Rake task name conflict for dependencies?

namespace :jobs do task :environment => [:environment] do #Something cool end end This causes a circular dependency on :environment, which I am just trying to depend on the Rails task environment. How can this be correctly setup?
Carson Reinke
  • 713
  • 5
  • 16
3
votes
2 answers

Rake "variadic" task

I need to define a rake task that can handle any amount of arguments, pretty much like variadic functions in C++. But I could not find a way to define it within rake's DSL. How can I create a rake task which can handle any amount of arguments? An…
Yossi
  • 11,778
  • 2
  • 53
  • 66
3
votes
2 answers

Newbie, about Rake task syntax

In Rake task definition, like following: desc 'SOME description' task :some_task => :environment do # DO SOMETHING end What does the :some_task in task :some_task => :environment means? Is it the method name which will be invoked in the DO…
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
3
votes
3 answers

can't activate test-unit (= 1.2.3), already activated test-unit-2.3.0

Recently I added rspec test in my rails 2.3.5 but I wasn't able to run simply rake -T command. Then I found Rails 3 - If I'm using RSpec, can I just delete the 'test' folder? and I added gem test-unit in my Gemfile. This is showing me below…
ashisrai_
  • 6,438
  • 2
  • 26
  • 42
3
votes
0 answers

How to run verbose rake db:seed Rails 6.1.3?

After successful rake db:migrate (which echoes tables creation statuses), I run rake db:seed. But rake db:seed does nothing, echoes and returns nothing. $ rake db:seed --trace ** Invoke db:seed (first_time) ** Invoke db:load_config (first_time) **…
user1185081
  • 1,898
  • 2
  • 21
  • 46
3
votes
2 answers

How to catch raised exception in rake task

I have a rake task that loops through rows in CSV file, and inside that loop, there's a begin/rescue block to catch any possible raised exception. But when I run it, it keeps on saying 'rake aborted!' and it is not entering the rescue…
Kok A.
  • 167
  • 1
  • 15
3
votes
1 answer

My rake task uses OptionParser for handling arguments. How can I invoke it from my minitest test case?

From command line I invoke the rake task as follows; rake add -- --num1 1 --num2 2 And the task is defined as follows; require 'optparse' task :add do options = {} OptionParser.new do |opts| opts.banner = "Usage: rake add [options]" …
rashila
  • 91
  • 4
3
votes
1 answer

Rake removes trailing whitespaces from parameters. How to prevent?

Having a simple rake task: task :ws, [:str] => :environment do |t, args| puts args.str.inspect end I get following results when run this task in command line: $ rake ws[' '] nil $ rake ws[' '] nil $ rake ws[' 1'] " 1" $ rake ws[' 1…
trushkevich
  • 2,657
  • 1
  • 28
  • 37
3
votes
1 answer

Why does this rake task run twice?

I have a main rake task setup_a_new_set_of_snippets.rake that I call, that then calls other tasks. So the main one looks like this: load './lib/tasks/fetch_and_create_snippets.rake' load './lib/tasks/generate_diffs_for_snippets.rake' load…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
3
votes
2 answers

NoMethodError: undefined method `within' for main:Object

I'm trying to make Capistrano deploy script. In my Capfile I make sure all rake tasks are included # Load tasks Dir.glob('config/capistrano_tasks/*.rake').each { |r| import r } Next I have a 'migrations.rake' containing: namespace :fileservice do …
3
votes
1 answer

How do you run a rake task at midnight of every single time zone?

I want to perform some actions on a user when it's midnight in his or her region. Since I want to support time zones instead of basing everything on server time, I want to cover all the possible midnights of every time zone. The idea I had so far is…
Gyt Dau
  • 35
  • 4
3
votes
1 answer

Exit from one of a series of Rake tasks and continue with the next

I have this main Rake task namespace :crawler do task main: :environment do Rake::Task['tester:first'].execute Rake::Task['tester:second'].execute Rake::Task['tester:third'].execute end end Every task runs a piece of code that…
Jack
  • 497
  • 5
  • 16
3
votes
2 answers

Custom rake task for DB: Table not found

I have a custom rake task, that creates a development DB with data for various situation. The core looks like this: namespace :db do task setup_seed: :environment do Rake::Task['db:drop'].invoke Rake::Task['db:create'].invoke …
23tux
  • 14,104
  • 15
  • 88
  • 187