Skip to content

Commit 791267b

Browse files
author
Gregg Van Hove
committed
Merge branch 'claudiosdc-Fix'
- Merges #147 from @claudiosdc - Fixes #145
2 parents 6c7db63 + 7405df3 commit 791267b

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

lib/jasmine.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ function Jasmine(options) {
3939
}
4040

4141
Jasmine.prototype.randomizeTests = function(value) {
42-
this.env.randomizeTests(value);
42+
this.env.configure({random: value});
4343
};
4444

4545
Jasmine.prototype.seed = function(value) {
46-
this.env.seed(value);
46+
this.env.configure({seed: value});
4747
};
4848

4949
Jasmine.prototype.showColors = function(value) {
@@ -115,16 +115,22 @@ Jasmine.prototype.loadConfigFile = function(configFilePath) {
115115
Jasmine.prototype.loadConfig = function(config) {
116116
this.specDir = config.spec_dir || this.specDir;
117117

118+
var configuration = {};
119+
118120
if (config.stopSpecOnExpectationFailure !== undefined) {
119-
this.env.throwOnExpectationFailure(config.stopSpecOnExpectationFailure);
121+
configuration.oneFailurePerSpec = config.stopSpecOnExpectationFailure;
120122
}
121123

122124
if (config.stopOnSpecFailure !== undefined) {
123-
this.env.stopOnSpecFailure(config.stopOnSpecFailure);
125+
configuration.failFast = config.stopOnSpecFailure;
124126
}
125127

126128
if (config.random !== undefined) {
127-
this.env.randomizeTests(config.random);
129+
configuration.random = config.random;
130+
}
131+
132+
if (Object.keys(configuration).length > 0) {
133+
this.env.configure(configuration);
128134
}
129135

130136
if(config.helpers) {
@@ -189,11 +195,11 @@ Jasmine.prototype.onComplete = function(onCompleteCallback) {
189195
};
190196

191197
Jasmine.prototype.stopSpecOnExpectationFailure = function(value) {
192-
this.env.throwOnExpectationFailure(value);
198+
this.env.configure({oneFailurePerSpec: value});
193199
};
194200

195201
Jasmine.prototype.stopOnSpecFailure = function(value) {
196-
this.env.stopOnSpecFailure(value);
202+
this.env.configure({failFast: value});
197203
};
198204

199205
Jasmine.prototype.exitCodeCompletion = function(passed) {
@@ -237,9 +243,9 @@ Jasmine.prototype.execute = function(files, filterString) {
237243
var specFilter = new ConsoleSpecFilter({
238244
filterString: filterString
239245
});
240-
this.env.specFilter = function(spec) {
246+
this.env.configure({specFilter: function(spec) {
241247
return specFilter.matches(spec.getFullName());
242-
};
248+
}});
243249
}
244250

245251
if (files && files.length > 0) {

spec/jasmine_spec.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ describe('Jasmine', function() {
1111
addMatchers: jasmine.createSpy('addMatchers'),
1212
provideFallbackReporter: jasmine.createSpy('provideFallbackReporter'),
1313
execute: jasmine.createSpy('execute'),
14-
throwOnExpectationFailure: jasmine.createSpy('throwOnExpectationFailure'),
15-
stopOnSpecFailure: jasmine.createSpy('stopOnSpecFailure'),
16-
randomizeTests: jasmine.createSpy('randomizeTests')
14+
configure: jasmine.createSpy('configure')
1715
}),
1816
Timer: jasmine.createSpy('Timer')
1917
};
@@ -191,39 +189,39 @@ describe('Jasmine', function() {
191189
this.configObject.stopSpecOnExpectationFailure = true;
192190
this.fixtureJasmine.loadConfig(this.configObject);
193191

194-
expect(this.fixtureJasmine.env.throwOnExpectationFailure).toHaveBeenCalledWith(true);
192+
expect(this.fixtureJasmine.env.configure).toHaveBeenCalledWith({oneFailurePerSpec: true});
195193
});
196194

197195
it('does not configure jasmine-core for stopping spec on expectation failure by default', function() {
198196
this.fixtureJasmine.loadConfig(this.configObject);
199197

200-
expect(this.fixtureJasmine.env.throwOnExpectationFailure).not.toHaveBeenCalled();
198+
expect(this.fixtureJasmine.env.configure).not.toHaveBeenCalled();
201199
});
202200

203201
it('can tell jasmine-core to stop execution when a spec fails', function() {
204202
this.configObject.stopOnSpecFailure = true;
205203
this.fixtureJasmine.loadConfig(this.configObject);
206204

207-
expect(this.fixtureJasmine.env.stopOnSpecFailure).toHaveBeenCalledWith(true);
205+
expect(this.fixtureJasmine.env.configure).toHaveBeenCalledWith({failFast: true});
208206
});
209207

210208
it('does not configure jasmine-core for stopping execution by default', function() {
211209
this.fixtureJasmine.loadConfig(this.configObject);
212210

213-
expect(this.fixtureJasmine.env.stopOnSpecFailure).not.toHaveBeenCalled();
211+
expect(this.fixtureJasmine.env.configure).not.toHaveBeenCalled();
214212
});
215213

216214
it('can tell jasmine-core to run random specs', function() {
217215
this.configObject.random = true;
218216
this.fixtureJasmine.loadConfig(this.configObject);
219217

220-
expect(this.fixtureJasmine.env.randomizeTests).toHaveBeenCalledWith(true);
218+
expect(this.fixtureJasmine.env.configure).toHaveBeenCalledWith({random: true});
221219
});
222220

223221
it('uses jasmine-core defaults if random is unspecified', function() {
224222
this.fixtureJasmine.loadConfig(this.configObject);
225223

226-
expect(this.fixtureJasmine.env.randomizeTests).not.toHaveBeenCalled();
224+
expect(this.fixtureJasmine.env.configure).not.toHaveBeenCalled();
227225
});
228226

229227
describe('with options', function() {
@@ -296,21 +294,21 @@ describe('Jasmine', function() {
296294
describe('#stopSpecOnExpectationFailure', function() {
297295
it('sets the throwOnExpectationFailure value on the jasmine-core env', function() {
298296
this.testJasmine.stopSpecOnExpectationFailure('foobar');
299-
expect(this.testJasmine.env.throwOnExpectationFailure).toHaveBeenCalledWith('foobar');
297+
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({oneFailurePerSpec: 'foobar'});
300298
});
301299
});
302300

303301
describe('#stopOnSpecFailure', function() {
304302
it('sets the stopOnSpecFailure value on the jasmine-core env', function() {
305303
this.testJasmine.stopOnSpecFailure('blah');
306-
expect(this.testJasmine.env.stopOnSpecFailure).toHaveBeenCalledWith('blah');
304+
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({failFast: 'blah'});
307305
});
308306
});
309307

310308
describe('#randomizeTests', function() {
311309
it('sets the randomizeTests value on the jasmine-core env', function() {
312310
this.testJasmine.randomizeTests('foobar');
313-
expect(this.testJasmine.env.randomizeTests).toHaveBeenCalledWith('foobar');
311+
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({random: 'foobar'});
314312
});
315313
});
316314

@@ -401,7 +399,7 @@ describe('Jasmine', function() {
401399
this.testJasmine.loadConfigFile();
402400

403401
this.testJasmine.execute(['spec/fixtures/**/*spec.js'], 'interesting spec');
404-
expect(this.testJasmine.env.specFilter).toEqual(jasmine.any(Function));
402+
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({specFilter: jasmine.any(Function)});
405403
});
406404

407405
it('adds an exit code reporter', function() {

0 commit comments

Comments
 (0)