<commit_before>describe('http!', function () {

    var Collection, RelationshipType, Pouch, RestObject, ResponseDescriptor, DescriptorRegistry, RequestDescriptor, Serialiser;
    var collection, carMapping, personMapping, vitalSignsMapping;

    var $rootScope;
    var server;

    beforeEach(function () {
        module('restkit.mapping', function ($provide) {
            $provide.value('$log', console);
            $provide.value('$q', Q);
        });
        module('restkit.relationship', function ($provide) {
            $provide.value('$log', console);
            $provide.value('$q', Q);
        });

        inject(function (_Collection_, _Serialiser_, _RelationshipType_, _Pouch_, _$rootScope_, _RestObject_, _ResponseDescriptor_, _RequestDescriptor_, _DescriptorRegistry_) {
            $rootScope = _$rootScope_;
            Collection = _Collection_;
            RelationshipType = _RelationshipType_;
            Pouch = _Pouch_;
            RestObject = _RestObject_;
            ResponseDescriptor = _ResponseDescriptor_;
            RequestDescriptor = _RequestDescriptor_;
            DescriptorRegistry = _DescriptorRegistry_;
            Serialiser = _Serialiser_;
        });

        server = sinon.fakeServer.create();

        Pouch.reset();

    });

    function configureCollection(configureDescriptors, callback) {
        var configuration = function (err, version) {
            if (err) callback(err);
            personMapping = collection.registerMapping('Person', {
                id: 'id',
                attributes: ['name', 'age']
            });
            carMapping = collection.registerMapping('Car', {
                id: 'id',
                attributes: ['colour', 'name'],
                relationships: {
                    owner: {
                        mapping: 'Person',
                        type: RelationshipType.ForeignKey,
                        reverse: 'cars'
                    }
                }
            });
            vitalSignsMapping = collection.registerMapping('VitalSigns', {
                id: 'id',
                attributes: ['heartRate', 'bloodPressure'],
                relationships: {
                    owner: {
                        mapping: 'Person',
                        type: RelationshipType.OneToOne,
                        reverse: 'vitalSigns'
                    }
                }
            });
            collection.baseURL = 'http://mywebsite.co.uk/';
            configureDescriptors();
        };
        collection = new Collection('myCollection', configuration, callback);
    }

    afterEach(function () {
        // Restore original server implementation.
        server.restore();
    });


    describe('path regex', function () {


        describe('check', function () {

            beforeEach(function (done) {
                var configureDescriptors = function () {
                    DescriptorRegistry.registerResponseDescriptor(new ResponseDescriptor({
                        method: 'GET',
                        mapping: carMapping,
                        path: '/cars/(?<id>[0-9])/(?<colour>[a-zA-Z0-9]+)/?'
                    }));
                    DescriptorRegistry.registerResponseDescriptor(new ResponseDescriptor({
                        method: 'GET',
                        mapping: carMapping,
                        path: '/cars/(?<colour>[a-zA-Z0-9]+)/?'
                    }));
                };
                configureCollection(configureDescriptors, done);
            });

            describe('singular', function () {
                var err, obj, resp;

                beforeEach(function (done) {
                    var raw = {colour: 'red', name: '<NAME>', owner: '093hodhfno', id: '5'};
                    var headers = { "Content-Type": "application/json" };
                    var path = "http://mywebsite.co.uk/cars/9/purple/";
                    var method = "GET";
                    var status = 200;
                    server.respondWith(method, path, [status, headers, JSON.stringify(raw)]);
                    collection.GET('cars/9/purple/', function (_err, _obj, _resp) {
                        err = _err;
                        obj = _obj;
                        resp = _resp;
                        done();
                    });
                    server.respond();
                });

                it('should map regex matches onto the object', function () {
                    assert.instanceOf(obj, RestObject);
                    assert.equal(obj.colour, 'purple');
                    assert.equal(obj.name, '<NAME>');
                    assert.equal(obj.id, '9');
                });
            });

            describe.only('multiple', function () {
                var err, objs, resp;

                beforeEach(function (done) {
                    var raw = [
                        {colour: 'red', name: '<NAME>', owner: '093hodhfno', id: '5'},
                        {colour: 'green', name: '<NAME>', owner: '093hodhfno', id: '2'},
                        {colour: 'orange', name: '<NAME>', owner: '093hodhfno', id: '1'}
                    ];
                    var headers = { "Content-Type": "application/json" };
                    var path = "http://mywebsite.co.uk/cars/purple/";
                    var method = "GET";
                    var status = 200;
                    server.respondWith(method, path, [status, headers, JSON.stringify(raw)]);
                    collection.GET('cars/purple/', function (_err, _objs, _resp) {
                        err = _err;
                        objs = _objs;
                        resp = _resp;
                        done();
                    });
                    server.respond();
                });

                it('should map regex matches onto the object', function () {
                    assert.notOk(err);
                    assert.ok(objs.length);
                    _.each(objs, function (obj) {
                        assert.equal(obj.colour, 'purple');
                        assert.equal(obj.name, '<NAME>');
                    });

                });<commit_msg>Variables in path of descriptor with arrays<commit_after>describe('http!', function () {

    var Collection, RelationshipType, Pouch, RestObject, ResponseDescriptor, DescriptorRegistry, RequestDescriptor, Serialiser;
    var collection, carMapping, personMapping, vitalSignsMapping;

    var $rootScope;
    var server;

    beforeEach(function () {
        module('restkit.mapping', function ($provide) {
            $provide.value('$log', console);
            $provide.value('$q', Q);
        });
        module('restkit.relationship', function ($provide) {
            $provide.value('$log', console);
            $provide.value('$q', Q);
        });

        inject(function (_Collection_, _Serialiser_, _RelationshipType_, _Pouch_, _$rootScope_, _RestObject_, _ResponseDescriptor_, _RequestDescriptor_, _DescriptorRegistry_) {
            $rootScope = _$rootScope_;
            Collection = _Collection_;
            RelationshipType = _RelationshipType_;
            Pouch = _Pouch_;
            RestObject = _RestObject_;
            ResponseDescriptor = _ResponseDescriptor_;
            RequestDescriptor = _RequestDescriptor_;
            DescriptorRegistry = _DescriptorRegistry_;
            Serialiser = _Serialiser_;
        });

        server = sinon.fakeServer.create();

        Pouch.reset();

    });

    function configureCollection(configureDescriptors, callback) {
        var configuration = function (err, version) {
            if (err) callback(err);
            personMapping = collection.registerMapping('Person', {
                id: 'id',
                attributes: ['name', 'age']
            });
            carMapping = collection.registerMapping('Car', {
                id: 'id',
                attributes: ['colour', 'name'],
                relationships: {
                    owner: {
                        mapping: 'Person',
                        type: RelationshipType.ForeignKey,
                        reverse: 'cars'
                    }
                }
            });
            vitalSignsMapping = collection.registerMapping('VitalSigns', {
                id: 'id',
                attributes: ['heartRate', 'bloodPressure'],
                relationships: {
                    owner: {
                        mapping: 'Person',
                        type: RelationshipType.OneToOne,
                        reverse: 'vitalSigns'
                    }
                }
            });
            collection.baseURL = 'http://mywebsite.co.uk/';
            configureDescriptors();
        };
        collection = new Collection('myCollection', configuration, callback);
    }

    afterEach(function () {
        // Restore original server implementation.
        server.restore();
    });


    describe('path regex', function () {


        describe('check', function () {

            beforeEach(function (done) {
                var configureDescriptors = function () {
                    DescriptorRegistry.registerResponseDescriptor(new ResponseDescriptor({
                        method: 'GET',
                        mapping: carMapping,
                        path: '/cars/(?<id>[0-9])/(?<colour>[a-zA-Z0-9]+)/?'
                    }));
                    DescriptorRegistry.registerResponseDescriptor(new ResponseDescriptor({
                        method: 'GET',
                        mapping: carMapping,
                        path: '/cars/(?<colour>[a-zA-Z0-9]+)/?'
                    }));
                };
                configureCollection(configureDescriptors, done);
            });

            describe('singular', function () {
                var err, obj, resp;

                beforeEach(function (done) {
                    var raw = {colour: 'red', name: '<NAME>', owner: '093hodhfno', id: '5'};
                    var headers = { "Content-Type": "application/json" };
                    var path = "http://mywebsite.co.uk/cars/9/purple/";
                    var method = "GET";
                    var status = 200;
                    server.respondWith(method, path, [status, headers, JSON.stringify(raw)]);
                    collection.GET('cars/9/purple/', function (_err, _obj, _resp) {
                        err = _err;
                        obj = _obj;
                        resp = _resp;
                        done();
                    });
                    server.respond();
                });

                it('should map regex matches onto the object', function () {
                    assert.instanceOf(obj, RestObject);
                    assert.equal(obj.colour, 'purple');
                    assert.equal(obj.name, '<NAME>');
                    assert.equal(obj.id, '9');
                });
            });

            describe('multiple', function () {
                var err, objs, resp;

                beforeEach(function (done) {
                    var raw = [
                        {colour: 'red', name: '<NAME>', owner: '093hodhfno', id: '5'},
                        {colour: 'green', name: '<NAME>', owner: '093hodhfno', id: '2'},
                        {colour: 'orange', name: '<NAME>', owner: '093hodhfno', id: '1'}
                    ];
                    var headers = { "Content-Type": "application/json" };
                    var path = "http://mywebsite.co.uk/cars/purple/";
                    var method = "GET";
                    var status = 200;
                    server.respondWith(method, path, [status, headers, JSON.stringify(raw)]);
                    collection.GET('cars/purple/', function (_err, _objs, _resp) {
                        err = _err;
                        objs = _objs;
                        resp = _resp;
                        done();
                    });
                    server.respond();
                });

                it('should map regex matches onto the object', function () {
                    assert.notOk(err);
                    assert.ok(objs.length);
                    _.each(objs, function (obj) {
                        assert.equal(obj.colour, 'purple');
                        assert.equal(obj.name, '<NAME>');
                    });

                });
{'fraction_non_alphanumeric': 0.12047123376099411, 'fraction_numerical': 0.005002824174937465, 'mean_word_length': 1.3244561140285072, 'pattern_counts': {'":': 4, '<': 21, '<?xml version=': 0, '>': 21, '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': '5871754', 'n_tokens_mistral': 3107, 'n_tokens_neox': 2814, 'n_words': 612}