Class: Paperclip::Shoulda::Matchers::HaveAttachedFileMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(attachment_name) ⇒ HaveAttachedFileMatcher



16
17
18
# File 'lib/paperclip/matchers/have_attached_file_matcher.rb', line 16

def initialize attachment_name
  @attachment_name = attachment_name
end

Instance Method Details

#descriptionObject



35
36
37
# File 'lib/paperclip/matchers/have_attached_file_matcher.rb', line 35

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

#failure_messageObject



26
27
28
# 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_negatedObject Also known as: negative_failure_message



30
31
32
# 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

#matches?(subject) ⇒ Boolean



20
21
22
23
24
# 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