dredd-rack icon indicating copy to clipboard operation
dredd-rack copied to clipboard

Task definition can't be in lib/tasks/

Open rylnd opened this issue 9 years ago • 2 comments

# lib/tasks/dredd_rack.rake
require 'dredd/rack'

Dredd::Rack::RakeTask.new

causes the same symptoms as described in #8.

The reason is that the hook that loads all these tasks, Rails.application.load_tasks, seems to load local tasks before the environment task, such that this condition is never met.

I wish I had the time and/or knowledge to figure out how to make this work. For now, placing the task definition after the load_tasks hook in the Rakefile is a reasonable workaround.

rylnd avatar May 13 '15 15:05 rylnd

Hi @rylnd!

Thanks for investigating this! There must be an explanation in the Rails initialisation process, I'll take a look at it.

gonzalo-bulnes avatar May 14 '15 01:05 gonzalo-bulnes

Would something like this help? (Seen in the grape-apiary docs)

spec = Gem::Specification.find_by_name 'grape-apiary'
load "#{spec.gem_dir}/lib/grape-apiary/tasks/grape-apiary.rake"

gonzalo-bulnes avatar Feb 18 '17 13:02 gonzalo-bulnes