Class: DataMapperMatchers::HasProperty
- Inherits:
-
Object
- Object
- DataMapperMatchers::HasProperty
- Defined in:
- lib/spec/matchers/dm/has_property.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected) ⇒ HasProperty
constructor
A new instance of HasProperty.
-
#matches?(model) ⇒ Boolean
Category.should has_property(:id).
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(expected) ⇒ HasProperty
Returns a new instance of HasProperty.
8 9 10 |
# File 'lib/spec/matchers/dm/has_property.rb', line 8 def initialize(expected) @expected = expected end |
Instance Method Details
#description ⇒ Object
18 19 20 |
# File 'lib/spec/matchers/dm/has_property.rb', line 18 def description "has property" end |
#failure_message ⇒ Object
22 23 24 25 |
# File 'lib/spec/matchers/dm/has_property.rb', line 22 def properties = @model.properties.entries.map { |property| property.name } "expected to has property #@expected, but has just the following properties: #{properties}" end |
#matches?(model) ⇒ Boolean
Category.should has_property(:id)
13 14 15 16 |
# File 'lib/spec/matchers/dm/has_property.rb', line 13 def matches?(model) @model = model return @model.properties.has_property?(@expected) end |
#negative_failure_message ⇒ Object
27 28 29 |
# File 'lib/spec/matchers/dm/has_property.rb', line 27 def "expected to not has property #@expected, but had" end |