简体   繁体   中英

How can I use fixtures from “dummy” in my Rails engine tests?

I've created a Rails engine

> 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

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 }

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

According to a discussion I've had on Github :

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

  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM