Skip to content

Commit

Permalink
Merge branch 'claudiosdc-Fix'
Browse files Browse the repository at this point in the history
- Merges #147 from @claudiosdc
- Fixes #145
  • Loading branch information
Gregg Van Hove committed Dec 4, 2018
2 parents 6c7db63 + 7405df3 commit 791267b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
24 changes: 15 additions & 9 deletions lib/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ function Jasmine(options) {
}

Jasmine.prototype.randomizeTests = function(value) {
this.env.randomizeTests(value);
this.env.configure({random: value});
};

Jasmine.prototype.seed = function(value) {
this.env.seed(value);
this.env.configure({seed: value});
};

Jasmine.prototype.showColors = function(value) {
Expand Down Expand Up @@ -115,16 +115,22 @@ Jasmine.prototype.loadConfigFile = function(configFilePath) {
Jasmine.prototype.loadConfig = function(config) {
this.specDir = config.spec_dir || this.specDir;

var configuration = {};

if (config.stopSpecOnExpectationFailure !== undefined) {
this.env.throwOnExpectationFailure(config.stopSpecOnExpectationFailure);
configuration.oneFailurePerSpec = config.stopSpecOnExpectationFailure;
}

if (config.stopOnSpecFailure !== undefined) {
this.env.stopOnSpecFailure(config.stopOnSpecFailure);
configuration.failFast = config.stopOnSpecFailure;
}

if (config.random !== undefined) {
this.env.randomizeTests(config.random);
configuration.random = config.random;
}

if (Object.keys(configuration).length > 0) {
this.env.configure(configuration);
}

if(config.helpers) {
Expand Down Expand Up @@ -189,11 +195,11 @@ Jasmine.prototype.onComplete = function(onCompleteCallback) {
};

Jasmine.prototype.stopSpecOnExpectationFailure = function(value) {
this.env.throwOnExpectationFailure(value);
this.env.configure({oneFailurePerSpec: value});
};

Jasmine.prototype.stopOnSpecFailure = function(value) {
this.env.stopOnSpecFailure(value);
this.env.configure({failFast: value});
};

Jasmine.prototype.exitCodeCompletion = function(passed) {
Expand Down Expand Up @@ -237,9 +243,9 @@ Jasmine.prototype.execute = function(files, filterString) {
var specFilter = new ConsoleSpecFilter({
filterString: filterString
});
this.env.specFilter = function(spec) {
this.env.configure({specFilter: function(spec) {
return specFilter.matches(spec.getFullName());
};
}});
}

if (files && files.length > 0) {
Expand Down
24 changes: 11 additions & 13 deletions spec/jasmine_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ describe('Jasmine', function() {
addMatchers: jasmine.createSpy('addMatchers'),
provideFallbackReporter: jasmine.createSpy('provideFallbackReporter'),
execute: jasmine.createSpy('execute'),
throwOnExpectationFailure: jasmine.createSpy('throwOnExpectationFailure'),
stopOnSpecFailure: jasmine.createSpy('stopOnSpecFailure'),
randomizeTests: jasmine.createSpy('randomizeTests')
configure: jasmine.createSpy('configure')
}),
Timer: jasmine.createSpy('Timer')
};
Expand Down Expand Up @@ -191,39 +189,39 @@ describe('Jasmine', function() {
this.configObject.stopSpecOnExpectationFailure = true;
this.fixtureJasmine.loadConfig(this.configObject);

expect(this.fixtureJasmine.env.throwOnExpectationFailure).toHaveBeenCalledWith(true);
expect(this.fixtureJasmine.env.configure).toHaveBeenCalledWith({oneFailurePerSpec: true});
});

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

expect(this.fixtureJasmine.env.throwOnExpectationFailure).not.toHaveBeenCalled();
expect(this.fixtureJasmine.env.configure).not.toHaveBeenCalled();
});

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

expect(this.fixtureJasmine.env.stopOnSpecFailure).toHaveBeenCalledWith(true);
expect(this.fixtureJasmine.env.configure).toHaveBeenCalledWith({failFast: true});
});

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

expect(this.fixtureJasmine.env.stopOnSpecFailure).not.toHaveBeenCalled();
expect(this.fixtureJasmine.env.configure).not.toHaveBeenCalled();
});

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

expect(this.fixtureJasmine.env.randomizeTests).toHaveBeenCalledWith(true);
expect(this.fixtureJasmine.env.configure).toHaveBeenCalledWith({random: true});
});

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

expect(this.fixtureJasmine.env.randomizeTests).not.toHaveBeenCalled();
expect(this.fixtureJasmine.env.configure).not.toHaveBeenCalled();
});

describe('with options', function() {
Expand Down Expand Up @@ -296,21 +294,21 @@ describe('Jasmine', function() {
describe('#stopSpecOnExpectationFailure', function() {
it('sets the throwOnExpectationFailure value on the jasmine-core env', function() {
this.testJasmine.stopSpecOnExpectationFailure('foobar');
expect(this.testJasmine.env.throwOnExpectationFailure).toHaveBeenCalledWith('foobar');
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({oneFailurePerSpec: 'foobar'});
});
});

describe('#stopOnSpecFailure', function() {
it('sets the stopOnSpecFailure value on the jasmine-core env', function() {
this.testJasmine.stopOnSpecFailure('blah');
expect(this.testJasmine.env.stopOnSpecFailure).toHaveBeenCalledWith('blah');
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({failFast: 'blah'});
});
});

describe('#randomizeTests', function() {
it('sets the randomizeTests value on the jasmine-core env', function() {
this.testJasmine.randomizeTests('foobar');
expect(this.testJasmine.env.randomizeTests).toHaveBeenCalledWith('foobar');
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({random: 'foobar'});
});
});

Expand Down Expand Up @@ -401,7 +399,7 @@ describe('Jasmine', function() {
this.testJasmine.loadConfigFile();

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

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

0 comments on commit 791267b

Please sign in to comment.