From e8d53313d87c2c23fe490fce7d762deb48692d69 Mon Sep 17 00:00:00 2001 From: Abel Martin Date: Wed, 7 Dec 2011 03:09:24 -0500 Subject: [PATCH] Updated documentation for Test::Unit --- lib/paperclip/matchers.rb | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/paperclip/matchers.rb b/lib/paperclip/matchers.rb index bac4221d9..3ba5cdd42 100644 --- a/lib/paperclip/matchers.rb +++ b/lib/paperclip/matchers.rb @@ -5,13 +5,15 @@ module Paperclip 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: # # require "paperclip/matchers" # - # And include the module: + # And _include_ the module: # # Spec::Runner.configure do |config| # config.include Paperclip::Shoulda::Matchers @@ -27,6 +29,35 @@ module Shoulda # it { should validate_attachment_size(:avatar). # less_than(2.megabytes) } # 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 end end