Class: DataMapper::Matchers::HaveProperty
- Inherits:
-
Object
- Object
- DataMapper::Matchers::HaveProperty
- Defined in:
- lib/dm/matchers/have_property.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(property) ⇒ HaveProperty
constructor
A new instance of HaveProperty.
- #matches?(model) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(property) ⇒ HaveProperty
Returns a new instance of HaveProperty.
5 6 7 |
# File 'lib/dm/matchers/have_property.rb', line 5 def initialize(property) @property = property.to_sym end |
Instance Method Details
#description ⇒ Object
22 23 24 |
# File 'lib/dm/matchers/have_property.rb', line 22 def description "have property #{@property}" end |
#failure_message ⇒ Object
14 15 16 |
# File 'lib/dm/matchers/have_property.rb', line 14 def "expected to have property #{@property}" end |
#matches?(model) ⇒ Boolean
9 10 11 12 |
# File 'lib/dm/matchers/have_property.rb', line 9 def matches?(model) model_class = model.is_a?(Class) ? model : model.class model_class.properties.map(&:name).include? @property end |
#negative_failure_message ⇒ Object
18 19 20 |
# File 'lib/dm/matchers/have_property.rb', line 18 def "expected to not have property #{@property}" end |