Sha256: 13c44ad9793a4b0b9c59a6751ccfa8aad6bdcf0bc9cb7d14a0be222cab517e99

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require 'test_helper'

class AboveLengthValidationsTest < Test::Unit::TestCase
  def setup
    Android.auto_length_validation

    @android = Android.new :name => 'A Very big name indeed',
                           :description => 'Fuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu',
                           :number => 115
  end

  def test_should_add_errors_to_the_name_field
    assert @android.invalid?
    assert_not_nil @android.errors[:name]
  end

  def test_should_add_errors_to_the_descriptiom_field
    assert @android.invalid?
    assert_not_nil @android.errors[:description]
  end

  def test_should_add_errors_to_the_number_field
    assert @android.invalid?
    assert_not_nil @android.errors[:number]
  end
end

class BelowLengthValidationsTest < Test::Unit::TestCase
  def setup
    Android.auto_length_validation

    @android = Android.new :name => 'Android',
                           :description => 'DBZ character',
                           :number => 16
  end

  def test_should_be_valid
    assert @android.valid?
  end
end

class AllowBlankTest < Test::Unit::TestCase
  def setup
    Android.auto_length_validation
    @android = Android.new :name => nil
  end

  def test_should_not_throw_errors
    assert_nothing_thrown { @android.valid? }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auto_validations-0.0.2 test/auto_length_test.rb