Hello all.

The Rails Engines documentation[1] was really quite good for understanding 
how to write engines. However, it left me with a question which I've been 
unable to answer.

Say I'm writing the engine discussed in the documentation (a blog). The 
`Post` model doesn't need to know anything about its author, and this 
engine doesn't need to deal with accounts in any way, but it makes sense 
for posts to _have_ an author, so we make the class for the author 
configurable and we say that the `Post` model `belongs_to` it. The engine 
can then simply make use of whatever account scheme is in use in the main 
application.

How then do we write tests for the `Post` model if the engine doesn't 
contain a model for the author? I'm using FactoryGirl and I tried just 
putting together a factory for a user, but it doesn't work without a 
corresponding table. I suppose I could create a basic `Author` class within 
the generated `test/dummy` application, but then all the tests would have 
to be put in there as well, which feels a little nasty to me (I just want 
my tests in an obvious place, I guess). I think a solution is probably 
outside of the testing setup being used (rspec, minitest, fixtures or 
factories, etc.).

I feel like this is a fairly typical use for an engine, so I thought maybe 
some of you had run into this issue before. I appreciate any help!

[1]: http://guides.rubyonrails.org/engines.html

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/b677140e-15ce-4223-83fc-b1ab3f597e95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to