mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Use autoloading instead of requiring all files up front
This commit is contained in:
parent
bd13becb5d
commit
ce78101362
15 changed files with 108 additions and 99 deletions
|
@ -1,21 +1,22 @@
|
|||
require 'shoulda/matchers/configuration'
|
||||
require 'shoulda/matchers/doublespeak'
|
||||
require 'shoulda/matchers/error'
|
||||
require 'shoulda/matchers/independent'
|
||||
require 'shoulda/matchers/integrations'
|
||||
require 'shoulda/matchers/matcher_context'
|
||||
require 'shoulda/matchers/rails_shim'
|
||||
require 'shoulda/matchers/util'
|
||||
require 'shoulda/matchers/version'
|
||||
require 'shoulda/matchers/warn'
|
||||
|
||||
require 'shoulda/matchers/action_controller'
|
||||
require 'shoulda/matchers/active_model'
|
||||
require 'shoulda/matchers/active_record'
|
||||
require 'shoulda/matchers/routing'
|
||||
|
||||
module Shoulda
|
||||
module Matchers
|
||||
autoload :ActionController, 'shoulda/matchers/action_controller'
|
||||
autoload :ActiveModel, 'shoulda/matchers/active_model'
|
||||
autoload :ActiveRecord, 'shoulda/matchers/active_record'
|
||||
autoload :Doublespeak, 'shoulda/matchers/doublespeak'
|
||||
autoload :Error, 'shoulda/matchers/error'
|
||||
autoload :Independent, 'shoulda/matchers/independent'
|
||||
autoload :Integrations, 'shoulda/matchers/integrations'
|
||||
autoload :MatcherContext, 'shoulda/matchers/matcher_context'
|
||||
autoload :RailsShim, 'shoulda/matchers/rails_shim'
|
||||
autoload :Routing, 'shoulda/matchers/routing'
|
||||
autoload :Util, 'shoulda/matchers/util'
|
||||
autoload :WordWrap, 'shoulda/matchers/util/word_wrap'
|
||||
|
||||
class << self
|
||||
# @private
|
||||
attr_accessor :assertion_exception_class
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
require 'shoulda/matchers/action_controller/filter_param_matcher'
|
||||
require 'shoulda/matchers/action_controller/route_params'
|
||||
require 'shoulda/matchers/action_controller/set_flash_matcher'
|
||||
require 'shoulda/matchers/action_controller/render_with_layout_matcher'
|
||||
require 'shoulda/matchers/action_controller/respond_with_matcher'
|
||||
require 'shoulda/matchers/action_controller/set_session_matcher'
|
||||
require 'shoulda/matchers/action_controller/route_matcher'
|
||||
require 'shoulda/matchers/action_controller/redirect_to_matcher'
|
||||
require 'shoulda/matchers/action_controller/render_template_matcher'
|
||||
require 'shoulda/matchers/action_controller/rescue_from_matcher'
|
||||
require 'shoulda/matchers/action_controller/callback_matcher'
|
||||
require 'shoulda/matchers/action_controller/permit_matcher'
|
||||
require 'shoulda/matchers/action_controller/set_session_or_flash_matcher'
|
||||
require 'shoulda/matchers/action_controller/flash_store'
|
||||
require 'shoulda/matchers/action_controller/session_store'
|
||||
|
||||
module Shoulda
|
||||
module Matchers
|
||||
# This module provides matchers that are used to test behavior within
|
||||
# controllers.
|
||||
module ActionController
|
||||
autoload :CallbackMatcher, 'shoulda/matchers/action_controller/callback_matcher'
|
||||
autoload :FlashStore, 'shoulda/matchers/action_controller/flash_store'
|
||||
autoload :FilterParamMatcher, 'shoulda/matchers/action_controller/filter_param_matcher'
|
||||
autoload :PermitMatcher, 'shoulda/matchers/action_controller/permit_matcher'
|
||||
autoload :RedirectToMatcher, 'shoulda/matchers/action_controller/redirect_to_matcher'
|
||||
autoload :RenderTemplateMatcher, 'shoulda/matchers/action_controller/render_template_matcher'
|
||||
autoload :RenderWithLayoutMatcher, 'shoulda/matchers/action_controller/render_with_layout_matcher'
|
||||
autoload :RescueFromMatcher, 'shoulda/matchers/action_controller/rescue_from_matcher'
|
||||
autoload :RouteParams, 'shoulda/matchers/action_controller/route_params'
|
||||
autoload :SessionStore, 'shoulda/matchers/action_controller/session_store'
|
||||
autoload :SetFlashMatcher, 'shoulda/matchers/action_controller/set_flash_matcher'
|
||||
autoload :SetSessionMatcher, 'shoulda/matchers/action_controller/set_session_matcher'
|
||||
autoload :SetSessionOrFlashMatcher, 'shoulda/matchers/action_controller/set_session_or_flash_matcher'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,34 +1,9 @@
|
|||
require 'shoulda/matchers/active_model/allow_mass_assignment_of_matcher'
|
||||
require 'shoulda/matchers/active_model/helpers'
|
||||
require 'shoulda/matchers/active_model/qualifiers'
|
||||
require 'shoulda/matchers/active_model/validation_matcher'
|
||||
require 'shoulda/matchers/active_model/validation_matcher/build_description'
|
||||
require 'shoulda/matchers/active_model/validator'
|
||||
require 'shoulda/matchers/active_model/allow_value_matcher'
|
||||
require 'shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error'
|
||||
require 'shoulda/matchers/active_model/allow_value_matcher/attribute_does_not_exist_error'
|
||||
require 'shoulda/matchers/active_model/allow_value_matcher/attribute_setter'
|
||||
require 'shoulda/matchers/active_model/allow_value_matcher/attribute_setter_and_validator'
|
||||
require 'shoulda/matchers/active_model/allow_value_matcher/attribute_setters'
|
||||
require 'shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators'
|
||||
require 'shoulda/matchers/active_model/allow_value_matcher/successful_check'
|
||||
require 'shoulda/matchers/active_model/allow_value_matcher/successful_setting'
|
||||
require 'shoulda/matchers/active_model/disallow_value_matcher'
|
||||
require 'shoulda/matchers/active_model/validate_length_of_matcher'
|
||||
require 'shoulda/matchers/active_model/validate_inclusion_of_matcher'
|
||||
require 'shoulda/matchers/active_model/validate_exclusion_of_matcher'
|
||||
require 'shoulda/matchers/active_model/validate_absence_of_matcher'
|
||||
require 'shoulda/matchers/active_model/validate_presence_of_matcher'
|
||||
require 'shoulda/matchers/active_model/validate_acceptance_of_matcher'
|
||||
require 'shoulda/matchers/active_model/validate_confirmation_of_matcher'
|
||||
require 'shoulda/matchers/active_model/validate_numericality_of_matcher'
|
||||
require 'shoulda/matchers/active_model/numericality_matchers/numeric_type_matcher'
|
||||
require 'shoulda/matchers/active_model/numericality_matchers/comparison_matcher'
|
||||
require 'shoulda/matchers/active_model/numericality_matchers/odd_number_matcher'
|
||||
require 'shoulda/matchers/active_model/numericality_matchers/even_number_matcher'
|
||||
require 'shoulda/matchers/active_model/numericality_matchers/only_integer_matcher'
|
||||
require 'shoulda/matchers/active_model/allow_mass_assignment_of_matcher'
|
||||
require 'shoulda/matchers/active_model/errors'
|
||||
require 'shoulda/matchers/active_model/have_secure_password_matcher'
|
||||
|
||||
module Shoulda
|
||||
module Matchers
|
||||
|
@ -89,6 +64,20 @@ module Shoulda
|
|||
# end
|
||||
#
|
||||
module ActiveModel
|
||||
autoload :AllowValueMatcher, 'shoulda/matchers/active_model/allow_value_matcher'
|
||||
autoload :CouldNotDetermineValueOutsideOfArray, 'shoulda/matchers/active_model/errors'
|
||||
autoload :CouldNotSetPasswordError, 'shoulda/matchers/active_model/errors'
|
||||
autoload :DisallowValueMatcher, 'shoulda/matchers/active_model/disallow_value_matcher'
|
||||
autoload :HaveSecurePasswordMatcher, 'shoulda/matchers/active_model/have_secure_password_matcher'
|
||||
autoload :NonNullableBooleanError, 'shoulda/matchers/active_model/errors'
|
||||
autoload :NumericalityMatchers, 'shoulda/matchers/active_model/numericality_matchers'
|
||||
autoload :ValidateAcceptanceOfMatcher, 'shoulda/matchers/active_model/validate_acceptance_of_matcher'
|
||||
autoload :ValidateConfirmationOfMatcher, 'shoulda/matchers/active_model/validate_confirmation_of_matcher'
|
||||
autoload :ValidateExclusionOfMatcher, 'shoulda/matchers/active_model/validate_exclusion_of_matcher'
|
||||
autoload :ValidateInclusionOfMatcher, 'shoulda/matchers/active_model/validate_inclusion_of_matcher'
|
||||
autoload :ValidateLengthOfMatcher, 'shoulda/matchers/active_model/validate_length_of_matcher'
|
||||
autoload :ValidateNumericalityOfMatcher, 'shoulda/matchers/active_model/validate_numericality_of_matcher'
|
||||
autoload :Validator, 'shoulda/matchers/active_model/validator'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -305,6 +305,15 @@ module Shoulda
|
|||
|
||||
# @private
|
||||
class AllowValueMatcher
|
||||
autoload :AttributeChangedValueError, 'shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error'
|
||||
autoload :AttributeDoesNotExistError, 'shoulda/matchers/active_model/allow_value_matcher/attribute_does_not_exist_error'
|
||||
autoload :AttributeSetter, 'shoulda/matchers/active_model/allow_value_matcher/attribute_setter'
|
||||
autoload :AttributeSetterAndValidator, 'shoulda/matchers/active_model/allow_value_matcher/attribute_setter_and_validator'
|
||||
autoload :AttributeSetters, 'shoulda/matchers/active_model/allow_value_matcher/attribute_setters'
|
||||
autoload :AttributeSettersAndValidators, 'shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators'
|
||||
autoload :SuccessfulCheck, 'shoulda/matchers/active_model/allow_value_matcher/successful_check'
|
||||
autoload :SuccessfulSetting, 'shoulda/matchers/active_model/allow_value_matcher/successful_setting'
|
||||
|
||||
include Helpers
|
||||
include Qualifiers::IgnoringInterferenceByWriter
|
||||
|
||||
|
|
|
@ -3,6 +3,11 @@ module Shoulda
|
|||
module ActiveModel
|
||||
# @private
|
||||
module NumericalityMatchers
|
||||
autoload :ComparisonMatcher, 'shoulda/matchers/active_model/numericality_matchers/comparison_matcher'
|
||||
autoload :EvenNumberMatcher, 'shoulda/matchers/active_model/numericality_matchers/even_number_matcher'
|
||||
autoload :NumericTypeMatcher, 'shoulda/matchers/active_model/numericality_matchers/numeric_type_matcher'
|
||||
autoload :OddNumberMatcher, 'shoulda/matchers/active_model/numericality_matchers/odd_number_matcher'
|
||||
autoload :OnlyIntegerMatcher, 'shoulda/matchers/active_model/numericality_matchers/only_integer_matcher'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,8 @@ module Shoulda
|
|||
module ActiveModel
|
||||
# @private
|
||||
class ValidationMatcher
|
||||
autoload :BuildDescription, 'shoulda/matchers/active_model/validation_matcher/build_description'
|
||||
|
||||
include Qualifiers::IgnoringInterferenceByWriter
|
||||
|
||||
def initialize(attribute)
|
||||
|
|
|
@ -1,35 +1,23 @@
|
|||
require "shoulda/matchers/active_record/association_matcher"
|
||||
require "shoulda/matchers/active_record/association_matchers"
|
||||
require "shoulda/matchers/active_record/association_matchers/counter_cache_matcher"
|
||||
require "shoulda/matchers/active_record/association_matchers/inverse_of_matcher"
|
||||
require "shoulda/matchers/active_record/association_matchers/join_table_matcher"
|
||||
require "shoulda/matchers/active_record/association_matchers/order_matcher"
|
||||
require "shoulda/matchers/active_record/association_matchers/through_matcher"
|
||||
require "shoulda/matchers/active_record/association_matchers/dependent_matcher"
|
||||
require "shoulda/matchers/active_record/association_matchers/required_matcher"
|
||||
require "shoulda/matchers/active_record/association_matchers/optional_matcher"
|
||||
require "shoulda/matchers/active_record/association_matchers/source_matcher"
|
||||
require "shoulda/matchers/active_record/association_matchers/model_reflector"
|
||||
require "shoulda/matchers/active_record/association_matchers/model_reflection"
|
||||
require "shoulda/matchers/active_record/association_matchers/option_verifier"
|
||||
require "shoulda/matchers/active_record/have_db_column_matcher"
|
||||
require "shoulda/matchers/active_record/have_db_index_matcher"
|
||||
require "shoulda/matchers/active_record/have_implicit_order_column"
|
||||
require "shoulda/matchers/active_record/have_readonly_attribute_matcher"
|
||||
require "shoulda/matchers/active_record/have_rich_text_matcher"
|
||||
require "shoulda/matchers/active_record/have_secure_token_matcher"
|
||||
require "shoulda/matchers/active_record/serialize_matcher"
|
||||
require "shoulda/matchers/active_record/accept_nested_attributes_for_matcher"
|
||||
require "shoulda/matchers/active_record/define_enum_for_matcher"
|
||||
require "shoulda/matchers/active_record/uniqueness"
|
||||
require "shoulda/matchers/active_record/validate_uniqueness_of_matcher"
|
||||
require "shoulda/matchers/active_record/have_attached_matcher"
|
||||
|
||||
module Shoulda
|
||||
module Matchers
|
||||
# This module provides matchers that are used to test behavior within
|
||||
# ActiveRecord classes.
|
||||
module ActiveRecord
|
||||
autoload :AcceptNestedAttributesForMatcher, 'shoulda/matchers/active_record/accept_nested_attributes_for_matcher'
|
||||
autoload :AssociationMatcher, 'shoulda/matchers/active_record/association_matcher'
|
||||
autoload :AssociationMatchers, 'shoulda/matchers/active_record/association_matchers'
|
||||
autoload :DefineEnumForMatcher, 'shoulda/matchers/active_record/define_enum_for_matcher'
|
||||
autoload :HaveAttachedMatcher, 'shoulda/matchers/active_record/have_attached_matcher'
|
||||
autoload :HaveDbColumnMatcher, 'shoulda/matchers/active_record/have_db_column_matcher'
|
||||
autoload :HaveDbIndexMatcher, 'shoulda/matchers/active_record/have_db_index_matcher'
|
||||
autoload :HaveImplicitOrderColumnMatcher, 'shoulda/matchers/active_record/have_implicit_order_column'
|
||||
autoload :HaveReadonlyAttributeMatcher, 'shoulda/matchers/active_record/have_readonly_attribute_matcher'
|
||||
autoload :HaveRichText, 'shoulda/matchers/active_record/have_rich_text_matcher'
|
||||
autoload :HaveSecureTokenMatcher, 'shoulda/matchers/active_record/have_secure_token_matcher'
|
||||
autoload :SerializeMatcher, 'shoulda/matchers/active_record/serialize_matcher'
|
||||
autoload :Uniqueness, 'shoulda/matchers/active_record/uniqueness'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,18 @@ module Shoulda
|
|||
module ActiveRecord
|
||||
# @private
|
||||
module AssociationMatchers
|
||||
autoload :CounterCacheMatcher, 'shoulda/matchers/active_record/association_matchers/counter_cache_matcher'
|
||||
autoload :InverseOfMatcher, 'shoulda/matchers/active_record/association_matchers/inverse_of_matcher'
|
||||
autoload :JoinTableMatcher, 'shoulda/matchers/active_record/association_matchers/join_table_matcher'
|
||||
autoload :OrderMatcher, 'shoulda/matchers/active_record/association_matchers/order_matcher'
|
||||
autoload :ThroughMatcher, 'shoulda/matchers/active_record/association_matchers/through_matcher'
|
||||
autoload :DependentMatcher, 'shoulda/matchers/active_record/association_matchers/dependent_matcher'
|
||||
autoload :RequiredMatcher, 'shoulda/matchers/active_record/association_matchers/required_matcher'
|
||||
autoload :OptionalMatcher, 'shoulda/matchers/active_record/association_matchers/optional_matcher'
|
||||
autoload :SourceMatcher, 'shoulda/matchers/active_record/association_matchers/source_matcher'
|
||||
autoload :ModelReflector, 'shoulda/matchers/active_record/association_matchers/model_reflector'
|
||||
autoload :ModelReflection, 'shoulda/matchers/active_record/association_matchers/model_reflection'
|
||||
autoload :OptionVerifier, 'shoulda/matchers/active_record/association_matchers/option_verifier'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
module Shoulda
|
||||
module Matchers
|
||||
module ActiveModel
|
||||
module ActiveRecord
|
||||
# @private
|
||||
module Uniqueness
|
||||
autoload :Model, 'shoulda/matchers/active_record/uniqueness/model'
|
||||
autoload :Namespace, 'shoulda/matchers/active_record/uniqueness/namespace'
|
||||
autoload :TestModelCreator, 'shoulda/matchers/active_record/uniqueness/test_model_creator'
|
||||
autoload :TestModels, 'shoulda/matchers/active_record/uniqueness/test_models'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require 'shoulda/matchers/active_record/uniqueness/model'
|
||||
require 'shoulda/matchers/active_record/uniqueness/namespace'
|
||||
require 'shoulda/matchers/active_record/uniqueness/test_model_creator'
|
||||
require 'shoulda/matchers/active_record/uniqueness/test_models'
|
||||
|
|
|
@ -4,6 +4,14 @@ module Shoulda
|
|||
module Matchers
|
||||
# @private
|
||||
module Doublespeak
|
||||
autoload :Double, 'shoulda/matchers/doublespeak/double'
|
||||
autoload :DoubleCollection, 'shoulda/matchers/doublespeak/double_collection'
|
||||
autoload :DoubleImplementationRegistry, 'shoulda/matchers/doublespeak/double_implementation_registry'
|
||||
autoload :MethodCall, 'shoulda/matchers/doublespeak/method_call'
|
||||
autoload :ObjectDouble, 'shoulda/matchers/doublespeak/object_double'
|
||||
autoload :ProxyImplementation, 'shoulda/matchers/doublespeak/proxy_implementation'
|
||||
autoload :World, 'shoulda/matchers/doublespeak/world'
|
||||
|
||||
class << self
|
||||
extend Forwardable
|
||||
|
||||
|
@ -28,11 +36,4 @@ module Shoulda
|
|||
end
|
||||
end
|
||||
|
||||
require 'shoulda/matchers/doublespeak/double'
|
||||
require 'shoulda/matchers/doublespeak/double_collection'
|
||||
require 'shoulda/matchers/doublespeak/double_implementation_registry'
|
||||
require 'shoulda/matchers/doublespeak/method_call'
|
||||
require 'shoulda/matchers/doublespeak/object_double'
|
||||
require 'shoulda/matchers/doublespeak/proxy_implementation'
|
||||
require 'shoulda/matchers/doublespeak/stub_implementation'
|
||||
require 'shoulda/matchers/doublespeak/world'
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
require 'shoulda/matchers/independent/delegate_method_matcher'
|
||||
require 'shoulda/matchers/independent/delegate_method_matcher/target_not_defined_error'
|
||||
|
||||
module Shoulda
|
||||
module Matchers
|
||||
|
|
|
@ -176,6 +176,9 @@ module Shoulda
|
|||
|
||||
# @private
|
||||
class DelegateMethodMatcher
|
||||
autoload :StubbedTarget, 'shoulda/matchers/independent/delegate_method_matcher/stubbed_target'
|
||||
autoload :DelegateObjectNotSpecified, 'shoulda/matchers/independent/delegate_method_matcher/target_not_defined_error'
|
||||
|
||||
def initialize(delegating_method)
|
||||
@delegating_method = delegating_method
|
||||
|
||||
|
|
|
@ -2,6 +2,12 @@ module Shoulda
|
|||
module Matchers
|
||||
# @private
|
||||
module Integrations
|
||||
autoload :Configuration, 'shoulda/matchers/integrations/configuration'
|
||||
autoload :ConfigurationError, 'shoulda/matchers/integrations/configuration_error'
|
||||
autoload :Inclusion, 'shoulda/matchers/integrations/inclusion'
|
||||
autoload :Rails, 'shoulda/matchers/integrations/rails'
|
||||
autoload :Registry, 'shoulda/matchers/integrations/registry'
|
||||
|
||||
class << self
|
||||
def register_library(klass, name)
|
||||
library_registry.register(klass, name)
|
||||
|
@ -33,11 +39,5 @@ module Shoulda
|
|||
end
|
||||
end
|
||||
|
||||
require 'shoulda/matchers/integrations/configuration'
|
||||
require 'shoulda/matchers/integrations/configuration_error'
|
||||
require 'shoulda/matchers/integrations/inclusion'
|
||||
require 'shoulda/matchers/integrations/rails'
|
||||
require 'shoulda/matchers/integrations/registry'
|
||||
|
||||
require 'shoulda/matchers/integrations/libraries'
|
||||
require 'shoulda/matchers/integrations/test_frameworks'
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
require 'shoulda/matchers/integrations/test_frameworks/active_support_test_case'
|
||||
require 'shoulda/matchers/integrations/test_frameworks/minitest_4'
|
||||
require 'shoulda/matchers/integrations/test_frameworks/minitest_5'
|
||||
require 'shoulda/matchers/integrations/test_frameworks/missing_test_framework'
|
||||
require 'shoulda/matchers/integrations/test_frameworks/rspec'
|
||||
require 'shoulda/matchers/integrations/test_frameworks/test_unit'
|
||||
|
||||
module Shoulda
|
||||
module Matchers
|
||||
module Integrations
|
||||
# @private
|
||||
module TestFrameworks
|
||||
autoload :ActiveSupportTestCase, 'shoulda/matchers/integrations/test_frameworks/active_support_test_case'
|
||||
autoload :Minitest4, 'shoulda/matchers/integrations/test_frameworks/minitest_4'
|
||||
autoload :Minitest5, 'shoulda/matchers/integrations/test_frameworks/minitest_5'
|
||||
autoload :TestUnit, 'shoulda/matchers/integrations/test_frameworks/test_unit'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require 'shoulda/matchers/util/word_wrap'
|
||||
|
||||
module Shoulda
|
||||
module Matchers
|
||||
# @private
|
||||
|
|
Loading…
Add table
Reference in a new issue