durran-validatable 1.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +118 -0
 - data/Rakefile +55 -0
 - data/VERSION.yml +4 -0
 - data/lib/child_validation.rb +15 -0
 - data/lib/errors.rb +90 -0
 - data/lib/included_validation.rb +9 -0
 - data/lib/macros.rb +306 -0
 - data/lib/object_extension.rb +21 -0
 - data/lib/requireable.rb +26 -0
 - data/lib/understandable.rb +31 -0
 - data/lib/validatable.rb +25 -0
 - data/lib/validatable_class_methods.rb +85 -0
 - data/lib/validatable_instance_methods.rb +116 -0
 - data/lib/validations/validates_acceptance_of.rb +14 -0
 - data/lib/validations/validates_associated.rb +13 -0
 - data/lib/validations/validates_confirmation_of.rb +23 -0
 - data/lib/validations/validates_each.rb +14 -0
 - data/lib/validations/validates_format_of.rb +16 -0
 - data/lib/validations/validates_length_of.rb +30 -0
 - data/lib/validations/validates_numericality_of.rb +27 -0
 - data/lib/validations/validates_presence_of.rb +17 -0
 - data/lib/validations/validates_true_for.rb +13 -0
 - data/lib/validations/validation_base.rb +91 -0
 - data/test/all_tests.rb +1 -0
 - data/test/functional/test_validatable.rb +589 -0
 - data/test/functional/test_validates_acceptance_of.rb +16 -0
 - data/test/functional/test_validates_associated.rb +41 -0
 - data/test/functional/test_validates_confirmation_of.rb +56 -0
 - data/test/functional/test_validates_each.rb +14 -0
 - data/test/functional/test_validates_format_of.rb +34 -0
 - data/test/functional/test_validates_length_of.rb +64 -0
 - data/test/functional/test_validates_numericality_of.rb +57 -0
 - data/test/functional/test_validates_presence_of.rb +16 -0
 - data/test/functional/test_validates_true_for.rb +27 -0
 - data/test/test_helper.rb +33 -0
 - data/test/unit/test_errors.rb +70 -0
 - data/test/unit/test_understandable.rb +19 -0
 - data/test/unit/test_validatable.rb +38 -0
 - data/test/unit/test_validates_acceptance_of.rb +45 -0
 - data/test/unit/test_validates_associated.rb +29 -0
 - data/test/unit/test_validates_confirmation_of.rb +76 -0
 - data/test/unit/test_validates_format_of.rb +44 -0
 - data/test/unit/test_validates_length_of.rb +80 -0
 - data/test/unit/test_validates_numericality_of.rb +76 -0
 - data/test/unit/test_validates_presence_of.rb +35 -0
 - data/test/unit/test_validates_true_for.rb +29 -0
 - data/test/unit/test_validation_base.rb +52 -0
 - metadata +126 -0
 
| 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Expectations do
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              expect false do
         
     | 
| 
      
 6 
     | 
    
         
            +
                validation = Validatable::ValidatesTrueFor.new stub_everything, :name, :logic => lambda { false }
         
     | 
| 
      
 7 
     | 
    
         
            +
                validation.valid?(stub_everything)
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
              expect true do
         
     | 
| 
      
 11 
     | 
    
         
            +
                validation = Validatable::ValidatesTrueFor.new stub_everything, :name, :logic => lambda { true }
         
     | 
| 
      
 12 
     | 
    
         
            +
                validation.valid?(stub_everything)
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
              
         
     | 
| 
      
 15 
     | 
    
         
            +
              expect ArgumentError do
         
     | 
| 
      
 16 
     | 
    
         
            +
                validation = Validatable::ValidatesTrueFor.new stub_everything, :age
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
              
         
     | 
| 
      
 19 
     | 
    
         
            +
              expect true do
         
     | 
| 
      
 20 
     | 
    
         
            +
                options = [:message, :if, :times, :level, :groups, :logic, :key]
         
     | 
| 
      
 21 
     | 
    
         
            +
                Validatable::ValidatesTrueFor.new(stub_everything, :name, options.to_blank_options_hash).must_understand(options.to_blank_options_hash)
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
              
         
     | 
| 
      
 24 
     | 
    
         
            +
              expect true do
         
     | 
| 
      
 25 
     | 
    
         
            +
                options = [:logic]
         
     | 
| 
      
 26 
     | 
    
         
            +
                Validatable::ValidatesTrueFor.new(stub_everything, :name, options.to_blank_options_hash).requires(options.to_blank_options_hash)
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
              
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,52 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Expectations do
         
     | 
| 
      
 4 
     | 
    
         
            +
              expect true do
         
     | 
| 
      
 5 
     | 
    
         
            +
                validation = Validatable::ValidationBase.new stub_everything, :base
         
     | 
| 
      
 6 
     | 
    
         
            +
                validation.should_validate? Object.new
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
              
         
     | 
| 
      
 9 
     | 
    
         
            +
              expect true do
         
     | 
| 
      
 10 
     | 
    
         
            +
                validation = Validatable::ValidationBase.new stub_everything, :base, :times => 1
         
     | 
| 
      
 11 
     | 
    
         
            +
                validation.validate_this_time?(stub(:times_validated => 0))
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              expect true do
         
     | 
| 
      
 15 
     | 
    
         
            +
                validation = Validatable::ValidationBase.new stub_everything, :base
         
     | 
| 
      
 16 
     | 
    
         
            +
                validation.validate_this_time?(nil)
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
              
         
     | 
| 
      
 19 
     | 
    
         
            +
              expect true do
         
     | 
| 
      
 20 
     | 
    
         
            +
                validation = Validatable::ValidationBase.new stub_everything, :base, :times => 2
         
     | 
| 
      
 21 
     | 
    
         
            +
                validation.validate_this_time?(stub(:times_validated => 1))
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              expect false do
         
     | 
| 
      
 25 
     | 
    
         
            +
                validation = Validatable::ValidationBase.new stub_everything, :base, :times => 1
         
     | 
| 
      
 26 
     | 
    
         
            +
                validation.validate_this_time?(stub(:times_validated => 1))
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
              
         
     | 
| 
      
 29 
     | 
    
         
            +
              expect 1 do
         
     | 
| 
      
 30 
     | 
    
         
            +
                validation = Validatable::ValidationBase.new stub_everything, :base
         
     | 
| 
      
 31 
     | 
    
         
            +
                validation.level
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
              
         
     | 
| 
      
 34 
     | 
    
         
            +
              expect ArgumentError do
         
     | 
| 
      
 35 
     | 
    
         
            +
                Validatable::ValidationBase.new stub_everything(:validation_keys_include? => true), :base, :times => 1
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
              
         
     | 
| 
      
 38 
     | 
    
         
            +
              expect "some message 100" do
         
     | 
| 
      
 39 
     | 
    
         
            +
                validation = Validatable::ValidationBase.new stub_everything, :base, :message => lambda { "some message #{a_method}" }
         
     | 
| 
      
 40 
     | 
    
         
            +
                validation.message(stub(:a_method=>'100'))
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
              
         
     | 
| 
      
 43 
     | 
    
         
            +
              expect ArgumentError do
         
     | 
| 
      
 44 
     | 
    
         
            +
                Validatable::ValidationBase.new(stub_everything, :base).must_understand(:foo => 1, :bar => 2)
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
              
         
     | 
| 
      
 47 
     | 
    
         
            +
              expect true do
         
     | 
| 
      
 48 
     | 
    
         
            +
                options = {:message => nil, :if => nil, :times => nil, :level => nil, :groups => nil, :key => nil}
         
     | 
| 
      
 49 
     | 
    
         
            +
                Validatable::ValidationBase.new(stub_everything, :base).must_understand(options)
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,126 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: durran-validatable
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.7.5
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Jay Fields
         
     | 
| 
      
 8 
     | 
    
         
            +
            - John Nunemaker
         
     | 
| 
      
 9 
     | 
    
         
            +
            - Durran Jordan
         
     | 
| 
      
 10 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 11 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 12 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            date: 2009-10-27 00:00:00 -04:00
         
     | 
| 
      
 15 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 16 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            description: 
         
     | 
| 
      
 19 
     | 
    
         
            +
            email: durran@gmail.com
         
     | 
| 
      
 20 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            extra_rdoc_files: 
         
     | 
| 
      
 25 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 26 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 27 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 28 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 29 
     | 
    
         
            +
            - VERSION.yml
         
     | 
| 
      
 30 
     | 
    
         
            +
            - lib/child_validation.rb
         
     | 
| 
      
 31 
     | 
    
         
            +
            - lib/errors.rb
         
     | 
| 
      
 32 
     | 
    
         
            +
            - lib/included_validation.rb
         
     | 
| 
      
 33 
     | 
    
         
            +
            - lib/macros.rb
         
     | 
| 
      
 34 
     | 
    
         
            +
            - lib/object_extension.rb
         
     | 
| 
      
 35 
     | 
    
         
            +
            - lib/requireable.rb
         
     | 
| 
      
 36 
     | 
    
         
            +
            - lib/understandable.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            - lib/validatable.rb
         
     | 
| 
      
 38 
     | 
    
         
            +
            - lib/validatable_class_methods.rb
         
     | 
| 
      
 39 
     | 
    
         
            +
            - lib/validatable_instance_methods.rb
         
     | 
| 
      
 40 
     | 
    
         
            +
            - lib/validations/validates_acceptance_of.rb
         
     | 
| 
      
 41 
     | 
    
         
            +
            - lib/validations/validates_associated.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
            - lib/validations/validates_confirmation_of.rb
         
     | 
| 
      
 43 
     | 
    
         
            +
            - lib/validations/validates_each.rb
         
     | 
| 
      
 44 
     | 
    
         
            +
            - lib/validations/validates_format_of.rb
         
     | 
| 
      
 45 
     | 
    
         
            +
            - lib/validations/validates_length_of.rb
         
     | 
| 
      
 46 
     | 
    
         
            +
            - lib/validations/validates_numericality_of.rb
         
     | 
| 
      
 47 
     | 
    
         
            +
            - lib/validations/validates_presence_of.rb
         
     | 
| 
      
 48 
     | 
    
         
            +
            - lib/validations/validates_true_for.rb
         
     | 
| 
      
 49 
     | 
    
         
            +
            - lib/validations/validation_base.rb
         
     | 
| 
      
 50 
     | 
    
         
            +
            - test/all_tests.rb
         
     | 
| 
      
 51 
     | 
    
         
            +
            - test/functional/test_validatable.rb
         
     | 
| 
      
 52 
     | 
    
         
            +
            - test/functional/test_validates_acceptance_of.rb
         
     | 
| 
      
 53 
     | 
    
         
            +
            - test/functional/test_validates_associated.rb
         
     | 
| 
      
 54 
     | 
    
         
            +
            - test/functional/test_validates_confirmation_of.rb
         
     | 
| 
      
 55 
     | 
    
         
            +
            - test/functional/test_validates_each.rb
         
     | 
| 
      
 56 
     | 
    
         
            +
            - test/functional/test_validates_format_of.rb
         
     | 
| 
      
 57 
     | 
    
         
            +
            - test/functional/test_validates_length_of.rb
         
     | 
| 
      
 58 
     | 
    
         
            +
            - test/functional/test_validates_numericality_of.rb
         
     | 
| 
      
 59 
     | 
    
         
            +
            - test/functional/test_validates_presence_of.rb
         
     | 
| 
      
 60 
     | 
    
         
            +
            - test/functional/test_validates_true_for.rb
         
     | 
| 
      
 61 
     | 
    
         
            +
            - test/test_helper.rb
         
     | 
| 
      
 62 
     | 
    
         
            +
            - test/unit/test_errors.rb
         
     | 
| 
      
 63 
     | 
    
         
            +
            - test/unit/test_understandable.rb
         
     | 
| 
      
 64 
     | 
    
         
            +
            - test/unit/test_validatable.rb
         
     | 
| 
      
 65 
     | 
    
         
            +
            - test/unit/test_validates_acceptance_of.rb
         
     | 
| 
      
 66 
     | 
    
         
            +
            - test/unit/test_validates_associated.rb
         
     | 
| 
      
 67 
     | 
    
         
            +
            - test/unit/test_validates_confirmation_of.rb
         
     | 
| 
      
 68 
     | 
    
         
            +
            - test/unit/test_validates_format_of.rb
         
     | 
| 
      
 69 
     | 
    
         
            +
            - test/unit/test_validates_length_of.rb
         
     | 
| 
      
 70 
     | 
    
         
            +
            - test/unit/test_validates_numericality_of.rb
         
     | 
| 
      
 71 
     | 
    
         
            +
            - test/unit/test_validates_presence_of.rb
         
     | 
| 
      
 72 
     | 
    
         
            +
            - test/unit/test_validates_true_for.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - test/unit/test_validation_base.rb
         
     | 
| 
      
 74 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 75 
     | 
    
         
            +
            homepage: http://github.com/durran/validatable
         
     | 
| 
      
 76 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 79 
     | 
    
         
            +
            rdoc_options: 
         
     | 
| 
      
 80 
     | 
    
         
            +
            - --charset=UTF-8
         
     | 
| 
      
 81 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 82 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 83 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 84 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 85 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 86 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 87 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 88 
     | 
    
         
            +
              version: 
         
     | 
| 
      
 89 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 90 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 91 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 92 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 93 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 94 
     | 
    
         
            +
              version: 
         
     | 
| 
      
 95 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 98 
     | 
    
         
            +
            rubygems_version: 1.3.5
         
     | 
| 
      
 99 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 100 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 101 
     | 
    
         
            +
            summary: Validatable is a library for adding validations.
         
     | 
| 
      
 102 
     | 
    
         
            +
            test_files: 
         
     | 
| 
      
 103 
     | 
    
         
            +
            - test/all_tests.rb
         
     | 
| 
      
 104 
     | 
    
         
            +
            - test/functional/test_validatable.rb
         
     | 
| 
      
 105 
     | 
    
         
            +
            - test/functional/test_validates_acceptance_of.rb
         
     | 
| 
      
 106 
     | 
    
         
            +
            - test/functional/test_validates_associated.rb
         
     | 
| 
      
 107 
     | 
    
         
            +
            - test/functional/test_validates_confirmation_of.rb
         
     | 
| 
      
 108 
     | 
    
         
            +
            - test/functional/test_validates_each.rb
         
     | 
| 
      
 109 
     | 
    
         
            +
            - test/functional/test_validates_format_of.rb
         
     | 
| 
      
 110 
     | 
    
         
            +
            - test/functional/test_validates_length_of.rb
         
     | 
| 
      
 111 
     | 
    
         
            +
            - test/functional/test_validates_numericality_of.rb
         
     | 
| 
      
 112 
     | 
    
         
            +
            - test/functional/test_validates_presence_of.rb
         
     | 
| 
      
 113 
     | 
    
         
            +
            - test/functional/test_validates_true_for.rb
         
     | 
| 
      
 114 
     | 
    
         
            +
            - test/test_helper.rb
         
     | 
| 
      
 115 
     | 
    
         
            +
            - test/unit/test_errors.rb
         
     | 
| 
      
 116 
     | 
    
         
            +
            - test/unit/test_understandable.rb
         
     | 
| 
      
 117 
     | 
    
         
            +
            - test/unit/test_validatable.rb
         
     | 
| 
      
 118 
     | 
    
         
            +
            - test/unit/test_validates_acceptance_of.rb
         
     | 
| 
      
 119 
     | 
    
         
            +
            - test/unit/test_validates_associated.rb
         
     | 
| 
      
 120 
     | 
    
         
            +
            - test/unit/test_validates_confirmation_of.rb
         
     | 
| 
      
 121 
     | 
    
         
            +
            - test/unit/test_validates_format_of.rb
         
     | 
| 
      
 122 
     | 
    
         
            +
            - test/unit/test_validates_length_of.rb
         
     | 
| 
      
 123 
     | 
    
         
            +
            - test/unit/test_validates_numericality_of.rb
         
     | 
| 
      
 124 
     | 
    
         
            +
            - test/unit/test_validates_presence_of.rb
         
     | 
| 
      
 125 
     | 
    
         
            +
            - test/unit/test_validates_true_for.rb
         
     | 
| 
      
 126 
     | 
    
         
            +
            - test/unit/test_validation_base.rb
         
     |