Skip to content

Commit

Permalink
feat: update to Jasmine 2.0
Browse files Browse the repository at this point in the history
This does not support iit/ddescribe yet.

Vojta: this is squashed and slightly refactored #18.
  • Loading branch information
r-park authored and vojtajina committed Feb 15, 2014
1 parent 57dddee commit 4e0b48a
Show file tree
Hide file tree
Showing 8 changed files with 2,310 additions and 2,445 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea/
node_modules/
tmp/
lib/adapter.js
node_modules
1 change: 1 addition & 0 deletions karma-v0.8.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
files = [
JASMINE,
JASMINE_ADAPTER,
'lib/jasmine.js',
'src/*.js',
'test/*.js'
];
Expand Down
1 change: 1 addition & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = function(config) {
config.set({
frameworks: ['jasmine'],
files: [
'lib/jasmine.js',
'src/*.js',
'test/*.js'
],
Expand Down
106 changes: 106 additions & 0 deletions lib/boot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* Jasmine 2.0 standalone `boot.js` modified for Karma.
* This file is registered in `index.js`. This version
* does not include `HtmlReporter` setup.
*/
(function(){

/**
* Require Jasmine's core files. Specifically, this requires and
* attaches all of Jasmine's code to the `jasmine` reference.
*/
window.jasmine = jasmineRequire.core(jasmineRequire);


/**
* Create the Jasmine environment. This is used to run all specs
* in a project.
*/
var env = jasmine.getEnv();


/**
* Build up the functions that will be exposed as the Jasmine
* public interface.
*/
var jasmineInterface = {
describe: function(description, specDefinitions) {
return env.describe(description, specDefinitions);
},

xdescribe: function(description, specDefinitions) {
return env.xdescribe(description, specDefinitions);
},

it: function(desc, func) {
return env.it(desc, func);
},

xit: function(desc, func) {
return env.xit(desc, func);
},

beforeEach: function(beforeEachFunction) {
return env.beforeEach(beforeEachFunction);
},

afterEach: function(afterEachFunction) {
return env.afterEach(afterEachFunction);
},

expect: function(actual) {
return env.expect(actual);
},

pending: function() {
return env.pending();
},

spyOn: function(obj, methodName) {
return env.spyOn(obj, methodName);
},

jsApiReporter: new jasmine.JsApiReporter({
timer: new jasmine.Timer()
})
};


/**
* Add all of the Jasmine global/public interface to the proper
* global, so a project can use the public interface directly.
* For example, calling `describe` in specs instead of
* `jasmine.getEnv().describe`.
*/
for (var property in jasmineInterface) {
if (jasmineInterface.hasOwnProperty(property)) {
window[property] = jasmineInterface[property];
}
}


/**
* Expose the interface for adding custom equality testers.
*/
jasmine.addCustomEqualityTester = function(tester) {
env.addCustomEqualityTester(tester);
};


/**
* Expose the interface for adding custom expectation matchers
*/
jasmine.addMatchers = function(matchers) {
return env.addMatchers(matchers);
};


/**
* Expose the mock interface for the JavaScript timeout functions
*/
jasmine.clock = function() {
return env.clock;
};


})();
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var createPattern = function(path) {

var initJasmine = function(files) {
files.unshift(createPattern(__dirname + '/adapter.js'));
files.unshift(createPattern(__dirname + '/boot.js'));
files.unshift(createPattern(__dirname + '/jasmine.js'));
};

Expand Down
Loading

0 comments on commit 4e0b48a

Please sign in to comment.