module MiniPaperclip::Shoulda::Matchers
Public Instance Methods
have_attached_file(name)
click to toggle source
Ensures that the given instance or class has an attachment with the given name.
Example:
describe User do it { should have_attached_file(:avatar) } end
# File lib/mini_paperclip/shoulda/matchers/have_attached_file_matcher.rb, line 13 def have_attached_file name HaveAttachedFileMatcher.new(name) end
validate_attachment_content_type(attachment_name)
click to toggle source
Ensures that the given instance or class validates the content type of the given attachment as specified.
Example:
describe User do it { should validate_attachment_content_type(:icon). allowing('image/png', 'image/gif'). rejecting('text/plain', 'text/xml') } end
# File lib/mini_paperclip/shoulda/matchers/validate_attachment_content_type_matcher.rb, line 15 def validate_attachment_content_type(attachment_name) ValidateAttachmentContentTypeMatcher.new(attachment_name) end
validate_attachment_geometry(attachment_name)
click to toggle source
Ensures that the given instance or class validates the geometry of the given attachment as specified.
Example:
describe User do it { should validate_attachment_geometry(:icon) .format(:png) .width(less_than_or_equal_to: 100) .height(less_than_or_equal_to: 100) end
# File lib/mini_paperclip/shoulda/matchers/validate_attachment_geometry_matcher.rb, line 16 def validate_attachment_geometry(attachment_name) ValidateAttachmentGeometryMatcher.new(attachment_name) end
validate_attachment_presence(attachment_name)
click to toggle source
Ensures that the given instance or class validates the presence of the given attachment.
describe User do
it { should validate_attachment_presence(:avatar) }
end
# File lib/mini_paperclip/shoulda/matchers/validate_attachment_presence_matcher.rb, line 12 def validate_attachment_presence(attachment_name) ValidateAttachmentPresenceMatcher.new(attachment_name) end
validate_attachment_size(attachment_name)
click to toggle source
Ensures that the given instance or class validates the size of the given attachment as specified.
Examples:
it { should validate_attachment_size(:avatar). less_than(2.megabytes) }
# File lib/mini_paperclip/shoulda/matchers/validate_attachment_size_matcher.rb, line 12 def validate_attachment_size(attachment_name) ValidateAttachmentSizeMatcher.new(attachment_name) end