Class | Paperclip::Shoulda::Matchers::ValidateAttachmentPresenceMatcher
In: | vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher.rb
Parent: | Object

### Methods

description error_when_not_valid? failure_message matches? negative_failure_message new no_error_when_valid?

### Public Class methods

new(attachment_name)

[Source]

        # File vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 9
     9:         def initialize attachment_name
    10:           @attachment_name = attachment_name
    11:         end

### Public Instance methods

description()

[Source]

        # File vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 26
    26:         def description
    27:           "require presence of attachment #{@attachment_name}"
    28:         end

failure_message()

[Source]

        # File vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 18
    18:         def failure_message
    19:           "Attachment #{@attachment_name} should be required"
    20:         end

matches?(subject)

[Source]

        # File vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 13
    13:         def matches? subject
    14:           @subject = subject
    15:           error_when_not_valid? && no_error_when_valid?
    16:         end

negative_failure_message()

[Source]

        # File vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 22
    22:         def negative_failure_message
    23:           "Attachment #{@attachment_name} should not be required"
    24:         end

### Protected Instance methods

error_when_not_valid?()

[Source]

        # File vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 32
    32:         def error_when_not_valid?
    33:           @attachment = @subject.new.send(@attachment_name)
    34:           @attachment.assign(nil)
    35:           not @attachment.errors[:presence].nil?
    36:         end

no_error_when_valid?()

[Source]

        # File vendor/plugins/paperclip/lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 38
    38:         def no_error_when_valid?
    39:           @file = StringIO.new(".")
    40:           @attachment = @subject.new.send(@attachment_name)
    41:           @attachment.assign(@file)
    42:           @attachment.errors[:presence].nil?
    43:         end

[Validate]