You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
asciinema.org/spec/support/authentication.rb

30 lines
605 B
Ruby

module Asciinema
module Test
module Authentication
attr_accessor :current_user
def ensure_authenticated!
unauthenticated_user unless current_user
end
end
module ControllerHelpers
def login_as(user)
controller.current_user = user
end
def logout
controller.current_user = nil
end
end
end
end
RSpec.configure do |config|
config.before(:each, type: :controller) do
controller.class_eval { include Asciinema::Test::Authentication }
end
config.include Asciinema::Test::ControllerHelpers, type: :controller
end