require 'kit/spec' # # Factories # rad.users require 'users/factories' # # Routing helpers # rspec.include Rad::Controller::Authenticated::RoutingHelper # # User helpers # Models::User.class_eval do def self.anonymous @anonymous ||= Factory.build :anonymous end end # # Authorization stub # AUTHENTICATION_CONTROLLERS = rad.extension :authentication_controllers do [::Rad::Controller::Authenticated] end AUTHENTICATION_CONTROLLERS.each do |auth| auth.class_eval do alias_method :prepare_current_user_without_test, :prepare_current_user def prepare_current_user_with_test; end alias_method :prepare_current_user, :prepare_current_user_with_test end end rspec do def self.with_auth before :all do AUTHENTICATION_CONTROLLERS.each do |auth| auth.class_eval do alias_method :prepare_current_user, :prepare_current_user_without_test end end end after :all do AUTHENTICATION_CONTROLLERS.each do |auth| auth.class_eval do alias_method :prepare_current_user, :prepare_current_user_with_test end end end end end