Commit e8d53313 by Abel Martin

Updated documentation for Test::Unit

parent 3ba8fcba
...@@ -5,13 +5,15 @@ require 'paperclip/matchers/validate_attachment_size_matcher' ...@@ -5,13 +5,15 @@ require 'paperclip/matchers/validate_attachment_size_matcher'
module Paperclip module Paperclip
module Shoulda module Shoulda
# Provides rspec-compatible matchers for testing Paperclip attachments. # Provides RSpec-compatible & Test::Unit-compatible matchers for testing Paperclip attachments.
#
# *RSpec*
# #
# In spec_helper.rb, you'll need to require the matchers: # In spec_helper.rb, you'll need to require the matchers:
# #
# require "paperclip/matchers" # require "paperclip/matchers"
# #
# And include the module: # And _include_ the module:
# #
# Spec::Runner.configure do |config| # Spec::Runner.configure do |config|
# config.include Paperclip::Shoulda::Matchers # config.include Paperclip::Shoulda::Matchers
...@@ -27,6 +29,35 @@ module Paperclip ...@@ -27,6 +29,35 @@ module Paperclip
# it { should validate_attachment_size(:avatar). # it { should validate_attachment_size(:avatar).
# less_than(2.megabytes) } # less_than(2.megabytes) }
# end # end
#
#
# *Test*::*Unit*
#
# In test_helper.rb, you'll need to require the matchers as well:
#
# require "paperclip/matchers"
#
# And _extend_ the module:
#
# class ActiveSupport::TestCase
# extend Paperclip::Shoulda::Matchers
#
# #...other initializers...#
# end
#
# Example:
# require 'test_helper'
#
# class UserTest < ActiveSupport::TestCase
# should have_attached_file(:avatar)
# should validate_attachment_presence(:avatar)
# should validate_attachment_content_type(:avatar).
# allowing('image/png', 'image/gif').
# rejecting('text/plain', 'text/xml')
# should validate_attachment_size(:avatar).
# less_than(2.megabytes)
# end
#
module Matchers module Matchers
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment