class DataMapper::Matchers::HaveMany
Public Class Methods
new(children)
click to toggle source
# File lib/dm/matchers/have_many.rb, line 5 def initialize(children) @children = children end
Public Instance Methods
description()
click to toggle source
# File lib/dm/matchers/have_many.rb, line 32 def description "has many #{@children}" end
failure_message()
click to toggle source
# File lib/dm/matchers/have_many.rb, line 24 def failure_message "expected to have many #{@children}" end
matches?(parent)
click to toggle source
# File lib/dm/matchers/have_many.rb, line 9 def matches?(parent) parent_class = parent.is_a?(Class) ? parent : parent.class relation = parent_class.relationships[@children.to_s] relation and relation.is_a?(DataMapper::Associations::OneToMany::Relationship) and relation.parent_model == parent_class end
negative_failure_message()
click to toggle source
# File lib/dm/matchers/have_many.rb, line 28 def negative_failure_message "expected to not have many #{@children}" end
through(broker)
click to toggle source
called only when the next syntax is used:
Book.should have_many(:tags).trough(:tagging)
# File lib/dm/matchers/have_many.rb, line 20 def through(broker) HaveManyThrough.new(@children, broker) end