Module: DataMapperMatchers

Defined in:
lib/spec/matchers/dm/has_many.rb,
lib/spec/matchers/dm/belongs_to.rb,
lib/spec/matchers/dm/has_property.rb,
lib/spec/matchers/dm/has_timestamps.rb,
lib/spec/matchers/dm/has_and_belongs_to_many.rb

Overview

habtm Product.relationships <DataMapper::Associations::RelationshipChain @parent_model=Product, @name=:color_products, @mutable=true, @child_key=#<PropertySet:#<Property:ColorProduct:product_slug>>, @child_model=“Color”, @parent_key=#<PropertySet:#<Property:Product:slug>>, @remote_relationship_name=“colors”, @options=:near_relationship_name=>:color_products, :parent_key=>nil, :child_key=>nil, :remote_relationship_name=>“colors”, :child_model=>“Color”, :min=>0, :parent_model=>Product, :max=>Infinity, @near_relationship_name=:color_products>

Defined Under Namespace

Classes: BelongsTo, HasAndBelongsToMany, HasMany, HasProperty, HasTimestamps

Instance Method Summary collapse

Instance Method Details

#belongs_to(name) ⇒ Object



39
40
41
# File 'lib/spec/matchers/dm/belongs_to.rb', line 39

def belongs_to(name)
  BelongsTo.new(name)
end

#has_and_belongs_to_many(name) ⇒ Object



35
36
37
# File 'lib/spec/matchers/dm/has_and_belongs_to_many.rb', line 35

def has_and_belongs_to_many(name)
  HasAndBelongsToMany.new(name)
end

#has_many(name, options = Hash.new) ⇒ Object



39
40
41
42
# File 'lib/spec/matchers/dm/has_many.rb', line 39

def has_many(name, options = Hash.new)
  defaults = {:min => 0, :max => 1.0 / 0}
  HasMany.new(name, defaults.merge(options))
end

#has_one(name, options = Hash.new) ⇒ Object



44
45
46
47
# File 'lib/spec/matchers/dm/has_many.rb', line 44

def has_one(name, options = Hash.new)
  defaults = {:min => 1, :max => 1}
  HasMany.new(name, defaults.merge(options))
end

#has_property(expected) ⇒ Object



32
33
34
# File 'lib/spec/matchers/dm/has_property.rb', line 32

def has_property(expected)
  HasProperty.new(expected)
end

#has_timestamps(expected) ⇒ Object



52
53
54
# File 'lib/spec/matchers/dm/has_timestamps.rb', line 52

def has_timestamps(expected)
  HasTimestamps.new(expected)
end