MINOR Added jasmine-jstd-adapter dependency

This commit is contained in:
Ingo Schommer 2011-03-10 10:28:47 +13:00
parent 4591503da6
commit fb502d7fc8
8 changed files with 324 additions and 0 deletions

View File

@ -0,0 +1,8 @@
---
format: 1
handler:
commit: 9113b5e33765d4ccc7cfbbebe29b52d38c296b76
branch: master
lock: false
repository_class: Piston::Git::Repository
repository_url: git://github.com/ibolmo/jasmine-jstd-adapter.git

View File

@ -0,0 +1,23 @@
Copyright (c) 2010
Misko Hevery <misko@hevery.com>
Olmo Maldonado <me@ibolmo.com>
Christoph Pojer <christoph.pojer@gmail.com>
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.

View File

@ -0,0 +1,62 @@
Jasmine Adapter for [JsTestDriver][jstd]
========================================
Author
------
* Olmo Maldonado (me@ibolmo.com)
* Misko Hevery (misko@hevery.com)
* Christoph Pojer (christoph.pojer@gmail.com)
Requirements
------------
- [JsTestDriver (JSTD)][jstd]
- [Jasmine][jasmine]
Usage
-----
Create, or update, a `jstestdriver.conf` file (see [wiki page][jstd-conf] for more info).
Update your `jstestdriver.conf` by prepending the jasmine library and the adapter's source files.
For example:
load:
- "../jasmine/lib/jasmine-0.10.0.js"
- "../JasmineAdapter/src/*"
- "your_source_files.js"
- "your_test_files.js"
Copy `server.sh` and `test.sh` (included) to your working directory, for convenience.
# copy
cp /path/to/jasmine-jstestdriver-adapter/*.sh ./
First: run `server.sh` and supply `-p`, for port, and `-j`, path to `jstestdriver.jar` or follow the convention defined in the `.sh` scripts (see Caveats below).
Open up [http://localhost:9876/capture](http://localhost:9876/capture) (update for your port) in any browser.
Finally: run `test.sh` to test all tests (specs) included with the `jstestdriver.conf`. Optionally pass a `-j` and `-t` arguments to `test.sh` to set the path to `jstestdriver.jar` and any test you'd only like to run, respectively.
Directory Layout
----------------
- src: The adapter source code. Intent is to match interface with interface.
- src-test: The test files that verifies that the adapter works as intended.
Caveats
-------
### jsTestDriver.conf and *.sh files
The files located in this repo assume that the parent folder has the jasmine source and a jstestdriver compiled available.
Update the paths, or pass arguments (as explained above), to reflect your own layout if you'd like to test the adapter.
[jstd]: http://code.google.com/p/js-test-driver
[jstd-conf]: http://code.google.com/p/js-test-driver/wiki/ConfigurationFile
[jasmine]: http://github.com/pivotal/jasmine

View File

@ -0,0 +1,6 @@
server: http://localhost:9876
load:
- "../jasmine/lib/jasmine.js"
- "src/JasmineAdapter.js"
- "src-test/tests.js"

19
thirdparty/jasmine-jstd-adapter/server.sh vendored Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
while getopts "j:p:" flag
do
if [ $flag == "j" ]; then
JSTD=$OPTARG
elif [ $flag == "p" ]; then
PORT=$OPTARG
fi
done
if [ -z "$PORT" ]; then
PORT=9876
fi
if [ -z "$JSTD" ]; then
JSTD=`ls ../jstestdriver/[jJ]s[tT]est[dD]river*.jar`
fi
java -jar $JSTD --port $PORT --runnerMode DEBUG

View File

@ -0,0 +1,91 @@
(function(){
var depth;
beforeEach(function(){
depth = 1;
});
afterEach(function(){
expect(depth).toEqual(1);
});
describe('describe', function(){
beforeEach(function(){
depth++;
});
afterEach(function(){
depth--;
});
it('should map it', function(){
expect(depth).toEqual(2);
});
describe('nested', function(){
beforeEach(function(){
depth++;
});
afterEach(function(){
depth--;
});
it('should exectue nested', function(){
expect(depth).toEqual(3);
});
});
});
describe("matchers", function(){
beforeEach(function(){
this.addMatchers({
toBePersonNamed: function(name){
return this.actual == name;
}
});
});
it('should work across multiple tests', function(){
expect('misko').toBePersonNamed('misko');
});
it('should allow a creation of new matcher', function(){
this.addMatchers({
toBeMe: function(){
return this.actual == 'misko';
}
});
this.addMatchers({
toBeMe2: function(arg){
return this.actual == arg;
}
});
expect('misko').toBeMe();
expect('misko').toBeMe2('misko');
expect('adam').toBePersonNamed('adam');
});
});
describe('runs', function(){
it('should execute a runs block', function(){
runs(function(){
this.runsFunction = function(){
return true;
};
spyOn(this, 'runsFunction');
});
runs(function(){
this.runsFunction();
});
runs(function(){
expect(this.runsFunction).wasCalled();
});
});
});
})();

View File

@ -0,0 +1,93 @@
/**
* @fileoverview Jasmine JsTestDriver Adapter.
* @author ibolmo@gmail.com (Olmo Maldonado)
* @author misko@hevery.com (Misko Hevery)
*/
(function(describe, it, beforeEach, afterEach, addResult){
var frame = function(parent, name){
var caseName = '';
if (parent && parent.caseName) caseName = parent.caseName + ' ';
if (name) caseName += name;
var before = [],
after = [];
return {
name: name,
caseName: caseName,
parent: parent,
testCase: TestCase(caseName),
before: before,
after: after,
runBefore: function(){
if (parent) parent.runBefore.apply(this);
for (var i = 0, l = before.length; i < l; i++) before[i].apply(this);
},
runAfter: function(){
for (var i = 0, l = after.length; i < l; i++) after[i].apply(this);
if (parent) parent.runAfter.apply(this);
}
};
};
var currentFrame = frame(null, null);
jasmine.Env.prototype.describe = function(description, context){
currentFrame = frame(currentFrame, description);
var result = describe.call(this, description, context);
currentFrame = currentFrame.parent;
return result;
};
jasmine.Env.prototype.it = function(description, closure){
var result = it.call(this, description, closure),
currentSpec = this.currentSpec,
frame = this.jstdFrame = currentFrame,
name = 'test that it ' + description;
if (this.jstdFrame.testCase.prototype[name])
throw "Spec with name '" + description + "' already exists.";
this.jstdFrame.testCase.prototype[name] = function(){
jasmine.getEnv().currentSpec = currentSpec;
frame.runBefore.apply(currentSpec);
try {
currentSpec.queue.start();
} finally {
frame.runAfter.apply(currentSpec);
}
};
return result;
};
jasmine.Env.prototype.beforeEach = function(closure) {
beforeEach.call(this, closure);
currentFrame.before.push(closure);
};
jasmine.Env.prototype.afterEach = function(closure) {
afterEach.call(this, closure);
currentFrame.after.push(closure);
};
jasmine.NestedResults.prototype.addResult = function(result) {
addResult.call(this, result);
if (result.type != 'MessageResult' && !result.passed()) fail(result.message);
};
// @reesd - Disable the catch on exceptions when using JSTD, we want them to make it up to JSTD
jasmine.Block.prototype.execute = function(onComplete) {
try {
this.func.apply(this.spec);
} finally {
onComplete();
}
};
// Reset environment with overriden methods.
jasmine.currentEnv_ = null;
jasmine.getEnv();
})(jasmine.Env.prototype.describe, jasmine.Env.prototype.it, jasmine.Env.prototype.beforeEach, jasmine.Env.prototype.afterEach, jasmine.NestedResults.prototype.addResult);

22
thirdparty/jasmine-jstd-adapter/test.sh vendored Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
while getopts "j:t:" flag
do
if [ $flag == "j" ]; then
JSTD=$OPTARG
elif [ $flag == "t" ]; then
TESTS=$OPTARG
fi
done
if [ -z "$JSTD" ]; then
JSTD=`ls ../jstestdriver/[jJ]s[tT]est[dD]river*.jar`
fi
if [ -z "$TESTS" ]; then
TESTS="all"
echo "Running all tests"
else
echo "Running '$TESTS'"
fi
java -jar $JSTD --reset --tests "$TESTS"