Class: Shoulda::Lotus::Matchers::ValidatePresenceOfMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda/lotus/matchers/validate_presence_of_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(attribute) ⇒ ValidatePresenceOfMatcher



9
10
11
# File 'lib/shoulda/lotus/matchers/validate_presence_of_matcher.rb', line 9

def initialize(attribute)
  @attribute = attribute
end

Instance Method Details

#descriptionObject



17
18
19
# File 'lib/shoulda/lotus/matchers/validate_presence_of_matcher.rb', line 17

def description
  "require '#{@attribute}' to be set"
end

#failure_messageObject



21
22
23
# File 'lib/shoulda/lotus/matchers/validate_presence_of_matcher.rb', line 21

def failure_message
  "'#{@attribute}' is a required attribute"
end

#failure_message_when_negatedObject



25
26
27
# File 'lib/shoulda/lotus/matchers/validate_presence_of_matcher.rb', line 25

def failure_message_when_negated
  "'#{@attribute}' is not a required attribute"
end

#matches?(target) ⇒ Boolean



13
14
15
# File 'lib/shoulda/lotus/matchers/validate_presence_of_matcher.rb', line 13

def matches?(target)
  Matcher.new(target, @attribute, :presence).matches?
end