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.



9
10
11
# File 'lib/paperclip/matchers/have_attached_file_matcher.rb', line 9

def initialize attachment_name
  @attachment_name = attachment_name
end

Instance Method Details

#descriptionObject



26
27
28
# File 'lib/paperclip/matchers/have_attached_file_matcher.rb', line 26

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

#failure_messageObject



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

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

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/paperclip/matchers/have_attached_file_matcher.rb', line 13

def matches? subject
  @subject = subject
  responds? && has_column? && included?
end

#negative_failure_messageObject



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

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