Module: DataMapper::Spec

### Home Classes Methods

### In Files

- lib/dm-core/spec/lib/adapter_helpers.rb
- lib/dm-core/spec/lib/collection_helpers.rb
- lib/dm-core/spec/lib/pending_helpers.rb
- lib/dm-core/spec/lib/spec_helper.rb
- lib/dm-core/spec/setup.rb

### Namespace

- MODULE DataMapper::Spec::Adapters
- MODULE DataMapper::Spec::CollectionHelpers
- MODULE DataMapper::Spec::Helpers
- MODULE DataMapper::Spec::PendingHelpers

### Methods

- ::cleanup_models
- ::configure
- ::configured?
- ::remove_ivars
- ::require_plugins
- ::require_spec_adapter
- ::root
- ::root=
- ::setup_logger
- ::spec_adapters

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- DataMapper
- DataMapper::Adapters
- DataMapper::Adapters::AbstractAdapter
- DataMapper::Adapters::InMemoryAdapter
- DataMapper::Assertions
- DataMapper::Associations
- DataMapper::Associations::ManyToMany
- DataMapper::Associations::ManyToMany::Collection
- DataMapper::Associations::ManyToMany::Relationship
- DataMapper::Associations::ManyToOne
- DataMapper::Associations::ManyToOne::Relationship
- DataMapper::Associations::OneToMany
- DataMapper::Associations::OneToMany::Collection
- DataMapper::Associations::OneToMany::Relationship
- DataMapper::Associations::OneToOne
- DataMapper::Associations::OneToOne::Relationship
- DataMapper::Associations::Relationship
- DataMapper::Chainable
- DataMapper::Collection
- DataMapper::Deprecate
- DataMapper::DescendantSet
- DataMapper::Equalizer
- DataMapper::Ext
- DataMapper::Ext::Array
- DataMapper::Ext::Hash
- DataMapper::Ext::Module
- DataMapper::Ext::Object
- DataMapper::Ext::String
- DataMapper::Hook
- DataMapper::Hook::ClassMethods
- DataMapper::IdentityMap
- DataMapper::ImmutableDeletedError
- DataMapper::ImmutableError
- DataMapper::IncompleteModelError
- DataMapper::Inflector
- DataMapper::Inflector::Inflections
- DataMapper::LocalObjectSpace
- DataMapper::Logger
- DataMapper::Mash
- DataMapper::Model
- DataMapper::Model::Hook
- DataMapper::Model::Hook::MethodCommand
- DataMapper::Model::Hook::Methods
- DataMapper::Model::Hook::ProcCommand
- DataMapper::Model::Is
- DataMapper::Model::Property
- DataMapper::Model::Relationship
- DataMapper::Model::Scope
- DataMapper::NamingConventions
- DataMapper::NamingConventions::Field
- DataMapper::NamingConventions::Field::Underscored
- DataMapper::NamingConventions::Field::UnderscoredAndPluralized
- DataMapper::NamingConventions::Field::UnderscoredAndPluralizedWithoutModule
- DataMapper::NamingConventions::Field::Yaml
- DataMapper::NamingConventions::Resource
- DataMapper::NamingConventions::Resource::Underscored
- DataMapper::NamingConventions::Resource::UnderscoredAndPluralized
- DataMapper::NamingConventions::Resource::UnderscoredAndPluralizedWithoutLeadingModule
- DataMapper::NamingConventions::Resource::UnderscoredAndPluralizedWithoutModule
- DataMapper::NamingConventions::Resource::Yaml
- DataMapper::ObjectNotFoundError
- DataMapper::OrderedSet
- DataMapper::OrderedSet::Cache
- DataMapper::OrderedSet::Cache::API
- DataMapper::PersistenceError
- DataMapper::PluginNotFoundError
- DataMapper::Property
- DataMapper::Property::Binary
- DataMapper::Property::Boolean
- DataMapper::Property::Class
- DataMapper::Property::Date
- DataMapper::Property::DateTime
- DataMapper::Property::Decimal
- DataMapper::Property::Discriminator
- DataMapper::Property::Discriminator::Model
- DataMapper::Property::Float
- DataMapper::Property::Integer
- DataMapper::Property::Lookup
- DataMapper::Property::Numeric
- DataMapper::Property::Object
- DataMapper::Property::PassThroughLoadDump
- DataMapper::Property::Serial
- DataMapper::Property::String
- DataMapper::Property::Text
- DataMapper::Property::Time
- DataMapper::Property::Typecast
- DataMapper::Property::Typecast::Numeric
- DataMapper::Property::Typecast::Time
- DataMapper::PropertySet
- DataMapper::Query
- DataMapper::Query::Conditions
- DataMapper::Query::Conditions::AbstractComparison
- DataMapper::Query::Conditions::AbstractOperation
- DataMapper::Query::Conditions::AndOperation
- DataMapper::Query::Conditions::Comparison
- DataMapper::Query::Conditions::EqualToComparison
- DataMapper::Query::Conditions::FlattenOperation
- DataMapper::Query::Conditions::GreaterThanComparison
- DataMapper::Query::Conditions::GreaterThanOrEqualToComparison
- DataMapper::Query::Conditions::InclusionComparison
- DataMapper::Query::Conditions::LessThanComparison
- DataMapper::Query::Conditions::LessThanOrEqualToComparison
- DataMapper::Query::Conditions::LikeComparison
- DataMapper::Query::Conditions::NotOperation
- DataMapper::Query::Conditions::NullOperation
- DataMapper::Query::Conditions::Operation
- DataMapper::Query::Conditions::OrOperation
- DataMapper::Query::Conditions::RegexpComparison
- DataMapper::Query::Conditions::RelationshipHandler
- DataMapper::Query::Direction
- DataMapper::Query::Operator
- DataMapper::Query::Path
- DataMapper::Query::Sort
- DataMapper::RelationshipSet
- DataMapper::Repository
- DataMapper::RepositoryNotSetupError
- DataMapper::Resource
- DataMapper::Resource::PersistenceState
- DataMapper::Resource::PersistenceState::Clean
- DataMapper::Resource::PersistenceState::Deleted
- DataMapper::Resource::PersistenceState::Dirty
- DataMapper::Resource::PersistenceState::Immutable
- DataMapper::Resource::PersistenceState::Persisted
- DataMapper::Resource::PersistenceState::Transient
- DataMapper::SaveFailureError
- DataMapper::Spec
- DataMapper::Spec::Adapters
- DataMapper::Spec::Adapters::Adapter
- DataMapper::Spec::Adapters::Helpers
- DataMapper::Spec::Adapters::InMemoryAdapter
- DataMapper::Spec::CollectionHelpers
- DataMapper::Spec::CollectionHelpers::GroupMethods
- DataMapper::Spec::Helpers
- DataMapper::Spec::PendingHelpers
- DataMapper::Subject
- DataMapper::SubjectSet
- DataMapper::SubjectSet::NameCache
- DataMapper::Undefined
- DataMapper::UnknownRelationshipError
- DataMapper::UnsavedParentError
- DataMapper::UpdateConflictError
- Blog
- Blog::Article
- ChildSubType
- CounterAdapter
- Heffalump
- Kernel
- LazyArray
- Object
- OtherComparison
- Pathname
- SubType
- Symbol

No matching classes.

# DataMapper::Spec

### Public Class Methods

cleanup_models() click to toggle source

global model cleanup

    # File lib/dm-core/spec/lib/spec_helper.rb, line 15
    def self.cleanup_models
      descendants = DataMapper::Model.descendants.to_a

      while model = descendants.shift
        model_name = model.name.to_s.strip

        unless model_name.empty? || model_name[0] == ##
          parts         = model_name.split('::')
          constant_name = parts.pop.to_sym
          base          = parts.empty? ? Object : DataMapper::Ext::Object.full_const_get(parts.join('::'))

          base.class_eval { remove_const(constant_name) if const_defined?(constant_name) }
        end

        remove_ivars(model)
        model.instance_methods(false).each { |method| model.send(:undef_method, method) }

      end

      DataMapper::Model.descendants.clear
    end

configure() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 24
    def configure
      @configured = begin
        setup_logger
        require_plugins
        require_spec_adapter
        true
      end
    end

configured?() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 33
    def configured?
      @configured
    end

remove_ivars(object, instance_variables = object.instance_variables) click to toggle source

    # File lib/dm-core/spec/lib/spec_helper.rb, line 37
    def self.remove_ivars(object, instance_variables = object.instance_variables)
      seen  = {}
      stack = instance_variables.map { |var| [ object, var ] }

      while node = stack.pop
        object, ivar = node

        # skip "global" and non-DM objects
        next if object.kind_of?(DataMapper::Logger)                    ||
                object.kind_of?(DataMapper::DescendantSet)             ||
                object.kind_of?(DataMapper::Adapters::AbstractAdapter) ||
                object.class.name.to_s[0, 13] == 'DataObjects::'

        # skip classes and modules in the DataMapper namespace
        next if object.kind_of?(Module) &&
                object.name.to_s[0, 12] == 'DataMapper::'

        # skip when the ivar is no longer defined in the object
        next unless object.instance_variable_defined?(ivar)

        value = object.instance_variable_get(ivar)

        # skip descendant sets
        next if value.kind_of?(DataMapper::DescendantSet)

        object.__send__(:remove_instance_variable, ivar) unless object.frozen?

        # skip when the value was seen
        next if seen.key?(value.object_id)
        seen[value.object_id] = true

        stack.concat value.instance_variables.map { |ivar| [ value, ivar ] }
      end
    end

require_plugins() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 54
    def require_plugins
      plugins = ENV['PLUGINS'] || ENV['PLUGIN']
      plugins = plugins.to_s.split(/[,\s]+/)
      unless ENV['ADAPTER'] == 'in_memory'
        plugins.push('dm-migrations')
      end
      plugins.uniq.each { |plugin| require plugin }
    end

require_spec_adapter() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 44
    def require_spec_adapter
      desired_adapter = ENV['ADAPTER']
      if desired_adapter.nil? || desired_adapter == 'in_memory'
        ENV['ADAPTER_SUPPORTS'] = 'all'
        Adapters.use(Adapters::InMemoryAdapter)
      else
        require "dm-#{desired_adapter}-adapter/spec/setup"
      end
    end

root() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 8
    def root
      @root ||= default_root
    end

root=(path) click to toggle source

    # File lib/dm-core/spec/setup.rb, line 12
    def root=(path)
      @root = Pathname(path)
    end

setup_logger() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 37
    def setup_logger
      if log = ENV['LOG']
        logger = DataMapper::Logger.new(log_stream(log), :debug)
        logger.auto_flush = true
      end
    end

spec_adapters() click to toggle source

    # File lib/dm-core/spec/setup.rb, line 63
    def spec_adapters
      @spec_adapters ||= {}
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.