Sha256: 592d392dd137ed273ae538e50d6b1b65b78f2ee131ca00c750ec6b8f864c5887

Contents?: true

Size: 967 Bytes

Versions: 1

Compression:

Stored size: 967 Bytes

Contents

require 'test_helper'

class ValidateFormatMatcherTest < Minitest::Test
  test 'raises ArgumentError when no option is given' do
    assert_raises(ArgumentError) { assert_must validate_format_of(:email), User}
  end

  test 'raises if to_allow and to_not_allow are used' do
    assert_raises RuntimeError do
      assert_must validate_format_of(:email).to_allow('').to_not_allow(''), User
    end
  end

  test 'must validate valid format of an attribute' do
    assert_must validate_format_of(:email).to_allow('foo@bar.com'), User
  end

  test 'must not validate valid format of an attribute' do
    assert_wont validate_format_of(:email).to_allow('foo_bar_com'), User
  end

  test 'must validate invalid format of an attribute' do
    assert_must validate_format_of(:email).to_not_allow('foo_bar_com'), User
  end

  test 'must not validate invalid format of an attribute' do
    assert_wont validate_format_of(:email).to_not_allow('foo@bar.com'), User
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
minitest-activemodel-1.1.0 test/cases/validate_format_matcher_test.rb