从其父应用程序运行Rails引擎的规范 [英] Running spec for a rails engine from its parent app

查看:62
本文介绍了从其父应用程序运行Rails引擎的规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有适用于父应用程序的rspec套件,也有一些附加引擎的规范。我要用一个命令运行它们。有没有办法将我的gem路径包含到rspec加载路径中?还是应该为此编写rake任务?

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?

推荐答案

我认为这是一个有趣的问题,但我认为Rails Engines应该被视为独立的代码库,因此未在您的父应用中进行测试。效果是您将在父应用程序中对待Rails Engine的方式与对待其他宝石(例如,EG,devise,实际上是Rails Engine的方式)的方式非常相似。

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).

假设您具有依赖于Rails Engine功能的父应用程序功能。在这种情况下,我将编写一个测试来表明我的父应用程序的功能可以与Rails Engine一起使用。我不会编写确保Rails Engine能够按预期工作的测试,因为这些测试属于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.

当您同时开发父级应用程序和Rails Engine时,我意识到这种方法不适用于实际工作场景。

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

这篇关于从其父应用程序运行Rails引擎的规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆