Class: MiniPaperclip::Shoulda::Matchers::HaveAttachedFileMatcher
- Inherits:
-
Object
- Object
- MiniPaperclip::Shoulda::Matchers::HaveAttachedFileMatcher
- Defined in:
- lib/mini_paperclip/shoulda/matchers/have_attached_file_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object (also: #negative_failure_message)
-
#initialize(attachment_name) ⇒ HaveAttachedFileMatcher
constructor
A new instance of HaveAttachedFileMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(attachment_name) ⇒ HaveAttachedFileMatcher
Returns a new instance of HaveAttachedFileMatcher.
18 19 20 |
# File 'lib/mini_paperclip/shoulda/matchers/have_attached_file_matcher.rb', line 18 def initialize = end |
Instance Method Details
#description ⇒ Object
40 41 42 |
# File 'lib/mini_paperclip/shoulda/matchers/have_attached_file_matcher.rb', line 40 def description "have an attachment named #{@attachment_name}" end |
#failure_message ⇒ Object
31 32 33 |
# File 'lib/mini_paperclip/shoulda/matchers/have_attached_file_matcher.rb', line 31 def "Should have an attachment named #{@attachment_name}" end |
#failure_message_when_negated ⇒ Object Also known as: negative_failure_message
35 36 37 |
# File 'lib/mini_paperclip/shoulda/matchers/have_attached_file_matcher.rb', line 35 def "Should not have an attachment named #{@attachment_name}" end |
#matches?(subject) ⇒ Boolean
22 23 24 25 26 27 28 29 |
# File 'lib/mini_paperclip/shoulda/matchers/have_attached_file_matcher.rb', line 22 def matches? subject @subject = subject.class == Class ? subject.new : subject @subject.respond_to?() && @subject.respond_to?("#{@attachment_name}=") && @subject.public_send().kind_of?(MiniPaperclip::Attachment) && @subject.class.column_names.include?("#{@attachment_name}_file_name") end |