> Let's see the helper method please.

 ---------------spec/support/controller_macros.rb: start ----------

module ControllerMacros
  include Devise::TestHelpers

  # sets up an instance of a non-admin user
  def login_user
    before(:each) do
      @request.env["devise.mapping"] = Devise.mappings[:user]
      @user = FactoryGirl.create(:user)
      sign_in @user
    end
  end

  # sets up an instance of a admin user
  def login_admin_user
    before(:each) do
      @request.env["devise.mapping"] = Devise.mappings[:user]
      @admin_user = FactoryGirl.create(:admin)
      sign_in @admin_user
    end
  end
end

 ---------------spec/support/controller_macros.rb: end    ----------

It works for my existing controller specs and it's based on
https://github.com/plataformatec/devise/wiki/How-To:-Controllers-and-Views-tests-with-Rails-3-(and-rspec)
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to