Skip to content

Instantly share code, notes, and snippets.

@ebramanti
Last active February 18, 2016 21:51
Show Gist options
  • Save ebramanti/e124df98f520fa3fae8d to your computer and use it in GitHub Desktop.
Save ebramanti/e124df98f520fa3fae8d to your computer and use it in GitHub Desktop.
describe('GET potatoes', function() {
it('returns JSON with only authenticated robot\'s potatoes', function*() {
const glados = yield factory.create('robot');
const gladosPotatoes = [
yield factory.create('potato', { ownerId: glados.id });
yield factory.create('potato', { ownerId: glados.id });
];
const wheatley = yield factory.create('robot');
const wheatleyPotato =
yield factory.create('potato', { ownerId: wheatley.id });
const response = yield request.auth(glados).get('/potatoes');
const potatoesResponse = response.body.potatoes;
const returnedIds = _.pluck(potatoesResponse, 'id');
expect(returnedIds).to.include(_.pluck(gladosPotatoes, 'id'));
expect(returnedIds).not.to.include(wheatleyPotato.id);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment