Class: DataMapper::Matchers::HaveManyAndBelongTo
- Inherits:
-
Object
- Object
- DataMapper::Matchers::HaveManyAndBelongTo
- Defined in:
- lib/dm/matchers/have_many_and_belong_to.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(name) ⇒ HaveManyAndBelongTo
constructor
A new instance of HaveManyAndBelongTo.
- #matches?(model) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(name) ⇒ HaveManyAndBelongTo
Returns a new instance of HaveManyAndBelongTo.
5 6 7 |
# File 'lib/dm/matchers/have_many_and_belong_to.rb', line 5 def initialize(name) @name = name end |
Instance Method Details
#description ⇒ Object
23 24 25 |
# File 'lib/dm/matchers/have_many_and_belong_to.rb', line 23 def description "belongs to #{@parent}" end |
#failure_message ⇒ Object
15 16 17 |
# File 'lib/dm/matchers/have_many_and_belong_to.rb', line 15 def "expected to have many and belong to #{@name}" end |
#matches?(model) ⇒ Boolean
9 10 11 12 13 |
# File 'lib/dm/matchers/have_many_and_belong_to.rb', line 9 def matches?(model) model_class = model.is_a?(Class) ? model : model.class relation = model_class.relationships[@name.to_s] relation && relation.is_a?(DataMapper::Associations::ManyToMany::Relationship) end |
#negative_failure_message ⇒ Object
19 20 21 |
# File 'lib/dm/matchers/have_many_and_belong_to.rb', line 19 def "expected to not have many and belong to #{@name}" end |