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

Returns a new instance of HaveAttachedFileMatcher.



18
19
20
# File 'lib/paperclip/matchers/have_attached_file_matcher.rb', line 18

def initialize(attachment_name)
  @attachment_name = attachment_name
end

Instance Method Details

#descriptionObject



37
38
39
# File 'lib/paperclip/matchers/have_attached_file_matcher.rb', line 37

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

#failure_messageObject



28
29
30
# File 'lib/paperclip/matchers/have_attached_file_matcher.rb', line 28

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

#failure_message_when_negatedObject Also known as: negative_failure_message



32
33
34
# File 'lib/paperclip/matchers/have_attached_file_matcher.rb', line 32

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

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
# File 'lib/paperclip/matchers/have_attached_file_matcher.rb', line 22

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