Skip to content

Commit

Permalink
Add Jasmine spec runner
Browse files Browse the repository at this point in the history
This allows the tests to be run by executing:

  npm test

Since Jasmine doesn't have an official npm package, I vendorized the
latest standalone version (1.3.1) [1] in the test directory.

[1]: https://github.com/pivotal/jasmine/downloads

Change-Id: I813be859eab9b05a6fab8efbcfe86960fdd7d8b2
Reviewed-on: https://gerrit.causes.com/23656
Tested-by: Joe Lencioni <[email protected]>
Reviewed-by: Adam Olsen <[email protected]>
  • Loading branch information
lencioni committed Jun 13, 2013
1 parent b21af0b commit 059517b
Show file tree
Hide file tree
Showing 8 changed files with 3,441 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
},
"bugs": "https://github.com/causes/method-proxy-js/issues",
"description": "Forwards method calls to an object.",
"devDependencies": {
"phantomjs": "1.9.x"
},
"license": "MIT",
"main": "method-proxy.js",
"name": "method-proxy-js",
"repository": {
"type": "git",
"url": "https://github.com/causes/method-proxy-js.git"
},
"scripts": {
"test": "phantomjs node_modules/phantomjs/lib/phantom/examples/run-jasmine.js test/SpecRunner.html"
},
"version": "1.0.0"
}
48 changes: 48 additions & 0 deletions test/SpecRunner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE HTML>
<html>
<head>
<title>method-proxy-js Test Suite</title>

<link rel="stylesheet" type="text/css" href="vendor/jasmine/jasmine.css">
<script src="vendor/jasmine/jasmine.js"></script>
<script src="vendor/jasmine/jasmine-html.js"></script>

<!-- include source files here... -->
<script src="../method-proxy.js"></script>

<!-- include spec files here... -->
<script src="method-proxy.js"></script>

<script>
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;

var htmlReporter = new jasmine.HtmlReporter();

jasmineEnv.addReporter(htmlReporter);

jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};

var currentWindowOnload = window.onload;

window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};

function execJasmine() {
jasmineEnv.execute();
}

})();
</script>
</head>

<body>
</body>
</html>
6 changes: 3 additions & 3 deletions test/method-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ describe('MethodProxy', function() {
};
});

context('after initialization', function() {
describe('after initialization', function() {
beforeEach(function() {
FBMethodProxy = new MethodProxy(FB, []);
});

context('when pushed to', function() {
describe('when pushed to', function() {
it('calls the pushed methods with the correct arguments', function() {
spyOn(FB, 'aMethod');
FBMethodProxy.push(['aMethod', 'this is a string', 2]);
Expand All @@ -36,7 +36,7 @@ describe('MethodProxy', function() {
});
});

context('with an existing queue', function() {
describe('with an existing queue', function() {
var queue = [
['aMethod', 'my argument'],
['anObject.anotherMethod', 'my other argument', 'one more']
Expand Down
20 changes: 20 additions & 0 deletions test/vendor/jasmine/MIT.LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2008-2011 Pivotal Labs

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit 059517b

Please sign in to comment.