Can spork work with rake tasks?

2019-04-21 12:15发布

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?

4条回答
在下西门庆
2楼-- · 2019-04-21 12:37

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
查看更多
该账号已被封号
3楼-- · 2019-04-21 12:41

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

查看更多
等我变得足够好
4楼-- · 2019-04-21 12:43
rake test:units
testdrb -I test/ test/unit/

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

rake test:integration
testdrb -I test/ test/integration/
查看更多
放荡不羁爱自由
5楼-- · 2019-04-21 12:54

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.

查看更多
登录 后发表回答