Break up DependencyModule's dual function of providing a "depend_on" DSL and "included" block DSL into separate modules. But, unify both approaches under AS::Concern.
This commit is contained in:
parent
de203245af
commit
4e50a35fa2
@ -1,6 +1,6 @@
|
||||
module AbstractController
|
||||
module Benchmarker
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on Logger
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
module AbstractController
|
||||
module Callbacks
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on ActiveSupport::NewCallbacks
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
module AbstractController
|
||||
module Helpers
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on Renderer
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
module AbstractController
|
||||
module Layouts
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on Renderer
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
module AbstractController
|
||||
module Logger
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class DelayedLog
|
||||
def initialize(&blk)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
module AbstractController
|
||||
module Renderer
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on AbstractController::Logger
|
||||
|
||||
|
@ -26,7 +26,7 @@ module ActionController #:nodoc:
|
||||
#
|
||||
# See docs on the FlashHash class for more details about the flash.
|
||||
module Flash
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# TODO : Remove the defined? check when new base is the main base
|
||||
depends_on Session if defined?(ActionController::Http)
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActionController
|
||||
module FilterParameterLogging
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# TODO : Remove the defined? check when new base is the main base
|
||||
if defined?(ActionController::Http)
|
||||
|
@ -3,7 +3,7 @@
|
||||
# FIXME: helper { ... } is broken on Ruby 1.9
|
||||
module ActionController #:nodoc:
|
||||
module Helpers #:nodoc:
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
# Initialize the base module to aggregate its helpers.
|
||||
|
@ -3,7 +3,7 @@ class InvalidAuthenticityToken < ActionControllerError #:nodoc:
|
||||
end
|
||||
|
||||
module RequestForgeryProtection
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# TODO : Remove the defined? check when new base is the main base
|
||||
if defined?(ActionController::Http)
|
||||
|
@ -2,7 +2,7 @@ module ActionController #:nodoc:
|
||||
# Methods for sending arbitrary data and for streaming files to the browser,
|
||||
# instead of rendering.
|
||||
module Streaming
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# TODO : Remove the defined? check when new base is the main base
|
||||
if defined?(ActionController::Http)
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActionController #:nodoc:
|
||||
module Verification #:nodoc:
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# TODO : Remove the defined? check when new base is the main base
|
||||
if defined?(ActionController::Http)
|
||||
|
@ -24,7 +24,7 @@ module ActionController #:nodoc:
|
||||
# ActionController::Base.cache_store = :mem_cache_store, "localhost"
|
||||
# ActionController::Base.cache_store = MyOwnStore.new("parameter")
|
||||
module Caching
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
autoload :Actions, 'action_controller/caching/actions'
|
||||
autoload :Fragments, 'action_controller/caching/fragments'
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActionController
|
||||
module Rails2Compatibility
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class ::ActionController::ActionControllerError < StandardError #:nodoc:
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActionController
|
||||
module ConditionalGet
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on RackConvenience
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
module ActionController
|
||||
module Helpers
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on AbstractController::Helpers
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActionController
|
||||
module HideActions
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
extlib_inheritable_accessor :hidden_actions
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActionController
|
||||
module Layouts
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on ActionController::Renderer
|
||||
depends_on AbstractController::Layouts
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActionController
|
||||
module RackConvenience
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
delegate :headers, :status=, :location=,
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActionController
|
||||
module RenderOptions
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
extlib_inheritable_accessor :_renderers
|
||||
@ -36,14 +36,12 @@ def render_to_body(options)
|
||||
end
|
||||
end
|
||||
|
||||
module RenderOption
|
||||
extend ActiveSupport::DependencyModule
|
||||
module RenderOption #:nodoc:
|
||||
def self.extended(base)
|
||||
base.extend ActiveSupport::Concern
|
||||
base.depends_on ::ActionController::RenderOptions
|
||||
|
||||
included do
|
||||
extend ActiveSupport::DependencyModule
|
||||
depends_on ::ActionController::RenderOptions
|
||||
|
||||
def self.register_renderer(name)
|
||||
def base.register_renderer(name)
|
||||
included { _add_render_option(name) }
|
||||
end
|
||||
end
|
||||
@ -51,7 +49,7 @@ def self.register_renderer(name)
|
||||
|
||||
module Renderers
|
||||
module Json
|
||||
include RenderOption
|
||||
extend RenderOption
|
||||
register_renderer :json
|
||||
|
||||
def _render_json(json, options)
|
||||
@ -63,7 +61,7 @@ def _render_json(json, options)
|
||||
end
|
||||
|
||||
module Js
|
||||
include RenderOption
|
||||
extend RenderOption
|
||||
register_renderer :js
|
||||
|
||||
def _render_js(js, options)
|
||||
@ -73,7 +71,7 @@ def _render_js(js, options)
|
||||
end
|
||||
|
||||
module Xml
|
||||
include RenderOption
|
||||
extend RenderOption
|
||||
register_renderer :xml
|
||||
|
||||
def _render_xml(xml, options)
|
||||
@ -82,8 +80,8 @@ def _render_xml(xml, options)
|
||||
end
|
||||
end
|
||||
|
||||
module Rjs
|
||||
include RenderOption
|
||||
module RJS
|
||||
extend RenderOption
|
||||
register_renderer :update
|
||||
|
||||
def _render_update(proc, options)
|
||||
@ -94,14 +92,12 @@ def _render_update(proc, options)
|
||||
end
|
||||
|
||||
module All
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
include ::ActionController::Renderers::Json
|
||||
include ::ActionController::Renderers::Js
|
||||
include ::ActionController::Renderers::Xml
|
||||
include ::ActionController::Renderers::Rjs
|
||||
end
|
||||
depends_on ActionController::Renderers::Json
|
||||
depends_on ActionController::Renderers::Js
|
||||
depends_on ActionController::Renderers::Xml
|
||||
depends_on ActionController::Renderers::RJS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActionController
|
||||
module Renderer
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on AbstractController::Renderer
|
||||
|
||||
|
@ -15,7 +15,7 @@ module ActionController #:nodoc:
|
||||
# behavior is achieved by overriding the <tt>rescue_action_in_public</tt>
|
||||
# and <tt>rescue_action_locally</tt> methods.
|
||||
module Rescue
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
include ActiveSupport::Rescuable
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActionController
|
||||
module Session
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on RackConvenience
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActionController
|
||||
module Testing
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on RackConvenience
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActionController
|
||||
module UrlFor
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on RackConvenience
|
||||
|
||||
|
@ -301,7 +301,7 @@ def generic_url_rewriter
|
||||
# A module used to extend ActionController::Base, so that integration tests
|
||||
# can capture the controller used to satisfy a request.
|
||||
module ControllerCapture #:nodoc:
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
alias_method_chain :initialize, :capture
|
||||
|
@ -171,7 +171,7 @@ module ActionView
|
||||
# <% end %>
|
||||
module Partials
|
||||
extend ActiveSupport::Memoizable
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
attr_accessor :_partial
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActiveRecord
|
||||
module Aggregations # :nodoc:
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def clear_aggregation_cache #:nodoc:
|
||||
self.class.reflect_on_all_aggregations.to_a.each do |assoc|
|
||||
|
@ -1,7 +1,7 @@
|
||||
module ActiveRecord
|
||||
# See ActiveRecord::AssociationPreload::ClassMethods for documentation.
|
||||
module AssociationPreload #:nodoc:
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# Implements the details of eager loading of ActiveRecord associations.
|
||||
# Application developers should not use this module directly.
|
||||
|
@ -79,7 +79,7 @@ def initialize(reflection)
|
||||
|
||||
# See ActiveRecord::Associations::ClassMethods for documentation.
|
||||
module Associations # :nodoc:
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# These classes will be loaded when associations are created.
|
||||
# So there is no need to eager load them.
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
module ActiveRecord
|
||||
module AttributeMethods #:nodoc:
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
DEFAULT_SUFFIXES = %w(= ? _before_type_cast)
|
||||
ATTRIBUTE_TYPES_CACHED_BY_DEFAULT = [:datetime, :timestamp, :time, :date]
|
||||
|
@ -125,7 +125,7 @@ module ActiveRecord
|
||||
# post.author.name = ''
|
||||
# post.save(false) # => true
|
||||
module AutosaveAssociation
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
ASSOCIATION_TYPES = %w{ has_one belongs_to has_many has_and_belongs_to_many }
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActiveRecord
|
||||
module Batches # :nodoc:
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# When processing large numbers of records, it's often a good idea to do
|
||||
# so in batches to prevent memory ballooning.
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActiveRecord
|
||||
module Calculations #:nodoc:
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
CALCULATIONS_OPTIONS = [:conditions, :joins, :order, :select, :group, :having, :distinct, :limit, :offset, :include, :from]
|
||||
|
||||
|
@ -211,7 +211,7 @@ module ActiveRecord
|
||||
# needs to be aware of it because an ordinary +save+ will raise such exception
|
||||
# instead of quietly returning +false+.
|
||||
module Callbacks
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
CALLBACKS = %w(
|
||||
after_find after_initialize before_save after_save before_create after_create before_update after_update before_validation
|
||||
|
@ -34,7 +34,7 @@ module ActiveRecord
|
||||
# person.name << 'by'
|
||||
# person.name_change # => ['uncle bob', 'uncle bobby']
|
||||
module Dirty
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
DIRTY_SUFFIXES = ['_changed?', '_change', '_will_change!', '_was']
|
||||
|
||||
|
@ -807,7 +807,7 @@ def find
|
||||
|
||||
module ActiveRecord
|
||||
module TestFixtures
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
setup :setup_fixtures
|
||||
|
@ -42,7 +42,7 @@ module Locking
|
||||
# To override the name of the lock_version column, invoke the <tt>set_locking_column</tt> method.
|
||||
# This method uses the same syntax as <tt>set_table_name</tt>
|
||||
module Optimistic
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
cattr_accessor :lock_optimistically, :instance_writer => false
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
module ActiveRecord
|
||||
module NamedScope
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# All subclasses of ActiveRecord::Base have one named scope:
|
||||
# * <tt>scoped</tt> - which allows for the creation of anonymous \scopes, on the fly: <tt>Shirt.scoped(:conditions => {:color => 'red'}).scoped(:include => :washing_instructions)</tt>
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
module ActiveRecord
|
||||
module NestedAttributes #:nodoc:
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
class_inheritable_accessor :reject_new_nested_attributes_procs, :instance_writer => false
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
module ActiveRecord
|
||||
module Observing # :nodoc:
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
module ClassMethods
|
||||
# Activates the observers assigned. Examples:
|
||||
|
@ -1,6 +1,6 @@
|
||||
module ActiveRecord
|
||||
module Reflection # :nodoc:
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# Reflection allows you to interrogate Active Record classes and objects about their associations and aggregations.
|
||||
# This information can, for example, be used in a form builder that took an Active Record object and created input
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
module ActiveRecord #:nodoc:
|
||||
module Serialization
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
cattr_accessor :include_root_in_json, :instance_writer => false
|
||||
|
@ -8,7 +8,7 @@ module ActiveRecord
|
||||
# Timestamps are in the local timezone by default but you can use UTC by setting
|
||||
# <tt>ActiveRecord::Base.default_timezone = :utc</tt>
|
||||
module Timestamp
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
alias_method_chain :create, :timestamps
|
||||
|
@ -3,7 +3,7 @@
|
||||
module ActiveRecord
|
||||
# See ActiveRecord::Transactions::ClassMethods for documentation.
|
||||
module Transactions
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class TransactionError < ActiveRecordError # :nodoc:
|
||||
end
|
||||
|
@ -302,7 +302,7 @@ def to_xml(options={})
|
||||
#
|
||||
# An Errors object is automatically created for every Active Record.
|
||||
module Validations
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
VALIDATIONS = %w( validate validate_on_create validate_on_update )
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
require 'active_support/core_ext/array/random_access'
|
||||
|
||||
module Remembered
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
after_create :remember
|
||||
|
@ -1,7 +1,7 @@
|
||||
module ActiveRecord
|
||||
module Testing
|
||||
module RepairHelper
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
module Toolbox
|
||||
def self.record_validations(*model_classes)
|
||||
|
@ -5,7 +5,7 @@ module ActiveSupport
|
||||
autoload :BufferedLogger, 'active_support/buffered_logger'
|
||||
autoload :Cache, 'active_support/cache'
|
||||
autoload :Callbacks, 'active_support/callbacks'
|
||||
autoload :NewCallbacks, 'active_support/new_callbacks'
|
||||
autoload :Concern, 'active_support/concern'
|
||||
autoload :ConcurrentHash, 'active_support/concurrent_hash'
|
||||
autoload :DependencyModule, 'active_support/dependency_module'
|
||||
autoload :Deprecation, 'active_support/deprecation'
|
||||
@ -15,6 +15,7 @@ module ActiveSupport
|
||||
autoload :MessageEncryptor, 'active_support/message_encryptor'
|
||||
autoload :MessageVerifier, 'active_support/message_verifier'
|
||||
autoload :Multibyte, 'active_support/multibyte'
|
||||
autoload :NewCallbacks, 'active_support/new_callbacks'
|
||||
autoload :OptionMerger, 'active_support/option_merger'
|
||||
autoload :OrderedHash, 'active_support/ordered_hash'
|
||||
autoload :OrderedOptions, 'active_support/ordered_options'
|
||||
|
22
activesupport/lib/active_support/concern.rb
Normal file
22
activesupport/lib/active_support/concern.rb
Normal file
@ -0,0 +1,22 @@
|
||||
require 'active_support/dependency_module'
|
||||
|
||||
module ActiveSupport
|
||||
module Concern
|
||||
include DependencyModule
|
||||
|
||||
def append_features(base)
|
||||
if super
|
||||
base.extend const_get("ClassMethods") if const_defined?("ClassMethods")
|
||||
base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block")
|
||||
end
|
||||
end
|
||||
|
||||
def included(base = nil, &block)
|
||||
if base.nil?
|
||||
@_included_block = block
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,19 +1,9 @@
|
||||
module ActiveSupport
|
||||
module DependencyModule
|
||||
def append_features(base)
|
||||
return if base < self
|
||||
return false if base < self
|
||||
(@_dependencies ||= []).each { |dep| base.send(:include, dep) }
|
||||
super
|
||||
base.extend const_get("ClassMethods") if const_defined?("ClassMethods")
|
||||
base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block")
|
||||
end
|
||||
|
||||
def included(base = nil, &block)
|
||||
if base.nil?
|
||||
@_included_block = block
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def depends_on(*mods)
|
||||
|
@ -1,9 +1,9 @@
|
||||
require 'abstract_unit'
|
||||
require 'active_support/dependency_module'
|
||||
require 'active_support/concern'
|
||||
|
||||
class DependencyModuleTest < Test::Unit::TestCase
|
||||
class ConcernTest < Test::Unit::TestCase
|
||||
module Baz
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
module ClassMethods
|
||||
def baz
|
||||
@ -29,7 +29,7 @@ def baz
|
||||
end
|
||||
|
||||
module Bar
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on Baz
|
||||
|
||||
@ -43,7 +43,7 @@ def baz
|
||||
end
|
||||
|
||||
module Foo
|
||||
extend ActiveSupport::DependencyModule
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
depends_on Bar, Baz
|
||||
end
|
||||
@ -55,17 +55,17 @@ def setup
|
||||
def test_module_is_included_normally
|
||||
@klass.send(:include, Baz)
|
||||
assert_equal "baz", @klass.new.baz
|
||||
assert_equal DependencyModuleTest::Baz, @klass.included_modules[0]
|
||||
assert_equal ConcernTest::Baz, @klass.included_modules[0]
|
||||
|
||||
@klass.send(:include, Baz)
|
||||
assert_equal "baz", @klass.new.baz
|
||||
assert_equal DependencyModuleTest::Baz, @klass.included_modules[0]
|
||||
assert_equal ConcernTest::Baz, @klass.included_modules[0]
|
||||
end
|
||||
|
||||
def test_class_methods_are_extended
|
||||
@klass.send(:include, Baz)
|
||||
assert_equal "baz", @klass.baz
|
||||
assert_equal DependencyModuleTest::Baz::ClassMethods, (class << @klass; self.included_modules; end)[0]
|
||||
assert_equal ConcernTest::Baz::ClassMethods, (class << @klass; self.included_modules; end)[0]
|
||||
end
|
||||
|
||||
def test_included_block_is_ran
|
||||
@ -78,11 +78,11 @@ def test_modules_dependencies_are_met
|
||||
assert_equal "bar", @klass.new.bar
|
||||
assert_equal "bar+baz", @klass.new.baz
|
||||
assert_equal "baz", @klass.baz
|
||||
assert_equal [DependencyModuleTest::Bar, DependencyModuleTest::Baz], @klass.included_modules[0..1]
|
||||
assert_equal [ConcernTest::Bar, ConcernTest::Baz], @klass.included_modules[0..1]
|
||||
end
|
||||
|
||||
def test_depends_on_with_multiple_modules
|
||||
@klass.send(:include, Foo)
|
||||
assert_equal [DependencyModuleTest::Foo, DependencyModuleTest::Bar, DependencyModuleTest::Baz], @klass.included_modules[0..2]
|
||||
assert_equal [ConcernTest::Foo, ConcernTest::Bar, ConcernTest::Baz], @klass.included_modules[0..2]
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user