Skip to content
This repository
Browse code

Updated documentation for Test::Unit

  • Loading branch information...
commit e8d53313d87c2c23fe490fce7d762deb48692d69 1 parent 3ba8fcb
Abel Martin authored December 07, 2011

Showing 1 changed file with 33 additions and 2 deletions. Show diff stats Hide diff stats

  1. 35  lib/paperclip/matchers.rb
35  lib/paperclip/matchers.rb
@@ -5,13 +5,15 @@
5 5
 
6 6
 module Paperclip
7 7
   module Shoulda
8  
-    # Provides rspec-compatible matchers for testing Paperclip attachments.
  8
+    # Provides RSpec-compatible & Test::Unit-compatible matchers for testing Paperclip attachments.
  9
+    #
  10
+    # *RSpec*
9 11
     #
10 12
     # In spec_helper.rb, you'll need to require the matchers:
11 13
     #
12 14
     #   require "paperclip/matchers"
13 15
     #
14  
-    # And include the module:
  16
+    # And _include_ the module:
15 17
     #
16 18
     #   Spec::Runner.configure do |config|
17 19
     #     config.include Paperclip::Shoulda::Matchers
@@ -27,6 +29,35 @@ module Shoulda
27 29
     #     it { should validate_attachment_size(:avatar).
28 30
     #                   less_than(2.megabytes) }
29 31
     #   end
  32
+    #
  33
+    #
  34
+    # *Test*::*Unit*
  35
+    #
  36
+    # In test_helper.rb, you'll need to require the matchers as well:
  37
+    #
  38
+    #   require "paperclip/matchers"
  39
+    #
  40
+    # And _extend_ the module:
  41
+    #
  42
+    #   class ActiveSupport::TestCase
  43
+    #     extend  Paperclip::Shoulda::Matchers
  44
+    #     
  45
+    #     #...other initializers...#
  46
+    #   end
  47
+    #
  48
+    # Example:
  49
+    #   require 'test_helper'
  50
+    #
  51
+    #   class UserTest < ActiveSupport::TestCase
  52
+    #     should have_attached_file(:avatar)
  53
+    #     should validate_attachment_presence(:avatar)
  54
+    #     should validate_attachment_content_type(:avatar).
  55
+    #                  allowing('image/png', 'image/gif').
  56
+    #                  rejecting('text/plain', 'text/xml')
  57
+    #     should validate_attachment_size(:avatar).
  58
+    #                  less_than(2.megabytes)
  59
+    #   end
  60
+    #  
30 61
     module Matchers
31 62
     end
32 63
   end

0 notes on commit e8d5331

Please sign in to comment.
Something went wrong with that request. Please try again.