Skip to content

Instantly share code, notes, and snippets.

@krasio
Created November 18, 2011 08:38

Revisions

  1. krasio revised this gist Nov 18, 2011. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions authentication_macros.rb
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,9 @@ def sign_in_user
    let(:current_user) { Factory.stub(:user) }

    before do
    sign_in current_user
    warden.stub(:authenticate => current_user)
    warden.stub(:authenticate! => current_user)
    sign_in current_user
    warden.stub(:authenticate => current_user)
    warden.stub(:authenticate! => current_user)
    end
    end
    end
  2. krasio created this gist Nov 18, 2011.
    12 changes: 12 additions & 0 deletions authentication_macros.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # spec/support/macros/authentication_macros.rb
    module AuthenticationMacros
    def sign_in_user
    let(:current_user) { Factory.stub(:user) }

    before do
    sign_in current_user
    warden.stub(:authenticate => current_user)
    warden.stub(:authenticate! => current_user)
    end
    end
    end
    5 changes: 5 additions & 0 deletions configuration.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # spec/support/configuration.rb
    RSpec.configure do |config|
    config.include Devise::TestHelpers, :type => :controller
    config.extend AuthenticationMacros, :type => :controller
    end