Hi guys,
I'm getting some problems with my engine specs.
I've generated my engine through rails plugin new name --mountable --dummy-path=spec/dummy command
I've also ran the default rspec generator, rails g rspec:install, but when i create my migrations, run rake db:migrate, and run rspec in my engine context, i'm always getting "Migrations are pending" in test environment.
Someone faced this problem?
Similar issue here.
@igorbelo does your engine copy the migrations into the dummy app, or do you monkeypatch something so they get recognized?
In my case, I rely on the rake rake xxxx:install:migrations as described in the rails guide to have the migrations copied into spec/dummy/db/migrate.
However, what I noticed is that current active record looks for the migrations in db/migrate of the engine, rather than the dummy app (see here).
I am not sure what the best practice would be now?
Override the migration_paths so the engine migrations are ignored and the ones in the dummy app are being read via rspec / spec_helper, or should the engine hook into rails and add the migration paths so no copying of migrations is needed anymore? (E.g as described here)
For now I just have this in the spec_helper, which solves my problem: ActiveRecord::Migrator.migrations_paths = 'spec/dummy/db/migrate'
This issue seems to be more of a question on best practice for rails engines rather than an actual rspec issue, or am I missing something?
Hello @effkay, thanks for the tip, by setting ActiveRecord::Migrator.migrations_paths my app worked fine!
Sorry for this issue, but i didn't find this solution in anywhere, and it really seemed a problem.
Thanks
Most helpful comment
Similar issue here.
@igorbelo does your engine copy the migrations into the dummy app, or do you monkeypatch something so they get recognized?
In my case, I rely on the rake rake xxxx:install:migrations as described in the rails guide to have the migrations copied into
spec/dummy/db/migrate.However, what I noticed is that current active record looks for the migrations in
db/migrateof the engine, rather than the dummy app (see here).I am not sure what the best practice would be now?
Override the
migration_pathsso the engine migrations are ignored and the ones in the dummy app are being read via rspec /spec_helper, or should the engine hook into rails and add the migration paths so no copying of migrations is needed anymore? (E.g as described here)For now I just have this in the spec_helper, which solves my problem:
ActiveRecord::Migrator.migrations_paths = 'spec/dummy/db/migrate'This issue seems to be more of a question on best practice for rails engines rather than an actual rspec issue, or am I missing something?