Sha256: ba23d4a8cf6b0fa848d946d388d2ad9dde330545a2e4cc5606e531dc376ced06

Contents?: true

Size: 1.9 KB

Versions: 30

Compression:

Stored size: 1.9 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../test_helper')

module Functional
  class ValidatesConfirmationOfTest < Test::Unit::TestCase
    test "given non matching attributes, when validated, then error is in the objects error collection" do
      klass = Class.new do
        include Validatable
        attr_accessor :name
        validates_confirmation_of :name
      end
      instance = klass.new
      instance.name = "foo"
      instance.name_confirmation = "bar"
      instance.valid?
      assert_equal "doesn't match confirmation", instance.errors.on(:name)
    end

    test "given matching attributes, when validated, then no error is in the objects error collection" do
      klass = Class.new do
        include Validatable
        attr_accessor :name
        validates_confirmation_of :name
      end
      instance = klass.new
      instance.name = "foo"
      instance.name_confirmation = "foo"
      assert_equal true, instance.valid?
    end

    test "given matching attributes of different case, when validated with case sensitive false, then no error is in the objects error collection" do
      klass = Class.new do
        include Validatable
        attr_accessor :name
        validates_confirmation_of :name, :case_sensitive => false
      end
      instance = klass.new
      instance.name = "foo"
      instance.name_confirmation = "FOO"
      assert_equal true, instance.valid?
    end

    test "given matching attributes of different case, when validated with case sensitive true, then error is in the objects error collection" do
      klass = Class.new do
        include Validatable
        attr_accessor :name
        validates_confirmation_of :name
      end
      instance = klass.new
      instance.name = "foo"
      instance.name_confirmation = "FOO"
      assert_equal false, instance.valid?
      assert_equal "doesn't match confirmation", instance.errors.on(:name)
      
    end
  end
end

Version data entries

30 entries across 30 versions & 8 rubygems

Version Path
hashrocket-validatable-1.7.2 test/functional/test_validates_confirmation_of.rb
hashrocket-validatable-1.7.4 test/functional/test_validates_confirmation_of.rb
jnunemaker-validatable-1.7.0 test/functional/test_validates_confirmation_of.rb
jnunemaker-validatable-1.7.1 test/functional/test_validates_confirmation_of.rb
jnunemaker-validatable-1.7.2 test/functional/test_validates_confirmation_of.rb
vizjerai-validatable-1.8.0 test/functional/test_validates_confirmation_of.rb
vizjerai-validatable-1.9.0 test/functional/test_validates_confirmation_of.rb
lgustafson-validatable-1.8.7 test/functional/test_validates_confirmation_of.rb
lgustafson-validatable-1.8.6 test/functional/test_validates_confirmation_of.rb
np422-validatable-1.8.5 test/functional/test_validates_confirmation_of.rb
erotte-validatable-1.8.5 test/functional/test_validates_confirmation_of.rb
mattmatt-validatable-1.8.4 test/functional/test_validates_confirmation_of.rb
mattmatt-validatable-1.8.3 test/functional/test_validates_confirmation_of.rb
jnunemaker-validatable-1.8.4 test/functional/test_validates_confirmation_of.rb
jnunemaker-validatable-1.8.3 test/functional/test_validates_confirmation_of.rb
jnunemaker-validatable-1.8.2 test/functional/test_validates_confirmation_of.rb
jnunemaker-validatable-1.1.10 test/functional/test_validates_confirmation_of.rb
jnunemaker-validatable-1.1.9 test/functional/test_validates_confirmation_of.rb
durran-validatable-2.0.1 test/functional/test_validates_confirmation_of.rb
durran-validatable-2.0.0 test/functional/test_validates_confirmation_of.rb