Class: DataMapper::Matchers::HaveProperty

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

Instance Method Summary collapse

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

#descriptionObject



22
23
24
# File 'lib/dm/matchers/have_property.rb', line 22

def description
  "have property #{@property}"
end

#failure_messageObject



14
15
16
# File 'lib/dm/matchers/have_property.rb', line 14

def failure_message
  "expected to have property #{@property}"
end

#matches?(model) ⇒ Boolean

Returns:

  • (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_messageObject



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

def negative_failure_message
  "expected to not have property #{@property}"
end