Class: DataMapperMatchers::HasProperty

Inherits:
Object
  • Object
show all
Defined in:
lib/spec/matchers/dm/has_property.rb

Instance Method Summary collapse

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

#descriptionObject



18
19
20
# File 'lib/spec/matchers/dm/has_property.rb', line 18

def description
  "has property"
end

#failure_messageObject



22
23
24
25
# File 'lib/spec/matchers/dm/has_property.rb', line 22

def failure_message
  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)

Returns:

  • (Boolean)


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_messageObject



27
28
29
# File 'lib/spec/matchers/dm/has_property.rb', line 27

def negative_failure_message
  "expected to not has property #@expected, but had"
end