class Paperclip::Shoulda::Matchers::HaveAttachedFileMatcher

Public Class Methods

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

Public Instance Methods

description() click to toggle source
# File lib/paperclip/matchers/have_attached_file_matcher.rb, line 35
def description
  "have an attachment named #{@attachment_name}"
end
failure_message() click to toggle source
# File lib/paperclip/matchers/have_attached_file_matcher.rb, line 26
def failure_message
  "Should have an attachment named #{@attachment_name}"
end
failure_message_when_negated() click to toggle source
# File lib/paperclip/matchers/have_attached_file_matcher.rb, line 30
def failure_message_when_negated
  "Should not have an attachment named #{@attachment_name}"
end
Also aliased as: negative_failure_message
matches?(subject) click to toggle source
# File lib/paperclip/matchers/have_attached_file_matcher.rb, line 20
def matches?(subject)
  @subject = subject
  @subject = @subject.class unless Class === @subject
  responds? && has_column?
end
negative_failure_message()

Protected Instance Methods

has_column?() click to toggle source
# File lib/paperclip/matchers/have_attached_file_matcher.rb, line 48
def has_column?
  @subject.column_names.include?("#{@attachment_name}_file_name")
end
responds?() click to toggle source
# File lib/paperclip/matchers/have_attached_file_matcher.rb, line 41
def responds?
  methods = @subject.instance_methods.map(&:to_s)
  methods.include?(@attachment_name.to_s) &&
    methods.include?("#{@attachment_name}=") &&
    methods.include?("#{@attachment_name}?")
end