Sha256: 3c1d07891f54ec289693ab2b6f8bd248e914ae4dccd70f9e2fc3c72b65e9e668

Contents?: true

Size: 1.08 KB

Versions: 58

Compression:

Stored size: 1.08 KB

Contents

root = exports ? window

require 'indemma/lib/record/validatable'

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

58 entries across 58 versions & 1 rubygems

Version Path
ende-0.3.1 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.3.0 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.21 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.20 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.19 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.18 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.17 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.16 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.15 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.14 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.13 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.12 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.11 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.10 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.3 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.2 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.1 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee
ende-0.2.0 vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee