Can spork work with rake tasks?
Asked Answered
O

4

10

Rake tasks suffer from the same problem as running tests: the Rails bootup process takes a long time before the task is even running.

Is there a way to integrate spork and rake together?

Ogletree answered 30/9, 2011 at 18:36 Comment(1)
I added my own answer below for zeus (github.com/burke/zeus). There is also the rails/command gem that DHH is working on (github.com/rails/commands).Ogletree
O
4

I discovered zeus today. It's the best thing ever, so I'm changing my answer to zeus:

https://github.com/burke/zeus

zeus rake my:special:task

Ogletree answered 5/12, 2012 at 0:29 Comment(1)
Fascinating... opens tricorderFractocumulus
J
7

You can use the irake gem which makes it possible to execute rake tasks from the console.

Add this to Gemfile:

gem 'irake'

Then bundle and start console

$ bundle install
$ rails console

...and wait for the Rails environment to load (only once). Then you can do:

rake "db:migrate"

If you want to list tasks, you can:

Rake::Task.tasks.each{|t| puts t.name }; nil
Justificatory answered 4/7, 2012 at 20:34 Comment(0)
O
4

I discovered zeus today. It's the best thing ever, so I'm changing my answer to zeus:

https://github.com/burke/zeus

zeus rake my:special:task

Ogletree answered 5/12, 2012 at 0:29 Comment(1)
Fascinating... opens tricorderFractocumulus
L
3
rake test:units
testdrb -I test/ test/unit/

rake test:functionals
testdrb -I test/ test/functional/

rake test:integration
testdrb -I test/ test/integration/
Lusaka answered 4/3, 2012 at 17:15 Comment(0)
P
1

There is no standard out of the box solution as i know.

Rake does not have --drb option and spork can't help here. Sure, custom solution is possible. This will require extension of rake runner.

I think rake tasks run not so often as tests, that why question is not addressed yet.

Perfectionism answered 26/10, 2011 at 8:46 Comment(1)
Thanks. I basically want something like spin (github.com/jstorimer/spin), which forks a loaded Rails process and all the gems.Ogletree

© 2022 - 2024 — McMap. All rights reserved.