Skip to content

Instantly share code, notes, and snippets.

@arturictus
Created March 19, 2015 09:01
Show Gist options
  • Select an option

  • Save arturictus/a5a30fd78cd42f642e43 to your computer and use it in GitHub Desktop.

Select an option

Save arturictus/a5a30fd78cd42f642e43 to your computer and use it in GitHub Desktop.

Revisions

  1. arturictus created this gist Mar 19, 2015.
    9 changes: 9 additions & 0 deletions rails_helper.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # spec/rails_helper.rb
    # add to your rails_helper inside the
    RSpec.configure do |config|
    config.around(:each, type: :request) do |example|
    Warden.test_mode!
    example.run
    Warden.test_reset!
    end
    end
    9 changes: 9 additions & 0 deletions warden_login.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # spec/support/warden_login.rb
    def warden_login(factory = :admin_user, opts = {})
    let(:admin_user) { create(factory, opts) }
    around(:each) do |example|
    login_as(admin_user, :scope => :admin_user)
    example.run
    logout(:admin_user)
    end
    end