lib/dm/matchers/have_many.rb in dm-rspec-0.2.0 vs lib/dm/matchers/have_many.rb in dm-rspec-0.2.1
- old
+ new
@@ -5,16 +5,16 @@
def initialize(children)
@children = children
end
def matches?(parent)
- @parent = parent
- relation = @parent.relationships[@children.to_s]
+ 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
+ relation.parent_model == parent_class
end
# called only when the next syntax is used:
# Book.should have_many(:tags).trough(:tagging)
def through(broker)
@@ -26,10 +26,10 @@
end
def negative_failure_message
"expected to not have many #{@children}"
end
-
+
def description
"has many #{@children}"
end
end