Class Paperclip::Shoulda::Matchers::HaveAttachedFileMatcher
In: lib/paperclip/matchers/have_attached_file_matcher.rb
Parent: Object

Methods

Public Class methods

[Source]

    # File lib/paperclip/matchers/have_attached_file_matcher.rb, line 16
16:         def initialize attachment_name
17:           @attachment_name = attachment_name
18:         end

Public Instance methods

[Source]

    # File lib/paperclip/matchers/have_attached_file_matcher.rb, line 34
34:         def description
35:           "have an attachment named #{@attachment_name}"
36:         end

[Source]

    # File lib/paperclip/matchers/have_attached_file_matcher.rb, line 26
26:         def failure_message
27:           "Should have an attachment named #{@attachment_name}"
28:         end

[Source]

    # File lib/paperclip/matchers/have_attached_file_matcher.rb, line 20
20:         def matches? subject
21:           @subject = subject
22:           @subject = @subject.class unless Class === @subject
23:           responds? && has_column? && included?
24:         end

[Source]

    # File lib/paperclip/matchers/have_attached_file_matcher.rb, line 30
30:         def negative_failure_message
31:           "Should not have an attachment named #{@attachment_name}"
32:         end

Protected Instance methods

[Source]

    # File lib/paperclip/matchers/have_attached_file_matcher.rb, line 47
47:         def has_column?
48:           @subject.column_names.include?("#{@attachment_name}_file_name")
49:         end

[Source]

    # File lib/paperclip/matchers/have_attached_file_matcher.rb, line 51
51:         def included?
52:           @subject.ancestors.include?(Paperclip::InstanceMethods)
53:         end

[Source]

    # File lib/paperclip/matchers/have_attached_file_matcher.rb, line 40
40:         def responds?
41:           methods = @subject.instance_methods.map(&:to_s)
42:           methods.include?("#{@attachment_name}") &&
43:             methods.include?("#{@attachment_name}=") &&
44:             methods.include?("#{@attachment_name}?")
45:         end

[Validate]