evergreen 1.0.0.rc → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -2
- data/config/routes.rb +1 -1
- data/lib/evergreen.rb +2 -6
- data/lib/evergreen/application.rb +38 -59
- data/lib/evergreen/cli.rb +2 -2
- data/lib/evergreen/runner.rb +6 -3
- data/lib/evergreen/server.rb +1 -5
- data/lib/evergreen/suite.rb +1 -13
- data/lib/evergreen/tasks.rb +1 -1
- data/lib/evergreen/version.rb +1 -1
- data/lib/jasmine/Contribute.markdown +44 -0
- data/lib/jasmine/Gemfile +4 -6
- data/lib/jasmine/MIT.LICENSE +1 -1
- data/lib/jasmine/README.markdown +17 -14
- data/lib/jasmine/Rakefile +21 -170
- data/lib/jasmine/Release.markdown +40 -0
- data/lib/jasmine/images/jasmine_favicon.png +0 -0
- data/lib/jasmine/jasmine-core.gemspec +22 -0
- data/lib/jasmine/jshint/jshint.js +5919 -0
- data/lib/jasmine/jshint/run.js +99 -0
- data/lib/jasmine/lib/jasmine-core.rb +36 -0
- data/lib/jasmine/lib/jasmine-core/example/SpecRunner.html +54 -0
- data/lib/jasmine/{example → lib/jasmine-core/example}/spec/PlayerSpec.js +0 -0
- data/lib/jasmine/{example → lib/jasmine-core/example}/spec/SpecHelper.js +3 -3
- data/lib/jasmine/{example → lib/jasmine-core/example}/src/Player.js +0 -0
- data/lib/jasmine/{example → lib/jasmine-core/example}/src/Song.js +0 -0
- data/lib/jasmine/lib/{jasmine-html.js → jasmine-core/jasmine-html.js} +6 -4
- data/lib/jasmine/lib/{jasmine.css → jasmine-core/jasmine.css} +0 -0
- data/lib/jasmine/lib/{jasmine.js → jasmine-core/jasmine.js} +103 -48
- data/lib/jasmine/lib/{json2.js → jasmine-core/json2.js} +0 -0
- data/lib/jasmine/lib/jasmine-core/version.rb +6 -0
- data/lib/jasmine/spec/console/ConsoleReporterSpec.js +451 -0
- data/lib/jasmine/spec/{suites → core}/BaseSpec.js +0 -0
- data/lib/jasmine/spec/{suites → core}/CustomMatchersSpec.js +0 -0
- data/lib/jasmine/spec/{suites → core}/EnvSpec.js +3 -2
- data/lib/jasmine/spec/{suites → core}/ExceptionsSpec.js +46 -4
- data/lib/jasmine/spec/{suites → core}/JsApiReporterSpec.js +1 -1
- data/lib/jasmine/spec/{suites → core}/MatchersSpec.js +87 -44
- data/lib/jasmine/spec/{suites → core}/MockClockSpec.js +0 -0
- data/lib/jasmine/spec/{suites → core}/MultiReporterSpec.js +3 -3
- data/lib/jasmine/spec/{suites → core}/NestedResultsSpec.js +0 -0
- data/lib/jasmine/spec/{suites → core}/PrettyPrintSpec.js +0 -6
- data/lib/jasmine/spec/{suites → core}/QueueSpec.js +0 -0
- data/lib/jasmine/spec/{suites → core}/ReporterSpec.js +0 -0
- data/lib/jasmine/spec/{suites → core}/RunnerSpec.js +0 -0
- data/lib/jasmine/spec/{suites → core}/SpecRunningSpec.js +14 -9
- data/lib/jasmine/spec/{suites → core}/SpecSpec.js +1 -1
- data/lib/jasmine/spec/{suites → core}/SpySpec.js +0 -0
- data/lib/jasmine/spec/{suites → core}/SuiteSpec.js +0 -0
- data/lib/jasmine/spec/{suites → core}/UtilSpec.js +0 -1
- data/lib/jasmine/spec/{suites → core}/WaitsForBlockSpec.js +32 -1
- data/lib/jasmine/spec/html/MatchersHtmlSpec.js +38 -0
- data/lib/jasmine/spec/html/PrettyPrintHtmlSpec.js +8 -0
- data/lib/jasmine/spec/{suites → html}/TrivialReporterSpec.js +3 -2
- data/lib/jasmine/spec/node_suite.js +127 -0
- data/lib/jasmine/spec/runner.html +44 -45
- data/lib/jasmine/spec/templates/runner.html.erb +49 -0
- data/lib/jasmine/spec/templates/script_tag.html.erb +1 -0
- data/lib/jasmine/src/SourcesList.json +7 -0
- data/lib/jasmine/src/console/ConsoleReporter.js +177 -0
- data/lib/jasmine/src/{Block.js → core/Block.js} +1 -1
- data/lib/jasmine/src/{Env.js → core/Env.js} +13 -8
- data/lib/jasmine/src/{JsApiReporter.js → core/JsApiReporter.js} +0 -0
- data/lib/jasmine/src/{Matchers.js → core/Matchers.js} +24 -7
- data/lib/jasmine/src/{MultiReporter.js → core/MultiReporter.js} +0 -0
- data/lib/jasmine/src/{NestedResults.js → core/NestedResults.js} +0 -0
- data/lib/jasmine/src/{PrettyPrinter.js → core/PrettyPrinter.js} +2 -1
- data/lib/jasmine/src/{Queue.js → core/Queue.js} +0 -0
- data/lib/jasmine/src/{Reporter.js → core/Reporter.js} +0 -0
- data/lib/jasmine/src/{Runner.js → core/Runner.js} +1 -1
- data/lib/jasmine/src/{Spec.js → core/Spec.js} +2 -1
- data/lib/jasmine/src/{Suite.js → core/Suite.js} +1 -1
- data/lib/jasmine/src/{WaitsBlock.js → core/WaitsBlock.js} +3 -1
- data/lib/jasmine/src/{WaitsForBlock.js → core/WaitsForBlock.js} +4 -2
- data/lib/jasmine/src/{base.js → core/base.js} +52 -24
- data/lib/jasmine/src/{mock-timeout.js → core/mock-timeout.js} +0 -0
- data/lib/jasmine/src/{util.js → core/util.js} +1 -1
- data/lib/jasmine/src/html/TrivialReporter.js +6 -4
- data/lib/jasmine/src/templates/example_project_jasmine_tags.html.erb +3 -0
- data/lib/jasmine/src/templates/version.js.erb +6 -0
- data/lib/jasmine/src/templates/version.rb.erb +6 -0
- data/lib/jasmine/src/version.js +6 -0
- data/lib/jasmine/src/version.json +2 -2
- data/lib/jasmine/tasks/build_dist.rb +48 -0
- data/lib/jasmine/tasks/build_specs.rb +50 -0
- data/lib/jasmine/tasks/docs.rb +17 -0
- data/lib/jasmine/tasks/helpers.rb +50 -0
- data/lib/jasmine/tasks/pages.rb +13 -0
- data/lib/jasmine/tasks/spec.rb +37 -0
- data/lib/jasmine/tasks/standalone.rb +91 -0
- data/lib/jasmine/tasks/version.rb +5 -0
- data/lib/tasks/evergreen.rake +1 -1
- data/spec/evergreen_spec.rb +6 -7
- data/spec/runner_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -8
- metadata +95 -77
- data/lib/jasmine/cruise_config.rb +0 -21
- data/lib/jasmine/example/SpecRunner.html +0 -27
- data/lib/jasmine/images/fail-16.png +0 -0
- data/lib/jasmine/images/fail.png +0 -0
- data/lib/jasmine/images/go-16.png +0 -0
- data/lib/jasmine/images/go.png +0 -0
- data/lib/jasmine/images/pending-16.png +0 -0
- data/lib/jasmine/images/pending.png +0 -0
- data/lib/jasmine/images/question-bk.png +0 -0
- data/lib/jasmine/images/questionbk-16.png +0 -0
- data/lib/jasmine/images/spinner.gif +0 -0
@@ -0,0 +1,99 @@
|
|
1
|
+
var fs = require("fs");
|
2
|
+
var sys = require("sys");
|
3
|
+
var path = require("path");
|
4
|
+
var JSHINT = require("./jshint").JSHINT;
|
5
|
+
|
6
|
+
// DWF TODO: Standardize this?
|
7
|
+
function isExcluded(fullPath) {
|
8
|
+
var fileName = path.basename(fullPath);
|
9
|
+
var excludeFiles = ["json2.js", "jshint.js", "publish.js", "node_suite.js", "jasmine.js", "jasmine-html.js"];
|
10
|
+
for (var i = 0; i < excludeFiles.length; i++) {
|
11
|
+
if (fileName == excludeFiles[i]) {
|
12
|
+
return true;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
return false;
|
16
|
+
}
|
17
|
+
|
18
|
+
// DWF TODO: This function could/should be re-written
|
19
|
+
function allJasmineJsFiles(rootDir) {
|
20
|
+
var files = [];
|
21
|
+
fs.readdirSync(rootDir).filter(function(filename) {
|
22
|
+
|
23
|
+
var fullPath = rootDir + "/" + filename;
|
24
|
+
if (fs.statSync(fullPath).isDirectory() && !fullPath.match(/pages/)) {
|
25
|
+
var subDirFiles = allJasmineJsFiles(fullPath);
|
26
|
+
if (subDirFiles.length > 0) {
|
27
|
+
files = files.concat();
|
28
|
+
return true;
|
29
|
+
}
|
30
|
+
} else {
|
31
|
+
if (fullPath.match(/\.js$/) && !isExcluded(fullPath)) {
|
32
|
+
files.push(fullPath);
|
33
|
+
return true;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
return false;
|
37
|
+
});
|
38
|
+
|
39
|
+
return files;
|
40
|
+
}
|
41
|
+
|
42
|
+
var jasmineJsFiles = allJasmineJsFiles(".");
|
43
|
+
jasmineJsFiles.reverse(); //cheap way to do the stuff in src stuff first
|
44
|
+
|
45
|
+
var jasmineJsHintConfig = {
|
46
|
+
|
47
|
+
forin:true, //while it's possible that we could be
|
48
|
+
//considering unwanted prototype methods, mostly
|
49
|
+
//we're doing this because the jsobjects are being
|
50
|
+
//used as maps.
|
51
|
+
|
52
|
+
loopfunc:true //we're fine with functions defined inside loops (setTimeout functions, etc)
|
53
|
+
|
54
|
+
};
|
55
|
+
|
56
|
+
var jasmineGlobals = {};
|
57
|
+
|
58
|
+
|
59
|
+
//jasmine.undefined is a jasmine-ism, let's let it go...
|
60
|
+
function removeJasmineUndefinedErrors(errors) {
|
61
|
+
var keepErrors = [];
|
62
|
+
for (var i = 0; i < errors.length; i++) {
|
63
|
+
if (!(errors[i] &&
|
64
|
+
errors[i].raw &&
|
65
|
+
errors[i].evidence &&
|
66
|
+
( errors[i].evidence.match(/jasmine\.undefined/) ||
|
67
|
+
errors[i].evidence.match(/diz be undefined yo/) )
|
68
|
+
)) {
|
69
|
+
keepErrors.push(errors[i]);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
return keepErrors;
|
73
|
+
}
|
74
|
+
|
75
|
+
(function() {
|
76
|
+
var ansi = {
|
77
|
+
green: '\033[32m',
|
78
|
+
red: '\033[31m',
|
79
|
+
yellow: '\033[33m',
|
80
|
+
none: '\033[0m'
|
81
|
+
};
|
82
|
+
|
83
|
+
for (var i = 0; i < jasmineJsFiles.length; i++) {
|
84
|
+
var file = jasmineJsFiles[i];
|
85
|
+
JSHINT(fs.readFileSync(file, "utf8"), jasmineJsHintConfig);
|
86
|
+
var errors = JSHINT.data().errors || [];
|
87
|
+
errors = removeJasmineUndefinedErrors(errors);
|
88
|
+
|
89
|
+
if (errors.length >= 1) {
|
90
|
+
console.log(ansi.red + "Jasmine JSHint failure: " + ansi.none);
|
91
|
+
console.log(file);
|
92
|
+
console.log(errors);
|
93
|
+
process.exit(1);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
console.log(ansi.green + "Jasmine JSHint PASSED." + ansi.none);
|
98
|
+
})();
|
99
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Jasmine
|
2
|
+
module Core
|
3
|
+
class << self
|
4
|
+
def path
|
5
|
+
File.join(File.dirname(__FILE__), "jasmine-core")
|
6
|
+
end
|
7
|
+
|
8
|
+
def js_files
|
9
|
+
(["jasmine.js"] + Dir.glob(File.join(path, "*.js"))).map { |f| File.basename(f) }.uniq
|
10
|
+
end
|
11
|
+
|
12
|
+
SPEC_TYPES = ["core", "html", "node"]
|
13
|
+
|
14
|
+
def core_spec_files
|
15
|
+
spec_files("core")
|
16
|
+
end
|
17
|
+
|
18
|
+
def html_spec_files
|
19
|
+
spec_files("html")
|
20
|
+
end
|
21
|
+
|
22
|
+
def node_spec_files
|
23
|
+
spec_files("node")
|
24
|
+
end
|
25
|
+
|
26
|
+
def spec_files(type)
|
27
|
+
raise ArgumentError.new("Unrecognized spec type") unless SPEC_TYPES.include?(type)
|
28
|
+
(Dir.glob(File.join(path, "spec", type, "*.js"))).map { |f| File.join("spec", type, File.basename(f)) }.uniq
|
29
|
+
end
|
30
|
+
|
31
|
+
def css_files
|
32
|
+
Dir.glob(File.join(path, "*.css")).map { |f| File.basename(f) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>Jasmine Spec Runner</title>
|
6
|
+
|
7
|
+
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.1.0.rc1/jasmine_favicon.png">
|
8
|
+
|
9
|
+
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.1.0.rc1/jasmine.css">
|
10
|
+
<script type="text/javascript" src="lib/jasmine-1.1.0.rc1/jasmine.js"></script>
|
11
|
+
<script type="text/javascript" src="lib/jasmine-1.1.0.rc1/jasmine-html.js"></script>
|
12
|
+
|
13
|
+
<!-- include spec files here... -->
|
14
|
+
<script type="text/javascript" src="spec/SpecHelper.js"></script>
|
15
|
+
<script type="text/javascript" src="spec/PlayerSpec.js"></script>
|
16
|
+
|
17
|
+
<!-- include source files here... -->
|
18
|
+
<script type="text/javascript" src="src/Player.js"></script>
|
19
|
+
<script type="text/javascript" src="src/Song.js"></script>
|
20
|
+
|
21
|
+
<script type="text/javascript">
|
22
|
+
(function() {
|
23
|
+
var jasmineEnv = jasmine.getEnv();
|
24
|
+
jasmineEnv.updateInterval = 1000;
|
25
|
+
|
26
|
+
var trivialReporter = new jasmine.TrivialReporter();
|
27
|
+
|
28
|
+
jasmineEnv.addReporter(trivialReporter);
|
29
|
+
|
30
|
+
jasmineEnv.specFilter = function(spec) {
|
31
|
+
return trivialReporter.specFilter(spec);
|
32
|
+
};
|
33
|
+
|
34
|
+
var currentWindowOnload = window.onload;
|
35
|
+
|
36
|
+
window.onload = function() {
|
37
|
+
if (currentWindowOnload) {
|
38
|
+
currentWindowOnload();
|
39
|
+
}
|
40
|
+
execJasmine();
|
41
|
+
};
|
42
|
+
|
43
|
+
function execJasmine() {
|
44
|
+
jasmineEnv.execute();
|
45
|
+
}
|
46
|
+
|
47
|
+
})();
|
48
|
+
</script>
|
49
|
+
|
50
|
+
</head>
|
51
|
+
|
52
|
+
<body>
|
53
|
+
</body>
|
54
|
+
</html>
|
File without changes
|
@@ -2,8 +2,8 @@ beforeEach(function() {
|
|
2
2
|
this.addMatchers({
|
3
3
|
toBePlaying: function(expectedSong) {
|
4
4
|
var player = this.actual;
|
5
|
-
return player.currentlyPlayingSong === expectedSong
|
6
|
-
|
5
|
+
return player.currentlyPlayingSong === expectedSong &&
|
6
|
+
player.isPlaying;
|
7
7
|
}
|
8
|
-
})
|
8
|
+
});
|
9
9
|
});
|
File without changes
|
File without changes
|
@@ -34,7 +34,7 @@ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
|
34
34
|
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
35
35
|
this.createDom('div', { className: 'banner' },
|
36
36
|
this.createDom('div', { className: 'logo' },
|
37
|
-
this.createDom('
|
37
|
+
this.createDom('span', { className: 'title' }, "Jasmine"),
|
38
38
|
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
39
39
|
this.createDom('div', { className: 'options' },
|
40
40
|
"Show ",
|
@@ -110,7 +110,7 @@ jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
|
110
110
|
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
111
111
|
var results = suite.results();
|
112
112
|
var status = results.passed() ? 'passed' : 'failed';
|
113
|
-
if (results.totalCount
|
113
|
+
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
114
114
|
status = 'skipped';
|
115
115
|
}
|
116
116
|
this.suiteDivs[suite.id].className += " " + status;
|
@@ -183,6 +183,8 @@ jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
|
183
183
|
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
184
184
|
}
|
185
185
|
|
186
|
-
if (!paramMap
|
187
|
-
|
186
|
+
if (!paramMap.spec) {
|
187
|
+
return true;
|
188
|
+
}
|
189
|
+
return spec.getFullName().indexOf(paramMap.spec) === 0;
|
188
190
|
};
|
File without changes
|
@@ -1,10 +1,12 @@
|
|
1
|
+
var isCommonJS = typeof window == "undefined";
|
2
|
+
|
1
3
|
/**
|
2
4
|
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
|
3
5
|
*
|
4
6
|
* @namespace
|
5
7
|
*/
|
6
8
|
var jasmine = {};
|
7
|
-
|
9
|
+
if (isCommonJS) exports.jasmine = jasmine;
|
8
10
|
/**
|
9
11
|
* @private
|
10
12
|
*/
|
@@ -20,6 +22,12 @@ jasmine.unimplementedMethod_ = function() {
|
|
20
22
|
*/
|
21
23
|
jasmine.undefined = jasmine.___undefined___;
|
22
24
|
|
25
|
+
/**
|
26
|
+
* Show diagnostic messages in the console if set to true
|
27
|
+
*
|
28
|
+
*/
|
29
|
+
jasmine.VERBOSE = false;
|
30
|
+
|
23
31
|
/**
|
24
32
|
* Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed.
|
25
33
|
*
|
@@ -72,7 +80,7 @@ jasmine.MessageResult = function(values) {
|
|
72
80
|
|
73
81
|
jasmine.MessageResult.prototype.toString = function() {
|
74
82
|
var text = "";
|
75
|
-
for(var i = 0; i < this.values.length; i++) {
|
83
|
+
for (var i = 0; i < this.values.length; i++) {
|
76
84
|
if (i > 0) text += " ";
|
77
85
|
if (jasmine.isString_(this.values[i])) {
|
78
86
|
text += this.values[i];
|
@@ -89,9 +97,10 @@ jasmine.ExpectationResult = function(params) {
|
|
89
97
|
this.passed_ = params.passed;
|
90
98
|
this.expected = params.expected;
|
91
99
|
this.actual = params.actual;
|
92
|
-
|
93
100
|
this.message = this.passed_ ? 'Passed.' : params.message;
|
94
|
-
|
101
|
+
|
102
|
+
var trace = (params.trace || new Error(this.message));
|
103
|
+
this.trace = this.passed_ ? '' : trace;
|
95
104
|
};
|
96
105
|
|
97
106
|
jasmine.ExpectationResult.prototype.toString = function () {
|
@@ -106,7 +115,8 @@ jasmine.ExpectationResult.prototype.passed = function () {
|
|
106
115
|
* Getter for the Jasmine environment. Ensures one gets created
|
107
116
|
*/
|
108
117
|
jasmine.getEnv = function() {
|
109
|
-
|
118
|
+
var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
|
119
|
+
return env;
|
110
120
|
};
|
111
121
|
|
112
122
|
/**
|
@@ -116,7 +126,7 @@ jasmine.getEnv = function() {
|
|
116
126
|
* @returns {Boolean}
|
117
127
|
*/
|
118
128
|
jasmine.isArray_ = function(value) {
|
119
|
-
return jasmine.isA_("Array", value);
|
129
|
+
return jasmine.isA_("Array", value);
|
120
130
|
};
|
121
131
|
|
122
132
|
/**
|
@@ -169,7 +179,7 @@ jasmine.pp = function(value) {
|
|
169
179
|
* @returns {Boolean}
|
170
180
|
*/
|
171
181
|
jasmine.isDomNode = function(obj) {
|
172
|
-
return obj
|
182
|
+
return obj.nodeType > 0;
|
173
183
|
};
|
174
184
|
|
175
185
|
/**
|
@@ -405,7 +415,7 @@ jasmine.isSpy = function(putativeSpy) {
|
|
405
415
|
* @param {Array} methodNames array of names of methods to make spies
|
406
416
|
*/
|
407
417
|
jasmine.createSpyObj = function(baseName, methodNames) {
|
408
|
-
if (!jasmine.isArray_(methodNames) || methodNames.length
|
418
|
+
if (!jasmine.isArray_(methodNames) || methodNames.length === 0) {
|
409
419
|
throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
|
410
420
|
}
|
411
421
|
var obj = {};
|
@@ -443,6 +453,7 @@ jasmine.log = function() {
|
|
443
453
|
var spyOn = function(obj, methodName) {
|
444
454
|
return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
|
445
455
|
};
|
456
|
+
if (isCommonJS) exports.spyOn = spyOn;
|
446
457
|
|
447
458
|
/**
|
448
459
|
* Creates a Jasmine spec that will be added to the current suite.
|
@@ -460,6 +471,7 @@ var spyOn = function(obj, methodName) {
|
|
460
471
|
var it = function(desc, func) {
|
461
472
|
return jasmine.getEnv().it(desc, func);
|
462
473
|
};
|
474
|
+
if (isCommonJS) exports.it = it;
|
463
475
|
|
464
476
|
/**
|
465
477
|
* Creates a <em>disabled</em> Jasmine spec.
|
@@ -472,6 +484,7 @@ var it = function(desc, func) {
|
|
472
484
|
var xit = function(desc, func) {
|
473
485
|
return jasmine.getEnv().xit(desc, func);
|
474
486
|
};
|
487
|
+
if (isCommonJS) exports.xit = xit;
|
475
488
|
|
476
489
|
/**
|
477
490
|
* Starts a chain for a Jasmine expectation.
|
@@ -484,6 +497,7 @@ var xit = function(desc, func) {
|
|
484
497
|
var expect = function(actual) {
|
485
498
|
return jasmine.getEnv().currentSpec.expect(actual);
|
486
499
|
};
|
500
|
+
if (isCommonJS) exports.expect = expect;
|
487
501
|
|
488
502
|
/**
|
489
503
|
* Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
|
@@ -493,6 +507,7 @@ var expect = function(actual) {
|
|
493
507
|
var runs = function(func) {
|
494
508
|
jasmine.getEnv().currentSpec.runs(func);
|
495
509
|
};
|
510
|
+
if (isCommonJS) exports.runs = runs;
|
496
511
|
|
497
512
|
/**
|
498
513
|
* Waits a fixed time period before moving to the next block.
|
@@ -503,6 +518,7 @@ var runs = function(func) {
|
|
503
518
|
var waits = function(timeout) {
|
504
519
|
jasmine.getEnv().currentSpec.waits(timeout);
|
505
520
|
};
|
521
|
+
if (isCommonJS) exports.waits = waits;
|
506
522
|
|
507
523
|
/**
|
508
524
|
* Waits for the latchFunction to return true before proceeding to the next block.
|
@@ -514,6 +530,7 @@ var waits = function(timeout) {
|
|
514
530
|
var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
|
515
531
|
jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
|
516
532
|
};
|
533
|
+
if (isCommonJS) exports.waitsFor = waitsFor;
|
517
534
|
|
518
535
|
/**
|
519
536
|
* A function that is called before each spec in a suite.
|
@@ -525,6 +542,7 @@ var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout
|
|
525
542
|
var beforeEach = function(beforeEachFunction) {
|
526
543
|
jasmine.getEnv().beforeEach(beforeEachFunction);
|
527
544
|
};
|
545
|
+
if (isCommonJS) exports.beforeEach = beforeEach;
|
528
546
|
|
529
547
|
/**
|
530
548
|
* A function that is called after each spec in a suite.
|
@@ -536,6 +554,7 @@ var beforeEach = function(beforeEachFunction) {
|
|
536
554
|
var afterEach = function(afterEachFunction) {
|
537
555
|
jasmine.getEnv().afterEach(afterEachFunction);
|
538
556
|
};
|
557
|
+
if (isCommonJS) exports.afterEach = afterEach;
|
539
558
|
|
540
559
|
/**
|
541
560
|
* Defines a suite of specifications.
|
@@ -555,6 +574,7 @@ var afterEach = function(afterEachFunction) {
|
|
555
574
|
var describe = function(description, specDefinitions) {
|
556
575
|
return jasmine.getEnv().describe(description, specDefinitions);
|
557
576
|
};
|
577
|
+
if (isCommonJS) exports.describe = describe;
|
558
578
|
|
559
579
|
/**
|
560
580
|
* Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
|
@@ -565,27 +585,35 @@ var describe = function(description, specDefinitions) {
|
|
565
585
|
var xdescribe = function(description, specDefinitions) {
|
566
586
|
return jasmine.getEnv().xdescribe(description, specDefinitions);
|
567
587
|
};
|
588
|
+
if (isCommonJS) exports.xdescribe = xdescribe;
|
568
589
|
|
569
590
|
|
570
591
|
// Provide the XMLHttpRequest class for IE 5.x-6.x:
|
571
592
|
jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
return
|
578
|
-
} catch(e) {
|
579
|
-
}
|
580
|
-
try {
|
581
|
-
return new ActiveXObject("Msxml2.XMLHTTP");
|
582
|
-
} catch(e) {
|
583
|
-
}
|
584
|
-
try {
|
585
|
-
return new ActiveXObject("Microsoft.XMLHTTP");
|
586
|
-
} catch(e) {
|
593
|
+
function tryIt(f) {
|
594
|
+
try {
|
595
|
+
return f();
|
596
|
+
} catch(e) {
|
597
|
+
}
|
598
|
+
return null;
|
587
599
|
}
|
588
|
-
|
600
|
+
|
601
|
+
var xhr = tryIt(function() {
|
602
|
+
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
|
603
|
+
}) ||
|
604
|
+
tryIt(function() {
|
605
|
+
return new ActiveXObject("Msxml2.XMLHTTP.3.0");
|
606
|
+
}) ||
|
607
|
+
tryIt(function() {
|
608
|
+
return new ActiveXObject("Msxml2.XMLHTTP");
|
609
|
+
}) ||
|
610
|
+
tryIt(function() {
|
611
|
+
return new ActiveXObject("Microsoft.XMLHTTP");
|
612
|
+
});
|
613
|
+
|
614
|
+
if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
|
615
|
+
|
616
|
+
return xhr;
|
589
617
|
} : XMLHttpRequest;
|
590
618
|
/**
|
591
619
|
* @namespace
|
@@ -606,7 +634,7 @@ jasmine.util.inherit = function(childClass, parentClass) {
|
|
606
634
|
var subclass = function() {
|
607
635
|
};
|
608
636
|
subclass.prototype = parentClass.prototype;
|
609
|
-
childClass.prototype = new subclass;
|
637
|
+
childClass.prototype = new subclass();
|
610
638
|
};
|
611
639
|
|
612
640
|
jasmine.util.formatException = function(e) {
|
@@ -707,12 +735,17 @@ jasmine.Env.prototype.version = function () {
|
|
707
735
|
* @returns string containing jasmine version build info, if set.
|
708
736
|
*/
|
709
737
|
jasmine.Env.prototype.versionString = function() {
|
710
|
-
if (jasmine.version_) {
|
711
|
-
var version = this.version();
|
712
|
-
return version.major + "." + version.minor + "." + version.build + " revision " + version.revision;
|
713
|
-
} else {
|
738
|
+
if (!jasmine.version_) {
|
714
739
|
return "version unknown";
|
715
740
|
}
|
741
|
+
|
742
|
+
var version = this.version();
|
743
|
+
var versionString = version.major + "." + version.minor + "." + version.build;
|
744
|
+
if (version.release_candidate) {
|
745
|
+
versionString += ".rc" + version.release_candidate;
|
746
|
+
}
|
747
|
+
versionString += " revision " + version.revision;
|
748
|
+
return versionString;
|
716
749
|
};
|
717
750
|
|
718
751
|
/**
|
@@ -760,14 +793,14 @@ jasmine.Env.prototype.describe = function(description, specDefinitions) {
|
|
760
793
|
declarationError = e;
|
761
794
|
}
|
762
795
|
|
763
|
-
this.currentSuite = parentSuite;
|
764
|
-
|
765
796
|
if (declarationError) {
|
766
797
|
this.it("encountered a declaration exception", function() {
|
767
798
|
throw declarationError;
|
768
799
|
});
|
769
800
|
}
|
770
801
|
|
802
|
+
this.currentSuite = parentSuite;
|
803
|
+
|
771
804
|
return suite;
|
772
805
|
};
|
773
806
|
|
@@ -828,7 +861,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
|
|
828
861
|
b.__Jasmine_been_here_before__ = a;
|
829
862
|
|
830
863
|
var hasKey = function(obj, keyName) {
|
831
|
-
return obj
|
864
|
+
return obj !== null && obj[keyName] !== jasmine.undefined;
|
832
865
|
};
|
833
866
|
|
834
867
|
for (var property in b) {
|
@@ -854,7 +887,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
|
|
854
887
|
|
855
888
|
delete a.__Jasmine_been_here_before__;
|
856
889
|
delete b.__Jasmine_been_here_before__;
|
857
|
-
return (mismatchKeys.length
|
890
|
+
return (mismatchKeys.length === 0 && mismatchValues.length === 0);
|
858
891
|
};
|
859
892
|
|
860
893
|
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
@@ -1302,16 +1335,16 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
|
|
1302
1335
|
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
1303
1336
|
}
|
1304
1337
|
this.message = function() {
|
1305
|
-
if (this.actual.callCount
|
1338
|
+
if (this.actual.callCount === 0) {
|
1306
1339
|
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
|
1307
1340
|
return [
|
1308
|
-
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
1309
|
-
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
|
1341
|
+
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
1342
|
+
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
|
1310
1343
|
];
|
1311
1344
|
} else {
|
1312
1345
|
return [
|
1313
|
-
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
|
1314
|
-
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
|
1346
|
+
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
|
1347
|
+
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
|
1315
1348
|
];
|
1316
1349
|
}
|
1317
1350
|
};
|
@@ -1333,7 +1366,7 @@ jasmine.Matchers.prototype.wasNotCalledWith = function() {
|
|
1333
1366
|
return [
|
1334
1367
|
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
|
1335
1368
|
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
|
1336
|
-
]
|
1369
|
+
];
|
1337
1370
|
};
|
1338
1371
|
|
1339
1372
|
return !this.env.contains_(this.actual.argsForCall, expectedArgs);
|
@@ -1366,6 +1399,23 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
|
|
1366
1399
|
return this.actual > expected;
|
1367
1400
|
};
|
1368
1401
|
|
1402
|
+
/**
|
1403
|
+
* Matcher that checks that the expected item is equal to the actual item
|
1404
|
+
* up to a given level of decimal precision (default 2).
|
1405
|
+
*
|
1406
|
+
* @param {Number} expected
|
1407
|
+
* @param {Number} precision
|
1408
|
+
*/
|
1409
|
+
jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
|
1410
|
+
if (!(precision === 0)) {
|
1411
|
+
precision = precision || 2;
|
1412
|
+
}
|
1413
|
+
var multiplier = Math.pow(10, precision);
|
1414
|
+
var actual = Math.round(this.actual * multiplier);
|
1415
|
+
expected = Math.round(expected * multiplier);
|
1416
|
+
return expected == actual;
|
1417
|
+
};
|
1418
|
+
|
1369
1419
|
/**
|
1370
1420
|
* Matcher that checks that the expected exception was thrown by the actual.
|
1371
1421
|
*
|
@@ -1390,7 +1440,7 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
|
|
1390
1440
|
|
1391
1441
|
this.message = function() {
|
1392
1442
|
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
1393
|
-
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "
|
1443
|
+
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
|
1394
1444
|
} else {
|
1395
1445
|
return "Expected function to throw an exception.";
|
1396
1446
|
}
|
@@ -1602,7 +1652,8 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
|
1602
1652
|
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
1603
1653
|
for (var property in obj) {
|
1604
1654
|
if (property == '__Jasmine_been_here_before__') continue;
|
1605
|
-
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property)
|
1655
|
+
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
|
1656
|
+
obj.__lookupGetter__(property) !== null) : false);
|
1606
1657
|
}
|
1607
1658
|
};
|
1608
1659
|
|
@@ -1962,7 +2013,8 @@ jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessag
|
|
1962
2013
|
jasmine.Spec.prototype.fail = function (e) {
|
1963
2014
|
var expectationResult = new jasmine.ExpectationResult({
|
1964
2015
|
passed: false,
|
1965
|
-
message: e ? jasmine.util.formatException(e) : 'Exception'
|
2016
|
+
message: e ? jasmine.util.formatException(e) : 'Exception',
|
2017
|
+
trace: { stack: e.stack }
|
1966
2018
|
});
|
1967
2019
|
this.results_.addResult(expectationResult);
|
1968
2020
|
};
|
@@ -2172,7 +2224,9 @@ jasmine.WaitsBlock = function(env, timeout, spec) {
|
|
2172
2224
|
jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
|
2173
2225
|
|
2174
2226
|
jasmine.WaitsBlock.prototype.execute = function (onComplete) {
|
2175
|
-
|
2227
|
+
if (jasmine.VERBOSE) {
|
2228
|
+
this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
|
2229
|
+
}
|
2176
2230
|
this.env.setTimeout(function () {
|
2177
2231
|
onComplete();
|
2178
2232
|
}, this.timeout);
|
@@ -2200,7 +2254,9 @@ jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
|
|
2200
2254
|
jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10;
|
2201
2255
|
|
2202
2256
|
jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
|
2203
|
-
|
2257
|
+
if (jasmine.VERBOSE) {
|
2258
|
+
this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
|
2259
|
+
}
|
2204
2260
|
var latchFunctionResult;
|
2205
2261
|
try {
|
2206
2262
|
latchFunctionResult = this.latchFunction.apply(this.spec);
|
@@ -2412,10 +2468,9 @@ jasmine.getGlobal().clearInterval = function(timeoutKey) {
|
|
2412
2468
|
}
|
2413
2469
|
};
|
2414
2470
|
|
2415
|
-
|
2416
2471
|
jasmine.version_= {
|
2417
2472
|
"major": 1,
|
2418
|
-
"minor":
|
2419
|
-
"build":
|
2420
|
-
"revision":
|
2473
|
+
"minor": 1,
|
2474
|
+
"build": 0,
|
2475
|
+
"revision": 1315677058
|
2421
2476
|
};
|