3

I'm building a Rails Engine inside another rails app. The engine's rake tasks seem to get scoped to app:

# inside <app_root>/engines/engine_name
$ rake -T apartment
rake app:apartment:migrate       # Migrate all tenants

Whereas from the app's root:

#inside <app_root>/
$ rake -T apartment
rake apartment:migrate       # Migrate all tenants

My problem is when I run

# inside <app_root>/engines/engine_name
RAILS_ENV=test rake db:migrate

I get the following error:

rake aborted! Don't know how to build task 'apartment:migrate'

Seems like it should be calling the app:apartment:migrate task, but I'm not sure how to do this so I can test this engine on its own with RSpec

typeoneerror
  • 55,990
  • 32
  • 132
  • 223

1 Answers1

3

You should have a Rakefile for the engine here: <app_root>/engines/engine_name/Rakefile

Try adding this line to the bottom of it to load the rake tasks from the apartment gem:

load 'tasks/apartment.rake'
Arctodus
  • 5,743
  • 3
  • 32
  • 44