Sha256: 5593bd85517d096dbd7d91cdbcc15b6ff1f2ed095d1fdac52bdfbcf3b7f30591

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require "test_helper"

describe Mongoid::Matchers::Validations do
  subject { Person }

  it { must validate_presence_of(:name) }
  it { wont validate_presence_of(:age) }

  it { must validate_uniqueness_of(:login).case_insensitive }
  it { wont validate_uniqueness_of(:email).case_insensitive }

  it { must validate_length_of(:password).with_min(8) }
  it { wont validate_length_of(:password).with_min(0) }
  it { must validate_length_of(:password).with_minimum(8) }
  it { wont validate_length_of(:password).with_minimum(0) }
  it { must validate_length_of(:password).with_max(16) }
  it { wont validate_length_of(:password).with_max(8) }
  it { must validate_length_of(:password).with_maximum(16) }
  it { wont validate_length_of(:password).with_maximum(8) }

  it { must validate_format_of(:email).to_allow("foo@bar.com") }
  it { wont validate_format_of(:email).to_allow("foo_bar_com") }
  it { must validate_format_of(:email).to_not_allow("foo_bar_com") }
  it { wont validate_format_of(:email).to_not_allow("foo@bar.com") }

  it { must validate_exclusion_of(:email).to_not_allow("foo@bar.com") }
  it { must validate_exclusion_of(:email).to_not_allow("foo@bar.com", "fizz@buzz.com") }
  it { wont validate_exclusion_of(:email).to_not_allow("foo_bar.com") }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-minitest-0.0.1 test/matchers/validations_test.rb