如何在我的Rails引擎测试中使用“dummy”中的灯具?

时间:2021-11-28 20:31:09

I've created a Rails engine

我创建了一个Rails引擎

> rails plugin new my_engine --mountable

> rails plugin new my_engine --mountable

In the dummy app, I create a model and fixtures...

在虚拟应用程序中,我创建了一个模型和夹具......

> cd test/dummy
> rails generate resource Owner name:string

> cd test / dummy> rails generate resource所有者名称:string

I ensure there is fixture data.
I write a test in the dummy app to make sure fixtures are working.
test("owners"){assert Owner.all.count > 0 }

我确保有夹具数据。我在虚拟应用程序中编写测试以确保灯具正常工作。 test(“所有者”){assert Owner.all.count> 0}

It fails.

So, how does one use fixtures from test/dummy to test an engine?

那么,如何使用测试/假人的夹具来测试引擎呢?


Note I have opened an issue on github where this is being discussed: https://github.com/rails/rails/issues/19477

1 个解决方案

#1


0  

According to a discussion I've had on Github:

根据我在Github上的讨论:

  1. rails generate ... from within the dummy app is basically doing the wrong thing when it puts fixtures in dummy/test/fixtures.

    从虚拟应用程序中生成的rails实际上在将它们放入虚拟/测试/固定装置时做错了。

  2. Fixtures can only live in one directory.

    灯具只能存放在一个目录中。

The solution then, is move them manually to the engine's test/fixtures directory. Or patch Rails.

然后,解决方案是将它们手动移动到引擎的test / fixtures目录。或补丁Rails。

#1


0  

According to a discussion I've had on Github:

根据我在Github上的讨论:

  1. rails generate ... from within the dummy app is basically doing the wrong thing when it puts fixtures in dummy/test/fixtures.

    从虚拟应用程序中生成的rails实际上在将它们放入虚拟/测试/固定装置时做错了。

  2. Fixtures can only live in one directory.

    灯具只能存放在一个目录中。

The solution then, is move them manually to the engine's test/fixtures directory. Or patch Rails.

然后,解决方案是将它们手动移动到引擎的test / fixtures目录。或补丁Rails。