Skip to content

Commit

Permalink
initial revision of jasmine-node
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Mar 8, 2010
0 parents commit e77ca28
Show file tree
Hide file tree
Showing 12 changed files with 2,445 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .externalToolBuilders/jasmineSpecs.launch
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; id=&quot;1268025180352_126&quot; label=&quot;workingSet&quot; name=&quot;workingSet&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/jasmine-node/lib&quot; type=&quot;2&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/jasmine-node/spec&quot; type=&quot;2&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/jasmine-node/specs.js&quot; type=&quot;1&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/jasmine-node/specs.sh}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/jasmine-node}"/>
</launchConfiguration>
27 changes: 27 additions & 0 deletions .project
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jasmine-node</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>auto,full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/jasmineSpecs.launch</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
3 changes: 3 additions & 0 deletions .settings/.jsdtscope
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
</classpath>
1 change: 1 addition & 0 deletions .settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
1 change: 1 addition & 0 deletions .settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
Window
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
The MIT License

Copyright (c) 2010 Adam Abrons and Misko Hevery http://getangular.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.

3 changes: 3 additions & 0 deletions README.md
@@ -0,0 +1,3 @@
jasmine-node
======
TODO
92 changes: 92 additions & 0 deletions lib/jasmine/index.js
@@ -0,0 +1,92 @@
var fs = require('fs');
var sys = require('sys');

var filename = __dirname + '/jasmine-0.10.1.js';
global.window = {
setTimeout: setTimeout,
clearTimeout: clearTimeout,
setInterval: setInterval,
clearInterval: clearInterval
};
var src = fs.readFileSync(filename);
var jasmine = process.compile(src + '\njasmine;', filename);
delete global.window;

jasmine.executeSpecsInFolder = function(folder){
var specs = fs.readdirSync('spec');
for ( var i = 0; i < specs.length; i++) {
var filename = folder + '/' + specs[i];
process.compile(fs.readFileSync(filename), filename);
}

var log = [];
var columnCounter = 0;
var jasmineEnv = jasmine.getEnv();
jasmineEnv.reporter = {
log: function(str){
},
reportRunnerStarting: function(runner) {
},
reportSuiteResults: function(suite) {
var specResults = suite.results();
log.push('Spec ' + suite.description);
specResults.items_.forEach(function(spec){
if (spec.failedCount > 0 && spec.description) {
log.push(' it ' + spec.description);
spec.items_.forEach(function(result){
log.push(' ' + result.message);
});
}
});
},
reportSpecResults: function(spec) {
sys.print(spec.results().failedCount ? "F" : ".");
if (columnCounter++ < 50) return;
columnCounter = 0;
sys.print('\n');
},
reportRunnerResults: function(runner) {
sys.puts('\n----------');
log.forEach(function(log){
sys.puts(log);
});
process.exit(0);
}
};
jasmineEnv.execute();
};

function now(){
return new Date().getTime();
}

jasmine.asyncIt = function(name, specFn){
jasmine.getEnv().it(name, function(){
specFn();
jasmine.asyncIt.wait.done = false;
jasmine.asyncIt.wait();
});
};

jasmine.asyncIt.wait = function wait(){
wait.start = wait.start || now();
waits(1);
runs(function() {
if (wait.start + wait.timeout < now()) {
expect('timeout waiting for spec').toBeNull();
} else if (!wait.done) {
wait();
}
});
};
jasmine.asyncIt.wait.timeout = 2 * 1000;
jasmine.asyncSpecDone = function(){
jasmine.asyncIt.wait.done = true;
};


jasmine.xasyncIt = function(name, specFn){
jasmine.getEnv().xit(name, specFn);
};

process.mixin(exports, jasmine);

0 comments on commit e77ca28

Please sign in to comment.