Module: MiniPaperclip::Shoulda::Matchers
- Defined in:
- lib/mini_paperclip/shoulda/matchers/have_attached_file_matcher.rb,
lib/mini_paperclip/shoulda/matchers/validate_attachment_size_matcher.rb,
lib/mini_paperclip/shoulda/matchers/validate_attachment_geometry_matcher.rb,
lib/mini_paperclip/shoulda/matchers/validate_attachment_presence_matcher.rb,
lib/mini_paperclip/shoulda/matchers/validate_attachment_content_type_matcher.rb
Defined Under Namespace
Classes: HaveAttachedFileMatcher, ValidateAttachmentContentTypeMatcher, ValidateAttachmentGeometryMatcher, ValidateAttachmentPresenceMatcher, ValidateAttachmentSizeMatcher
Instance Method Summary collapse
-
#have_attached_file(name) ⇒ Object
Ensures that the given instance or class has an attachment with the given name.
-
#validate_attachment_content_type(attachment_name) ⇒ Object
Ensures that the given instance or class validates the content type of the given attachment as specified.
-
#validate_attachment_geometry(attachment_name) ⇒ Object
Ensures that the given instance or class validates the geometry of the given attachment as specified.
-
#validate_attachment_presence(attachment_name) ⇒ Object
Ensures that the given instance or class validates the presence of the given attachment.
-
#validate_attachment_size(attachment_name) ⇒ Object
Ensures that the given instance or class validates the size of the given attachment as specified.
Instance Method Details
#have_attached_file(name) ⇒ Object
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
13 14 15 |
# 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) ⇒ Object
Ensures that the given instance or class validates the content type of the given attachment as specified.
Example:
describe User do
it { should (:icon).
allowing('image/png', 'image/gif').
rejecting('text/plain', 'text/xml') }
end
15 16 17 |
# File 'lib/mini_paperclip/shoulda/matchers/validate_attachment_content_type_matcher.rb', line 15 def () ValidateAttachmentContentTypeMatcher.new() end |
#validate_attachment_geometry(attachment_name) ⇒ Object
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
16 17 18 |
# File 'lib/mini_paperclip/shoulda/matchers/validate_attachment_geometry_matcher.rb', line 16 def () ValidateAttachmentGeometryMatcher.new() end |
#validate_attachment_presence(attachment_name) ⇒ Object
Ensures that the given instance or class validates the presence of the given attachment.
describe User do
it { should (:avatar) }
end
12 13 14 |
# File 'lib/mini_paperclip/shoulda/matchers/validate_attachment_presence_matcher.rb', line 12 def () ValidateAttachmentPresenceMatcher.new() end |
#validate_attachment_size(attachment_name) ⇒ Object
Ensures that the given instance or class validates the size of the given attachment as specified.
Examples:
it { should (:avatar).
less_than(2.megabytes) }
12 13 14 |
# File 'lib/mini_paperclip/shoulda/matchers/validate_attachment_size_matcher.rb', line 12 def () ValidateAttachmentSizeMatcher.new() end |