class Paperclip::Shoulda::Matchers::HaveAttachedFileMatcher

def description

def description
  "have an attachment named #{@attachment_name}"
end

def failure_message

def failure_message
  "Should have an attachment named #{@attachment_name}"
end

def failure_message_when_negated

def failure_message_when_negated
  "Should not have an attachment named #{@attachment_name}"
end

def has_column?

def has_column?
  @subject.column_names.include?("#{@attachment_name}_file_name")
end

def initialize attachment_name

def initialize attachment_name
  @attachment_name = attachment_name
end

def matches? subject

def matches? subject
  @subject = subject
  @subject = @subject.class unless Class === @subject
  responds? && has_column?
end

def responds?

def responds?
  methods = @subject.instance_methods.map(&:to_s)
  methods.include?("#{@attachment_name}") &&
    methods.include?("#{@attachment_name}=") &&
    methods.include?("#{@attachment_name}?")
end