describe('Records', function () {
  helpers.testRequest(
    'when you get a record',
    function () { return client.get('people', 1) },
    function (call) {
      it('should return the record', function () {
        return expect(helpers.removeUrl(call.response)).eventually.deep.equal({
          "id":1,
          "name":"Paul Jacobs",
          "role":"Group Manager",
          "phone":"573-356-3327",
          "tasks":[{"id":3, "summary":"Finalize next iteration of test plan"}, {"id":10, "summary":"Publish industry analysis"}]
        });
      })
    }
  )

  helpers.testRequest(
    'when you get a record with options',
    function () { return client.get('people', 1, {include: 'role', exclude: 'id,record_url'}) },
    function (call) {
      it('should return the record', function () {
        return expect(call.response).eventually.deep.equal({role:"Group Manager"});
      })
    }
  );

  helpers.testRequest(
    'when you create a record',
    function () { return client.create('people', {name: 'Ben B', role: 'Engineer'}) },
    function (call) {
      it('should return the record', function () {
        var response = call.response.then(function (data) {
          return _.omit(data, 'id', 'record_url');
        })
        return expect(response).eventually.deep.equal({
          name: 'Ben B',
          role: 'Engineer',
          phone: null,
          tasks: []
        });
      })

      var needsDelete = true;
      describe('when you get the response', function () {
        var id;
        before(function () {
          return call.response.then(function (data) { id = data.id })
        })

        helpers.testRequest(
          'when you update a record',
          function () { return client.update('people', id, {phone: '510-867-5309'}) },
          function (call) {
            it('should return the modified record', function () {
              var response = call.response.then(function (data) {
                return _.omit(data, 'id', 'record_url');
              })

              return expect(response).eventually.deep.equal({
                name: 'Ben B',
                role: 'Engineer',
                phone: '510-867-5309',
                tasks: []
              });
            })
          }
        )

        helpers.testRequest(
          'when you delete a record',
          function () {
            needsDelete = false;
            return client.destroy('people', id)
          },
          function (call) {
            it('should complete successfully', function () {
              return expect(call.response).eventually.equal('ok');
            })
          }
        )
      })

      after(function () {
        // Cleanup if we haven't already run the delete
        if (needsDelete) {
          return call.response.then(function (data) {
            return client.destroy('people', data.id);
          })
        }
      })
    }
  )

  helpers.testRequest(
    'when you request a record and get an error',
    function () { return client.get('people', 99) },
    function (call) {
      it('should throw an error', function () {
        return expect(call.response).eventually.rejectedWith(/Record id not found/)
      })
    }
  )
});

@@ -2266,16 +2266,636 @@
      )%0A%0A
+        helpers.testRequest(%0A          'when you update a record with unicode characters',%0A          function () %7B return client.update('people', id, %7Brole: '%D9%85%D9%87%D9%86%D8%AF%D8%B3'%7D) %7D,%0A          function (call) %7B%0A            it('should return the modified record', function () %7B%0A              var response = call.response.then(function (data) %7B%0A                return _.omit(data, 'id', 'record_url', 'phone');%0A              %7D)%0A%0A              return expect(response).eventually.deep.equal(%7B%0A                name: 'Ben B',%0A                role: '%D9%85%D9%87%D9%86%D8%AF%D8%B3',%0A                tasks: %5B%5D%0A              %7D);%0A            %7D)%0A          %7D%0A        )%0A%0A
         

Test unicode requests