class DataMapper::Matchers::BelongTo
Public Class Methods
new(parent)
click to toggle source
# File lib/dm/matchers/belong_to.rb, line 5 def initialize(parent) @parent = parent end
Public Instance Methods
description()
click to toggle source
# File lib/dm/matchers/belong_to.rb, line 26 def description "belongs to #{@parent}" end
failure_message()
click to toggle source
# File lib/dm/matchers/belong_to.rb, line 18 def failure_message "expected to belong to #{@parent}" end
matches?(child)
click to toggle source
# File lib/dm/matchers/belong_to.rb, line 9 def matches?(child) child_class = child.is_a?(Class) ? child : child.class relation = child_class.relationships[@parent.to_s] relation and relation.is_a?(DataMapper::Associations::ManyToOne::Relationship) and relation.child_model == child_class end
negative_failure_message()
click to toggle source
# File lib/dm/matchers/belong_to.rb, line 22 def negative_failure_message "expected to not belong to #{@parent}" end