Sha256: 1075bafa246f6815b45d42d8808b52a318e04a8292a12872d750515c8cb0c7f6

Contents?: true

Size: 665 Bytes

Versions: 5

Compression:

Stored size: 665 Bytes

Contents

module ControllerMacros
  def login_user(user)
    @request.env['devise.mapping'] = Devise.mappings[:user]
    sign_in user
  end
end

shared_context 'authentication for routes' do
  let(:warden) do
    instance_double('Warden::Proxy').tap do |warden|
      allow(warden).to receive(:authenticate?).with(scope: :user)
        .and_return(authenticated?)
      allow(warden).to receive(:user).with(:user).and_return(user)
    end
  end
  let(:user) { instance_double(User) }
  let(:authenticated?) { true }
end

def simulate_running_with_devise
  stub_const(
    'Rack::MockRequest::DEFAULT_ENV',
    Rack::MockRequest::DEFAULT_ENV.merge('warden' => warden)
  )
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
date_book-0.0.6 spec/support/controller_macros.rb
date_book-0.0.5 spec/support/controller_macros.rb
date_book-0.0.3 spec/support/controller_macros.rb
date_book-0.0.2 spec/support/controller_macros.rb
date_book-0.0.1 spec/support/controller_macros.rb