Sha256: 876afb1780d3fde8c20f84b5afa21fecfb0f55de7cbf0aee5382b6bd9a150d11

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

root = exports ? window

require 'indemma/lib/record/validatable.js'

describe 'model #() validates type of',  ->

  describe 'basic usage', ->
    model  = root.model
    person = null

    beforeEach ->
      person = model.call
        resource  : 'person'
        name      : String
        phone     : Phone
        validates_type_of: ['name', 'phone']

    afterEach ->
      person.validators.length = 0

    describe '#validate', ->

      #it 'should use Phone#valid getter to find out if object is valid'
      it 'should use Phone#validate to find out if attribute is valid'
      it 'should add error to record when phone typed attribute has an non valid phone value', ->
        arthur = person phone: new Phone 'batata'
        arthur.valid.should.be.false
        arthur.errors.messages.should.have.property 'phone'
        expect(arthur.errors.messages.phone).to.match /não está válido/

      it 'should throw error to when phone typed attribute has an non phone value', ->
        arthur = person phone: 'batata'
        expect( -> arthur.valid).to.throw /invalid attribute value type/i

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ende-0.5.22 components/indefinido/indemma/master/src/spec/record/validations/type_spec.coffee
ende-0.5.21 components/indefinido/indemma/master/src/spec/record/validations/type_spec.coffee