Module: Clearance::Testing::Helpers

Included in:
ActionController::TestCase
Defined in:
lib/clearance/testing/helpers.rb

Instance Method Summary collapse

Instance Method Details

#setup_controller_request_and_responseObject



4
5
6
7
# File 'lib/clearance/testing/helpers.rb', line 4

def setup_controller_request_and_response
  super
  @request.env[:clearance] = Clearance::Session.new(@request.env)
end

#sign_inObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/clearance/testing/helpers.rb', line 9

def 
  unless defined?(FactoryGirl)
    raise(
      RuntimeError,
      "Clearance's `sign_in` helper requires factory_girl"
    )
  end

  factory = Clearance.configuration.user_model.to_s.underscore.to_sym
   FactoryGirl.create(factory)
end

#sign_in_as(user) ⇒ Object



21
22
23
24
# File 'lib/clearance/testing/helpers.rb', line 21

def (user)
  @controller. user
  user
end

#sign_outObject



26
27
28
# File 'lib/clearance/testing/helpers.rb', line 26

def sign_out
  @controller.sign_out
end