Module: ControllerHelper

Defined in:
lib/spec_snap/controller_helper.rb

Instance Method Summary collapse

Instance Method Details

#not_signed_inObject



14
15
16
17
# File 'lib/spec_snap/controller_helper.rb', line 14

def not_signed_in
  allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, {:scope => :user})
  allow(controller).to receive(:current_user).and_return(nil)
end

#sign_in(user) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/spec_snap/controller_helper.rb', line 5

def (user)
  if user.nil?
    not_signed_in
  else
    allow(request.env['warden']).to receive(:authenticate!).and_return(user)
    allow(controller).to receive(:current_user).and_return(user)
  end
end