Module: Monban::Test::ControllerHelpers
- Defined in:
- lib/monban/test/controller_helpers.rb
Overview
Note:
these have only been tested with rspec controller specs
These are test helpers for controller specs
Class Method Summary collapse
Instance Method Summary collapse
-
#sign_in(user) ⇒ Object
Signs a user in for tests.
-
#sign_out ⇒ Object
Signs the user out in tests.
-
#warden ⇒ Object
A mock of warden for tests.
Class Method Details
.included(base) ⇒ Object
9 10 11 12 13 |
# File 'lib/monban/test/controller_helpers.rb', line 9 def self.included(base) base.class_eval do setup :store_controller_for_warden, :warden if respond_to?(:setup) end end |
Instance Method Details
#sign_in(user) ⇒ Object
Signs a user in for tests
17 18 19 |
# File 'lib/monban/test/controller_helpers.rb', line 17 def sign_in(user) @controller.sign_in(user) end |
#sign_out ⇒ Object
Signs the user out in tests
22 23 24 |
# File 'lib/monban/test/controller_helpers.rb', line 22 def sign_out @controller.sign_out end |
#warden ⇒ Object
A mock of warden for tests
27 28 29 30 31 32 33 34 |
# File 'lib/monban/test/controller_helpers.rb', line 27 def warden @warden ||= begin manager = Warden::Manager.new(nil) do |config| config.merge! Monban.warden_config end @request.env['warden'] = Warden::Proxy.new(@request.env, manager) end end |