lib/dm/matchers/belong_to.rb in dm-rspec-0.1.2 vs lib/dm/matchers/belong_to.rb in dm-rspec-0.2.0
- old
+ new
@@ -5,15 +5,15 @@
def initialize(parent)
@parent = parent
end
def matches?(child)
- @child = child
- relation = @child.relationships[@parent.to_s]
+ 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
+ relation.child_model == child_class
end
def failure_message
"expected to belong to #{@parent}"
end