Mark Bolusmjak
Mark Bolusmjak

Reputation: 24399

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

Upvotes: 4

Views: 841

Answers (1)

Mark Bolusmjak
Mark Bolusmjak

Reputation: 24399

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.

Upvotes: 2

Related Questions