Sha256: d71a49f076aea177371a370b8e71c0368c141cfee855a0bf8f8649f58cd3cf8f

Contents?: true

Size: 520 Bytes

Versions: 1

Compression:

Stored size: 520 Bytes

Contents

module ControllerHelpers
  # https://github.com/plataformatec/devise/wiki/How-To:-Stub-authentication-in-controller-specs
  def sign_in_stub(user = double('user'))
    if user.nil?
      allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, {:scope => :user})
      allow(controller).to receive(:current_user).and_return(nil)
    else
      allow(request.env['warden']).to receive(:authenticate!).and_return(user)
      allow(controller).to receive(:current_user).and_return(user)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pwb-0.0.1 spec/support/controller_helpers.rb