<commit_before>var chai = require('chai'),
    expect = chai.expect,
    chaiAsPromised = require('chai-as-promised'),
    acid = require('../lib/acid')({
      host: 'localhost',
      user: 'postgres',
      password: '',
      database: 'acidjs',
      port: 5432
    }),
    Model = require('../lib/model');

chai.use(chaiAsPromised);

describe('Model', function() {
  describe('.new', function() {
    it('should return an instance of a model', function() {
      var User = acid.Model('users', ['id', 'email']);
      var user = new User({email: '<EMAIL>'});
      expect(user).to.be.an.instanceof(Model);
    });

    it('should create properties', function() {
      var User = acid.Model('users', ['id', 'email']);
      var user = new User({email: '<EMAIL>'});
      expect(user.email).to.equal('<EMAIL>');
    });

    it('should throw an error when given an incorrect input', function() {
      var User = acid.Model('users', ['id', 'email']);
      var fn = function() { new User(); };
      expect(fn).to.throw('Cannot build a record for table users without an object');
    });
  });

  describe('#save', function() {
    beforeEach(function() {
      return acid.Query('drop table users;').then(function() {
        return acid.Query('create table users (id serial primary key, email text not null);');
      });
    });

    it('should save a record to the database', function() {
      var User = acid.Model('users', ['id', 'email']);
      var user = new User({email: '<EMAIL>'});
      return expect(user.save()).to.eventually.include.keys('id');<commit_msg>Get tests passing on travis<commit_after>var chai = require('chai'),
    expect = chai.expect,
    chaiAsPromised = require('chai-as-promised'),
    acid = require('../lib/acid')({
      host: 'localhost',
      user: 'postgres',
      password: '',
      database: 'acidjs',
      port: 5432
    }),
    Model = require('../lib/model');

chai.use(chaiAsPromised);

describe('Model', function() {
  describe('.new', function() {
    it('should return an instance of a model', function() {
      var User = acid.Model('users', ['id', 'email']);
      var user = new User({email: '<EMAIL>'});
      expect(user).to.be.an.instanceof(Model);
    });

    it('should create properties', function() {
      var User = acid.Model('users', ['id', 'email']);
      var user = new User({email: '<EMAIL>'});
      expect(user.email).to.equal('<EMAIL>');
    });

    it('should throw an error when given an incorrect input', function() {
      var User = acid.Model('users', ['id', 'email']);
      var fn = function() { new User(); };
      expect(fn).to.throw('Cannot build a record for table users without an object');
    });
  });

  describe('#save', function() {
    before(function() {
      return acid.Query('create table users (id serial primary key, email text not null);');
    });

    after(function() {
      return acid.Query('drop table users;');
    })

    it('should save a record to the database', function() {
      var User = acid.Model('users', ['id', 'email']);
      var user = new User({email: '<EMAIL>'});
      return expect(user.save()).to.eventually.include.keys('id');
{'fraction_non_alphanumeric': 0.19223484848484848, 'fraction_numerical': 0.0025252525252525255, 'mean_word_length': 3.104922279792746, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1831154', 'n_tokens_mistral': 960, 'n_tokens_neox': 940, 'n_words': 260}