1

I am using rails 4.2 and i am trying to run test using the command rake test.I am trying to use plv8 extention so i create it manually from psql console, then when i run the test it seems like it has deleted that extension from postgres. I looked into rails 4.2 project and i noticed that they brought test:db:prepare back. This is what is deleting the plv8 extension every time. how can i add a pice of code that will run after the test:db:prepare or test:db:create?

I am not a big fan of modifying Rakefile solution.

fenec
  • 5,637
  • 10
  • 56
  • 82

1 Answers1

1

You can name multiple tasks inline:

rake test:db:create test:db:prepare custom:task

Or when you create a new rake task you can make it dependent on any other task:

desc "the dependent task will run before this one"
task my_task: :other_task do
   # stuff
end

You can also arbitrarily invoke other tasks:

Rake::Task['db:test:prepare'].invoke

More info here: http://jasonseifer.com/2010/04/06/rake-tutorial and here: How to run Rake tasks from within Rake tasks?

Community
  • 1
  • 1
DiegoSalazar
  • 13,361
  • 2
  • 38
  • 55