Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit a85e7e6

Browse files
clark0xMiroslav Bajtoš
authored andcommitted
Fix handling of dynamic URLs in the test builder
Fix the test builder to call the URL factory function before each test. Before this change, the URL produced by the first test was used, which caused problems in tests that were creating new entities before each test, e.g. `lt.describe.whenCalledByUser`.
1 parent 26e573f commit a85e7e6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ _describe.whenCalledRemotely = function(verb, url, data, cb) {
156156
describe(verb.toUpperCase() + ' ' + urlStr, function() {
157157
beforeEach(function(cb) {
158158
if(typeof url === 'function') {
159-
url = url.call(this);
159+
this.url = url.call(this);
160160
}
161161
this.remotely = true;
162162
this.verb = verb.toUpperCase();

test/test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,18 @@ describe('helpers', function () {
7272
});
7373
});
7474
});
75+
helpers.describe.staticMethod('findById', function() {
76+
helpers.beforeEach.givenModel('xxx-test-model', {foo: 'bar'});
77+
helpers.describe.whenCalledRemotely('GET', function () {
78+
return '/xxx-test-models/' + this['xxx-test-model'].id;
79+
}, function() {
80+
it('should retrieve the expected model in the first test', function () {
81+
assert.equal(this.res.body.id, this['xxx-test-model'].id);
82+
});
83+
it('should retrieve the expected model in subsequent tests', function () {
84+
assert.equal(this.res.body.id, this['xxx-test-model'].id);
85+
});
86+
});
87+
});
7588
});
7689
});

0 commit comments

Comments
 (0)