Running spec for a rails engine from its parent ap

2020-07-10 06:03发布

问题:

I have rspec suite for parent app, and also some spec for engines attached. What I want is to run them with one command. Is there a way to include my gems paths into rspec load path? Or should I write rake task for this?

回答1:

I think this is an interesting question, but my opinion is that Rails Engines should be treated as an independent code base and therefore not tested in your parent app. The effect is that you'd treat a Rails Engine in your parent app much like you treat other gems (EG, devise, which is actually a Rails Engine).

But let's say you have parent app functionality that relies on a Rails Engine feature. In that case, I would write a test to show that my parent app's functionality works in conjunction with the Rails Engine. I would not write the test ensuring that the Rails Engine works as it is supposed to because those tests belong in the Rails Engine code base, not the parent app.

I realize this methodology does not apply perfectly in real work scenarios when you are simultaneously developing the parent app and the Rails Engine.