Sha256: 2177912e18a8dff1f735031c0cc0047db832519b26caa26f228a650d98c2ac4f

Contents?: true

Size: 478 Bytes

Versions: 6

Compression:

Stored size: 478 Bytes

Contents

module ControllerHelpers
  def login_with(user = double('user'), scope = :user)
    current_user = "current_#{scope}".to_sym
    if user.nil?
      allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, {:scope => scope})
      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

6 entries across 6 versions & 1 rubygems

Version Path
happy_seed-0.0.19 lib/generators/happy_seed/base/templates/spec/support/controller_helpers.rb
happy_seed-0.0.18 lib/generators/happy_seed/base/templates/spec/support/controller_helpers.rb
happy_seed-0.0.17 lib/generators/happy_seed/base/templates/spec/support/controller_helpers.rb
happy_seed-0.0.16 lib/generators/happy_seed/base/templates/spec/support/controller_helpers.rb
happy_seed-0.0.15 lib/generators/happy_seed/base/templates/spec/support/controller_helpers.rb
happy_seed-0.0.14 lib/generators/happy_seed/base/templates/spec/support/controller_helpers.rb