Class: Paperclip::Shoulda::Matchers::ValidateAttachmentPresenceMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/paperclip/matchers/validate_attachment_presence_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(attachment_name) ⇒ ValidateAttachmentPresenceMatcher

Returns a new instance of ValidateAttachmentPresenceMatcher



15
16
17
# File 'lib/paperclip/matchers/validate_attachment_presence_matcher.rb', line 15

def initialize attachment_name
  @attachment_name = attachment_name
end

Instance Method Details

#descriptionObject



33
34
35
# File 'lib/paperclip/matchers/validate_attachment_presence_matcher.rb', line 33

def description
  "require presence of attachment #{@attachment_name}"
end

#failure_messageObject



25
26
27
# File 'lib/paperclip/matchers/validate_attachment_presence_matcher.rb', line 25

def failure_message
  "Attachment #{@attachment_name} should be required"
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/paperclip/matchers/validate_attachment_presence_matcher.rb', line 19

def matches? subject
  @subject = subject
  @subject = @subject.class unless Class === @subject
  error_when_not_valid? && no_error_when_valid?
end

#negative_failure_messageObject



29
30
31
# File 'lib/paperclip/matchers/validate_attachment_presence_matcher.rb', line 29

def negative_failure_message
  "Attachment #{@attachment_name} should not be required"
end