Jump to content

The ultimate community for Ruby on Rails developers.


Testing engines


  • Please log in to reply
No replies to this topic

#1 polivers



  • Members
  • 1 posts

Posted 24 October 2013 - 02:53 PM

Hi all,

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

  context "User is not logged in" do
    it "should return unauthorized" do
      get 'resource/1/edit'
      expect(response.response_code).to eq 403

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.


Any ideas?

Also tagged with one or more of these keywords: devise

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users