factory bot - Rails Engines: How to write tests that depend upon main app models? -


the rails engines documentation quite understanding how write engines. however, left me question i've been unable answer.

say i'm writing engine discussed in documentation (a blog). post model doesn't need know author, , engine doesn't need deal accounts in way, makes sense posts have author, make class author configurable , post model belongs_to it. engine make use of whatever account scheme in use in main application.

how write tests post model if engine doesn't contain model author? i'm using factorygirl , tried putting factory user, doesn't work without corresponding table. suppose create basic author class within generated test/dummy application, tests have put in there well, feels little nasty me (i want tests in obvious place, guess).

the answer quite simple: use test/dummy application. generate author class within test/dummy, write factory in test/factories , use else. don't have write tests within dummy application. more information (including quick tutorial) here:

https://rainveiltech.com/posts/rails-writing-engine-tests-that-depend-on-main-application-models


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -