I've been trying for some time to get rspec+devise+factory_girl_rails setup in an engine.
My application structure is like this:
Parent app: mainly doing authentication
--> Engine 1: Admin interface
--> Engine 2: CRUD on resources
So, the user logs into the parent app. Engine 1 will allow me to create new logins. Engine 2 will be an index of models that can be added/edited/removed etc.
So, my question is this: where should authentication oriented tests go? In the core app (where auth is done) or the engines themselves?
I've been trying to get rspec+devise working together in the engines with tests like:
describe "Editing a record" do context "User is logged in" do it "should return success" do login_user FactoryGirl.build(:user) get 'resource/1/edit' expect(response.response_code).to eq 200 end end context "User is not logged in" do it "should return unauthorized" do get 'resource/1/edit' expect(response.response_code).to eq 403 end end end
But I'm not sure it's possible to do this, without installing Devise and creating a devise user model in every engine I may create.