Sha256: c3d118470933768dd20a8310819a11251403a87c0e9ec1d7b6988e849eda4065

Contents?: true

Size: 1.4 KB

Versions: 58

Compression:

Stored size: 1.4 KB

Contents

var root;

root = typeof exports !== "undefined" && exports !== null ? exports : window;

require('indemma/lib/record/validatable');

describe('model #() validates type of', function() {
  return describe('basic usage', function() {
    var model, person;

    model = root.model;
    person = null;
    beforeEach(function() {
      return person = model.call({
        resource: 'person',
        name: String,
        phone: Phone,
        validates_type_of: ['name', 'phone']
      });
    });
    afterEach(function() {
      return person.validators.length = 0;
    });
    return describe('#validate', function() {
      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', function() {
        var arthur;

        arthur = person({
          phone: new Phone('batata')
        });
        arthur.valid.should.be["false"];
        arthur.errors.messages.should.have.property('phone');
        return expect(arthur.errors.messages.phone).to.match(/não está válido/);
      });
      return it('should throw error to when phone typed attribute has an non phone value', function() {
        var arthur;

        arthur = person({
          phone: 'batata'
        });
        return expect(function() {
          return arthur.valid;
        }).to["throw"](/invalid attribute value type/i);
      });
    });
  });
});

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
ende-0.4.25 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.4.24 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.4.23 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.5.1 components/indefinido/indemma/master/spec/record/validations/type_spec.js
ende-0.4.22 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.4.21 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.5.0 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.4.20 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.4.19 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.4.18 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.4.17 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.4.16 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.3.13 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.3.12 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.3.11 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.4.15 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.4.14 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.4.13 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.4.12 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js
ende-0.4.11 vendor/components/indefinido-indemma/spec/record/validations/type_spec.js