Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 759
Mark Bolusmjak Avatar asked Sep 16 '25 04:09

Mark Bolusmjak


1 Answers

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.

like image 137
Mark Bolusmjak Avatar answered Sep 17 '25 19:09

Mark Bolusmjak