0

我正在制作一个 gem,它将向应用程序的控制器添加一些自定义响应程序。为了测试这一点,我需要一个位于测试目录中的虚拟应用程序,我可以加载它并以某种方式从中生成视图。

我更喜欢使用 Cucumber 来测试这个 gem,因为这是我过去使用它时最舒服的。

如何像这样在我的测试目录中生成应用程序?我至少需要一个控制器和一个模型,但不需要视图(响应器仅用于 JSON)。我可以在其中生成一个新的 Rails 应用程序/features/support/dummy吗?我将如何从我的测试套件中运行虚拟应用程序?

4

1 回答 1

0

At first, do not generate anything within features/support/. That's the place for global hooks.

Your problem sounds not hard if I understood correctly. Here is my proposed steps.

  1. Create a demo directory in project root. New demo app will be under it.

  2. Create a ruby module/class under features/support/, with methods to generate a demo app and delete it. The demo app will be simply some directories like app/contorllers for test purpose. Making a whole new Rails app sounds overkill.

  3. Create a tag for the Scenario which need generate app. Add Before and After hook for this tag to add and remove app for this Scenario, by calling the module/class in #2

于 2012-12-11T04:10:27.397 回答