require "rehearsal/version" require "rehearsal/engine" module Rehearsal def self.included(base) base.extend ClassMethods base.helper_method :rehearsing? base.before_filter :require_http_basic_auth end module ClassMethods def rehearse_with(username, password) class_eval do define_method(:username) do username end define_method(:password) do password end end Rehearsal.config.enabled = true end end class << self def configure yield(config) end def config=(config_instance) @config = config_instance end def config @config ||= Configuration.new end end private def require_http_basic_auth authenticate_or_request_with_http_basic do |username, password| username == self.username && password == self.password end if rehearsing? end def rehearsing? return unless Rehearsal.config.enabled Rails.env.to_sym == Rehearsal.config.env end end