Parent

Files

Class/Module Index [+]

Quicksearch

Paperclip::Shoulda::Matchers::ValidateAttachmentPresenceMatcher

Public Class Methods

new(attachment_name) click to toggle source
# File lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 15
def initialize attachment_name
  @attachment_name = attachment_name
end

Public Instance Methods

description() click to toggle source
# File lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 33
def description
  "require presence of attachment #{@attachment_name}"
end
failure_message() click to toggle source
# File lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 25
def failure_message
  "Attachment #{@attachment_name} should be required"
end
matches?(subject) click to toggle source
# File lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 19
def matches? subject
  @subject = subject
  @subject = subject.new if subject.class == Class
  error_when_not_valid? && no_error_when_valid?
end
negative_failure_message() click to toggle source
# File lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 29
def negative_failure_message
  "Attachment #{@attachment_name} should not be required"
end

Protected Instance Methods

error_when_not_valid?() click to toggle source
# File lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 39
def error_when_not_valid?
  @subject.send(@attachment_name).assign(nil)
  @subject.valid?
  @subject.errors[:"#{@attachment_name}"].present?
end
no_error_when_valid?() click to toggle source
# File lib/paperclip/matchers/validate_attachment_presence_matcher.rb, line 45
def no_error_when_valid?
  @file = StringIO.new(".")
  @subject.send(@attachment_name).assign(@file)
  @subject.valid?
  @subject.errors[:"#{@attachment_name}"].blank?
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.