shuriken 0.1.2.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Rakefile +28 -0
- data/coffeescripts/shuriken/test/assertions.coffee +111 -0
- data/coffeescripts/shuriken/test/reporters.coffee +61 -0
- data/coffeescripts/shuriken/test.coffee +117 -0
- data/coffeescripts/shuriken.coffee +2 -2
- data/javascripts/shuriken/mixins/callbacks.js +45 -0
- data/javascripts/shuriken/mixins.js +58 -0
- data/javascripts/shuriken/test/assertions.js +117 -0
- data/javascripts/shuriken/test/reporters.js +84 -0
- data/javascripts/shuriken/test.js +165 -0
- data/javascripts/shuriken.js +195 -0
- data/lib/shuriken.rb +1 -1
- data/shuriken.gemspec +84 -4
- data/tests/basic_namespace_tests.coffee +114 -0
- data/tests/template.erb +26 -0
- data/tests.watchr +6 -0
- data/vendor/jasmine-0.10.0/MIT.LICENSE +20 -0
- data/vendor/jasmine-0.10.0/README.markdown +437 -0
- data/vendor/jasmine-0.10.0/doc/files.html +460 -0
- data/vendor/jasmine-0.10.0/doc/index.html +322 -0
- data/vendor/jasmine-0.10.0/doc/symbols/_global_.html +918 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.Block.html +417 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.Clock.html +678 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.Env.html +1169 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.JsApiReporter.html +822 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.Matchers.html +1461 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.MultiReporter.html +394 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.NestedResults.html +710 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.Reporter.html +574 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.Runner.html +710 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.Spec.html +1259 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.Spy.html +855 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.Suite.html +705 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.html +1345 -0
- data/vendor/jasmine-0.10.0/doc/symbols/jasmine.util.html +535 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/lib_TrivialReporter.js.html +124 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_Block.js.html +29 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_Env.js.html +240 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_JsApiReporter.js.html +111 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_Matchers.js.html +328 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_MultiReporter.js.html +36 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_NestedResults.js.html +88 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_PrettyPrinter.js.html +130 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_Queue.js.html +102 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_Reporter.js.html +35 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_Reporters.js.html +51 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_Runner.js.html +75 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_Spec.js.html +211 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_Suite.js.html +77 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_WaitsBlock.js.html +21 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_WaitsForBlock.js.html +45 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_base.js.html +555 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_mock-timeout.js.html +185 -0
- data/vendor/jasmine-0.10.0/doc/symbols/src/src_util.js.html +75 -0
- data/vendor/jasmine-0.10.0/example/example_runner.html +25 -0
- data/vendor/jasmine-0.10.0/example/spec/example_suite.js +11 -0
- data/vendor/jasmine-0.10.0/lib/TrivialReporter.js +117 -0
- data/vendor/jasmine-0.10.0/lib/consolex.js +28 -0
- data/vendor/jasmine-0.10.0/lib/jasmine-0.10.0.js +2261 -0
- data/vendor/jasmine-0.10.0/lib/jasmine.css +86 -0
- data/vendor/jasmine-0.10.0/spec/runner.html +63 -0
- data/vendor/jasmine-0.10.0/spec/suites/CustomMatchersSpec.js +112 -0
- data/vendor/jasmine-0.10.0/spec/suites/EnvSpec.js +71 -0
- data/vendor/jasmine-0.10.0/spec/suites/ExceptionsSpec.js +107 -0
- data/vendor/jasmine-0.10.0/spec/suites/JsApiReporterSpec.js +82 -0
- data/vendor/jasmine-0.10.0/spec/suites/MatchersSpec.js +589 -0
- data/vendor/jasmine-0.10.0/spec/suites/MockClockSpec.js +34 -0
- data/vendor/jasmine-0.10.0/spec/suites/MultiReporterSpec.js +30 -0
- data/vendor/jasmine-0.10.0/spec/suites/NestedResultsSpec.js +54 -0
- data/vendor/jasmine-0.10.0/spec/suites/PrettyPrintSpec.js +93 -0
- data/vendor/jasmine-0.10.0/spec/suites/QueueSpec.js +23 -0
- data/vendor/jasmine-0.10.0/spec/suites/ReporterSpec.js +60 -0
- data/vendor/jasmine-0.10.0/spec/suites/RunnerSpec.js +258 -0
- data/vendor/jasmine-0.10.0/spec/suites/SpecRunningSpec.js +1086 -0
- data/vendor/jasmine-0.10.0/spec/suites/SpecSpec.js +110 -0
- data/vendor/jasmine-0.10.0/spec/suites/SpySpec.js +187 -0
- data/vendor/jasmine-0.10.0/spec/suites/SuiteSpec.js +101 -0
- data/vendor/jasmine-0.10.0/spec/suites/TrivialReporterSpec.js +140 -0
- data/vendor/jasmine-0.10.0/spec/suites/UtilSpec.js +23 -0
- data/vendor/jquery.js +154 -0
- data/wip-coffeescripts/example_test.coffee +0 -0
- data/wip-coffeescripts/test/assertions.coffee +111 -0
- data/wip-coffeescripts/test/reporters.coffee +61 -0
- data/wip-coffeescripts/test.coffee +96 -15
- metadata +83 -4
@@ -0,0 +1,86 @@
|
|
1
|
+
body {
|
2
|
+
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
3
|
+
}
|
4
|
+
|
5
|
+
|
6
|
+
body .run_spec {
|
7
|
+
float:right;
|
8
|
+
}
|
9
|
+
|
10
|
+
.runner.running {
|
11
|
+
background-color: yellow;
|
12
|
+
}
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
.runner {
|
17
|
+
border: 1px solid gray;
|
18
|
+
margin: 5px;
|
19
|
+
padding-left: 1em;
|
20
|
+
padding-right: 1em;
|
21
|
+
}
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
.suite {
|
26
|
+
border: 1px outset gray;
|
27
|
+
margin: 5px;
|
28
|
+
padding-left: 1em;
|
29
|
+
}
|
30
|
+
|
31
|
+
.suite.passed {
|
32
|
+
background-color: #cfc;
|
33
|
+
}
|
34
|
+
|
35
|
+
.suite.failed {
|
36
|
+
background-color: #fdd;
|
37
|
+
}
|
38
|
+
|
39
|
+
.spec {
|
40
|
+
margin: 5px;
|
41
|
+
clear: both;
|
42
|
+
}
|
43
|
+
|
44
|
+
.passed {
|
45
|
+
background-color: #cfc;
|
46
|
+
}
|
47
|
+
|
48
|
+
.failed {
|
49
|
+
background-color: #fdd;
|
50
|
+
}
|
51
|
+
|
52
|
+
.skipped {
|
53
|
+
color: #777;
|
54
|
+
background-color: #eee;
|
55
|
+
}
|
56
|
+
|
57
|
+
/*.resultMessage {*/
|
58
|
+
/*white-space: pre;*/
|
59
|
+
/*}*/
|
60
|
+
|
61
|
+
.resultMessage span.result {
|
62
|
+
display: block;
|
63
|
+
line-height: 2em;
|
64
|
+
color: black;
|
65
|
+
}
|
66
|
+
|
67
|
+
.resultMessage .mismatch {
|
68
|
+
color: black;
|
69
|
+
}
|
70
|
+
|
71
|
+
.stackTrace {
|
72
|
+
white-space: pre;
|
73
|
+
font-size: .8em;
|
74
|
+
margin-left: 10px;
|
75
|
+
height: 5em;
|
76
|
+
overflow: auto;
|
77
|
+
border: 1px inset red;
|
78
|
+
padding: 1em;
|
79
|
+
background: #eef;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
#jasmine_content {
|
84
|
+
position:fixed;
|
85
|
+
left: 100%;
|
86
|
+
}
|
@@ -0,0 +1,63 @@
|
|
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 Test Runner</title>
|
6
|
+
|
7
|
+
<script type="text/javascript">
|
8
|
+
// yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
|
9
|
+
undefined = "diz be undefined yo";
|
10
|
+
</script>
|
11
|
+
|
12
|
+
<script type="text/javascript" src="../lib/jasmine-0.10.0.js"></script>
|
13
|
+
<script type="text/javascript" src="../lib/TrivialReporter.js"></script>
|
14
|
+
<script type="text/javascript" src="../lib/consolex.js"></script>
|
15
|
+
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
(function () {
|
19
|
+
var suites = [
|
20
|
+
'suites/CustomMatchersSpec.js',
|
21
|
+
'suites/EnvSpec.js',
|
22
|
+
'suites/ExceptionsSpec.js',
|
23
|
+
'suites/JsApiReporterSpec.js',
|
24
|
+
'suites/MatchersSpec.js',
|
25
|
+
'suites/MultiReporterSpec.js',
|
26
|
+
'suites/NestedResultsSpec.js',
|
27
|
+
'suites/PrettyPrintSpec.js',
|
28
|
+
'suites/ReporterSpec.js',
|
29
|
+
'suites/RunnerSpec.js',
|
30
|
+
'suites/QueueSpec.js',
|
31
|
+
'suites/SpecSpec.js',
|
32
|
+
'suites/SpecRunningSpec.js',
|
33
|
+
'suites/SpySpec.js',
|
34
|
+
'suites/SuiteSpec.js',
|
35
|
+
'suites/TrivialReporterSpec.js',
|
36
|
+
];
|
37
|
+
for (var i = 0; i < suites.length; i++) {
|
38
|
+
jasmine.include(suites[i], true);
|
39
|
+
}
|
40
|
+
|
41
|
+
var jasmineEnv = jasmine.getEnv();
|
42
|
+
jasmineEnv.updateInterval = 1000;
|
43
|
+
|
44
|
+
var trivialReporter = new jasmine.TrivialReporter();
|
45
|
+
|
46
|
+
jasmineEnv.addReporter(trivialReporter);
|
47
|
+
|
48
|
+
jasmineEnv.specFilter = function(spec) {
|
49
|
+
return trivialReporter.specFilter(spec);
|
50
|
+
};
|
51
|
+
|
52
|
+
window.onload = function() {
|
53
|
+
jasmineEnv.execute();
|
54
|
+
};
|
55
|
+
})();
|
56
|
+
</script>
|
57
|
+
|
58
|
+
<link href="../lib/jasmine.css" rel="stylesheet"/>
|
59
|
+
</head>
|
60
|
+
|
61
|
+
<body>
|
62
|
+
</body>
|
63
|
+
</html>
|
@@ -0,0 +1,112 @@
|
|
1
|
+
describe("Custom Matchers", function() {
|
2
|
+
var env;
|
3
|
+
var fakeTimer;
|
4
|
+
|
5
|
+
beforeEach(function() {
|
6
|
+
env = new jasmine.Env();
|
7
|
+
env.updateInterval = 0;
|
8
|
+
});
|
9
|
+
|
10
|
+
it("should be easy to add more matchers local to a spec, suite, etc.", function() {
|
11
|
+
var spec1, spec2, spec1Matcher, spec2Matcher;
|
12
|
+
var suite = env.describe('some suite', function() {
|
13
|
+
env.beforeEach(function() {
|
14
|
+
this.addMatchers({ matcherForSuite: function(expected) {
|
15
|
+
return "matcherForSuite: actual: " + this.actual + "; expected: " + expected;
|
16
|
+
} });
|
17
|
+
});
|
18
|
+
|
19
|
+
spec1 = env.it('spec with an expectation').runs(function () {
|
20
|
+
this.addMatchers({ matcherForSpec: function(expected) {
|
21
|
+
return "matcherForSpec: actual: " + this.actual + "; expected: " + expected;
|
22
|
+
} });
|
23
|
+
spec1Matcher = this.expect("xxx");
|
24
|
+
});
|
25
|
+
|
26
|
+
spec2 = env.it('spec with failing expectation').runs(function () {
|
27
|
+
spec2Matcher = this.expect("yyy");
|
28
|
+
});
|
29
|
+
});
|
30
|
+
|
31
|
+
suite.execute();
|
32
|
+
|
33
|
+
expect(spec1Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: xxx; expected: expected");
|
34
|
+
expect(spec1Matcher.matcherForSpec("expected")).toEqual("matcherForSpec: actual: xxx; expected: expected");
|
35
|
+
|
36
|
+
expect(spec2Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: yyy; expected: expected");
|
37
|
+
expect(spec2Matcher.matcherForSpec).toBe(jasmine.undefined);
|
38
|
+
});
|
39
|
+
|
40
|
+
it("should generate messages with the same rules as for regular matchers when this.report() is not called", function() {
|
41
|
+
var spec;
|
42
|
+
var suite = env.describe('some suite', function() {
|
43
|
+
spec = env.it('spec with an expectation').runs(function () {
|
44
|
+
this.addMatchers({
|
45
|
+
toBeTrue: function() {
|
46
|
+
return this.actual === true;
|
47
|
+
}
|
48
|
+
});
|
49
|
+
this.expect(true).toBeTrue();
|
50
|
+
this.expect(false).toBeTrue();
|
51
|
+
});
|
52
|
+
});
|
53
|
+
|
54
|
+
suite.execute();
|
55
|
+
var passResult = new jasmine.ExpectationResult({passed: true, matcherName: 'toBeTrue',
|
56
|
+
actual: true, expected: jasmine.undefined, message: "Passed." });
|
57
|
+
var failResult = new jasmine.ExpectationResult({passed: false, matcherName: 'toBeTrue',
|
58
|
+
actual: false, expected: jasmine.undefined, message: "Expected false to be true." });
|
59
|
+
failResult.trace = jasmine.any(Object);
|
60
|
+
expect(spec.results().getItems()).toEqual([passResult, failResult]);
|
61
|
+
});
|
62
|
+
|
63
|
+
it("should pass args", function() {
|
64
|
+
var matcherCallArgs = [];
|
65
|
+
var spec;
|
66
|
+
var suite = env.describe('some suite', function() {
|
67
|
+
spec = env.it('spec with an expectation').runs(function () {
|
68
|
+
this.addMatchers({
|
69
|
+
toBeTrue: function() {
|
70
|
+
matcherCallArgs.push(jasmine.util.argsToArray(arguments));
|
71
|
+
return this.actual === true;
|
72
|
+
}
|
73
|
+
});
|
74
|
+
this.expect(true).toBeTrue();
|
75
|
+
this.expect(false).toBeTrue('arg');
|
76
|
+
this.expect(true).toBeTrue('arg1', 'arg2');
|
77
|
+
});
|
78
|
+
});
|
79
|
+
|
80
|
+
suite.execute();
|
81
|
+
var results = spec.results().getItems();
|
82
|
+
expect(results[0].expected).toEqual(jasmine.undefined);
|
83
|
+
expect(results[1].expected).toEqual('arg');
|
84
|
+
expect(results[2].expected).toEqual(['arg1', 'arg2']);
|
85
|
+
|
86
|
+
expect(matcherCallArgs).toEqual([[], ['arg'], ['arg1', 'arg2']]);
|
87
|
+
});
|
88
|
+
|
89
|
+
describe("in the old style", function() {
|
90
|
+
it("should report deprecation a warning", function() {
|
91
|
+
var spec;
|
92
|
+
var suite = env.describe('some suite', function() {
|
93
|
+
spec = env.it('spec with an expectation').runs(function () {
|
94
|
+
this.addMatchers({
|
95
|
+
toBeTrue: function() {
|
96
|
+
this.report(this.actual === true, this.actual + " was not true.", "details");
|
97
|
+
}
|
98
|
+
});
|
99
|
+
this.expect(true).toBeTrue();
|
100
|
+
this.expect(false).toBeTrue();
|
101
|
+
});
|
102
|
+
});
|
103
|
+
|
104
|
+
suite.execute();
|
105
|
+
var passResult = new jasmine.ExpectationResult({passed: true, message: "Passed.", details: "details"});
|
106
|
+
var failResult = new jasmine.ExpectationResult({passed: false, message: "false was not true.", details: "details"});
|
107
|
+
failResult.trace = jasmine.any(Object);
|
108
|
+
expect(spec.results().getItems()).toEqual([passResult, failResult]);
|
109
|
+
});
|
110
|
+
});
|
111
|
+
|
112
|
+
});
|
@@ -0,0 +1,71 @@
|
|
1
|
+
describe("jasmine.Env", function() {
|
2
|
+
var env;
|
3
|
+
beforeEach(function() {
|
4
|
+
env = new jasmine.Env();
|
5
|
+
env.updateInterval = 0;
|
6
|
+
});
|
7
|
+
|
8
|
+
describe('ids', function () {
|
9
|
+
|
10
|
+
it('nextSpecId should return consecutive integers, starting at 0', function () {
|
11
|
+
expect(env.nextSpecId()).toEqual(0);
|
12
|
+
expect(env.nextSpecId()).toEqual(1);
|
13
|
+
expect(env.nextSpecId()).toEqual(2);
|
14
|
+
});
|
15
|
+
|
16
|
+
});
|
17
|
+
describe("reporting", function() {
|
18
|
+
var fakeReporter;
|
19
|
+
|
20
|
+
beforeEach(function() {
|
21
|
+
fakeReporter = jasmine.createSpyObj("fakeReporter", ["log"]);
|
22
|
+
});
|
23
|
+
|
24
|
+
describe('version', function () {
|
25
|
+
var oldVersion;
|
26
|
+
|
27
|
+
beforeEach(function () {
|
28
|
+
oldVersion = jasmine.version_;
|
29
|
+
});
|
30
|
+
|
31
|
+
afterEach(function () {
|
32
|
+
jasmine.version_ = oldVersion;
|
33
|
+
});
|
34
|
+
|
35
|
+
it('should raise an error if version is not set', function () {
|
36
|
+
jasmine.version_ = null;
|
37
|
+
var exception;
|
38
|
+
try {
|
39
|
+
env.version();
|
40
|
+
}
|
41
|
+
catch (e) {
|
42
|
+
exception = e;
|
43
|
+
}
|
44
|
+
expect(exception.message).toEqual('Version not set');
|
45
|
+
|
46
|
+
});
|
47
|
+
|
48
|
+
it("version should return the current version as an int", function() {
|
49
|
+
jasmine.version_ = {
|
50
|
+
"major": 1,
|
51
|
+
"minor": 9,
|
52
|
+
"build": 7,
|
53
|
+
"revision": 8
|
54
|
+
};
|
55
|
+
expect(env.version()).toEqual({
|
56
|
+
"major": 1,
|
57
|
+
"minor": 9,
|
58
|
+
"build": 7,
|
59
|
+
"revision": 8
|
60
|
+
});
|
61
|
+
|
62
|
+
});
|
63
|
+
});
|
64
|
+
|
65
|
+
it("should allow reporters to be registered", function() {
|
66
|
+
env.addReporter(fakeReporter);
|
67
|
+
env.reporter.log("message");
|
68
|
+
expect(fakeReporter.log).wasCalledWith("message");
|
69
|
+
});
|
70
|
+
});
|
71
|
+
});
|
@@ -0,0 +1,107 @@
|
|
1
|
+
describe('Exceptions:', function() {
|
2
|
+
var env;
|
3
|
+
|
4
|
+
beforeEach(function() {
|
5
|
+
env = new jasmine.Env();
|
6
|
+
env.updateInterval = 0;
|
7
|
+
});
|
8
|
+
|
9
|
+
it('jasmine.formatException formats Firefox exception messages as expected', function() {
|
10
|
+
var sampleFirefoxException = {
|
11
|
+
fileName: 'foo.js',
|
12
|
+
line: '1978',
|
13
|
+
message: 'you got your foo in my bar',
|
14
|
+
name: 'A Classic Mistake'
|
15
|
+
};
|
16
|
+
|
17
|
+
var expected = 'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)';
|
18
|
+
|
19
|
+
expect(jasmine.util.formatException(sampleFirefoxException)).toEqual(expected);
|
20
|
+
});
|
21
|
+
|
22
|
+
it('jasmine.formatException formats Webkit exception messages as expected', function() {
|
23
|
+
var sampleWebkitException = {
|
24
|
+
sourceURL: 'foo.js',
|
25
|
+
lineNumber: '1978',
|
26
|
+
message: 'you got your foo in my bar',
|
27
|
+
name: 'A Classic Mistake'
|
28
|
+
};
|
29
|
+
|
30
|
+
var expected = 'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)';
|
31
|
+
|
32
|
+
expect(jasmine.util.formatException(sampleWebkitException)).toEqual(expected);
|
33
|
+
});
|
34
|
+
|
35
|
+
it('should handle exceptions thrown, but continue', function() {
|
36
|
+
var fakeTimer = new jasmine.FakeTimer();
|
37
|
+
env.setTimeout = fakeTimer.setTimeout;
|
38
|
+
env.clearTimeout = fakeTimer.clearTimeout;
|
39
|
+
env.setInterval = fakeTimer.setInterval;
|
40
|
+
env.clearInterval = fakeTimer.clearInterval;
|
41
|
+
|
42
|
+
//we run two exception tests to make sure we continue after throwing an exception
|
43
|
+
var suite = env.describe('Suite for handles exceptions', function () {
|
44
|
+
env.it('should be a test that fails because it throws an exception', function() {
|
45
|
+
throw new Error('fake error 1');
|
46
|
+
});
|
47
|
+
|
48
|
+
env.it('should be another test that fails because it throws an exception', function() {
|
49
|
+
this.runs(function () {
|
50
|
+
throw new Error('fake error 2');
|
51
|
+
});
|
52
|
+
this.runs(function () {
|
53
|
+
this.expect(true).toEqual(true);
|
54
|
+
});
|
55
|
+
});
|
56
|
+
|
57
|
+
env.it('should be a passing test that runs after exceptions are thrown', function() {
|
58
|
+
this.expect(true).toEqual(true);
|
59
|
+
});
|
60
|
+
|
61
|
+
env.it('should be another test that fails because it throws an exception after a wait', function() {
|
62
|
+
this.runs(function () {
|
63
|
+
var foo = 'foo';
|
64
|
+
});
|
65
|
+
this.waits(250);
|
66
|
+
this.runs(function () {
|
67
|
+
throw new Error('fake error 3');
|
68
|
+
});
|
69
|
+
});
|
70
|
+
|
71
|
+
env.it('should be a passing test that runs after exceptions are thrown from a async test', function() {
|
72
|
+
this.expect(true).toEqual(true);
|
73
|
+
});
|
74
|
+
});
|
75
|
+
|
76
|
+
var runner = env.currentRunner();
|
77
|
+
suite.execute();
|
78
|
+
fakeTimer.tick(2500);
|
79
|
+
|
80
|
+
var suiteResults = suite.results();
|
81
|
+
var specResults = suiteResults.getItems();
|
82
|
+
|
83
|
+
expect(suiteResults.passed()).toEqual(false);
|
84
|
+
//
|
85
|
+
expect(specResults.length).toEqual(5);
|
86
|
+
expect(specResults[0].passed()).toMatch(false);
|
87
|
+
var blockResults = specResults[0].getItems();
|
88
|
+
expect(blockResults[0].passed()).toEqual(false);
|
89
|
+
expect(blockResults[0].message).toMatch(/fake error 1/);
|
90
|
+
|
91
|
+
expect(specResults[1].passed()).toEqual(false);
|
92
|
+
var blockResults = specResults[1].getItems();
|
93
|
+
expect(blockResults[0].passed()).toEqual(false);
|
94
|
+
expect(blockResults[0].message).toMatch(/fake error 2/),
|
95
|
+
expect(blockResults[1].passed()).toEqual(true);
|
96
|
+
|
97
|
+
expect(specResults[2].passed()).toEqual(true);
|
98
|
+
|
99
|
+
expect(specResults[3].passed()).toEqual(false);
|
100
|
+
blockResults = specResults[3].getItems();
|
101
|
+
expect(blockResults[0].message).toMatch(/fake error 3/);
|
102
|
+
|
103
|
+
expect(specResults[4].passed()).toEqual(true);
|
104
|
+
|
105
|
+
});
|
106
|
+
|
107
|
+
});
|
@@ -0,0 +1,82 @@
|
|
1
|
+
describe('jasmine.jsApiReporter', function() {
|
2
|
+
|
3
|
+
|
4
|
+
describe('results', function () {
|
5
|
+
var reporter, spec1, spec2, spec3, expectedSpec1Results, expectedSpec2Results;
|
6
|
+
|
7
|
+
beforeEach(function() {
|
8
|
+
var env = new jasmine.Env();
|
9
|
+
env.updateInterval = 0;
|
10
|
+
var suite = new jasmine.Suite(env);
|
11
|
+
spec1 = new jasmine.Spec(env, suite, 'spec 1');
|
12
|
+
spec1.runs(function () {
|
13
|
+
this.expect(true).toEqual(true);
|
14
|
+
});
|
15
|
+
expectedSpec1Results = {
|
16
|
+
messages: spec1.results().getItems(),
|
17
|
+
result: "passed"
|
18
|
+
};
|
19
|
+
spec2 = new jasmine.Spec(env, suite, 'spec 2');
|
20
|
+
spec2.runs(function () {
|
21
|
+
this.expect(true).toEqual(false);
|
22
|
+
});
|
23
|
+
expectedSpec2Results = {
|
24
|
+
messages: spec2.results().getItems(),
|
25
|
+
result: "failed"
|
26
|
+
};
|
27
|
+
|
28
|
+
spec3 = new jasmine.Spec(env, suite, 'spec 3');
|
29
|
+
spec3.runs(function () {
|
30
|
+
this.log('some debug message')
|
31
|
+
});
|
32
|
+
|
33
|
+
spec1.execute();
|
34
|
+
spec2.execute();
|
35
|
+
spec3.execute();
|
36
|
+
|
37
|
+
reporter = new jasmine.JsApiReporter();
|
38
|
+
reporter.reportSpecResults(spec1);
|
39
|
+
reporter.reportSpecResults(spec2);
|
40
|
+
reporter.reportSpecResults(spec3);
|
41
|
+
});
|
42
|
+
|
43
|
+
it('resultForSpec() should return the result for the given spec', function () {
|
44
|
+
expect(reporter.resultsForSpec(spec1.id)).toEqual(expectedSpec1Results);
|
45
|
+
expect(reporter.resultsForSpec(spec2.id)).toEqual(expectedSpec2Results);
|
46
|
+
|
47
|
+
});
|
48
|
+
|
49
|
+
it('results() should return a hash of all results, indexed by spec id', function () {
|
50
|
+
expect(reporter.results()[spec1.id]).toEqual(expectedSpec1Results);
|
51
|
+
expect(reporter.results()[spec2.id]).toEqual(expectedSpec2Results);
|
52
|
+
});
|
53
|
+
|
54
|
+
describe("#summarizeResult_", function() {
|
55
|
+
it("should summarize a passing result", function() {
|
56
|
+
var result = reporter.results()[spec1.id];
|
57
|
+
var summarizedResult = reporter.summarizeResult_(result);
|
58
|
+
expect(summarizedResult.result).toEqual('passed');
|
59
|
+
expect(summarizedResult.messages.length).toEqual(1);
|
60
|
+
expect(summarizedResult.messages[0].message).toEqual(result.messages[0].message);
|
61
|
+
expect(summarizedResult.messages[0].passed).toBeTruthy();
|
62
|
+
expect(summarizedResult.messages[0].type).toEqual('ExpectationResult');
|
63
|
+
expect(summarizedResult.messages[0].text).toEqual(jasmine.undefined);
|
64
|
+
expect(summarizedResult.messages[0].trace.stack).toEqual(jasmine.undefined);
|
65
|
+
});
|
66
|
+
|
67
|
+
it("should have a stack trace for failing specs", function() {
|
68
|
+
var result = reporter.results()[spec2.id];
|
69
|
+
var summarizedResult = reporter.summarizeResult_(result);
|
70
|
+
expect(summarizedResult.result).toEqual('failed');
|
71
|
+
expect(summarizedResult.messages[0].trace.stack).toEqual(result.messages[0].trace.stack);
|
72
|
+
});
|
73
|
+
|
74
|
+
it("should have messages for specs with messages", function() {
|
75
|
+
var result = reporter.results()[spec3.id];
|
76
|
+
var summarizedResult = reporter.summarizeResult_(result);
|
77
|
+
expect(summarizedResult.result).toEqual('passed');
|
78
|
+
expect(summarizedResult.messages[0].text).toEqual('some debug message');
|
79
|
+
});
|
80
|
+
});
|
81
|
+
});
|
82
|
+
});
|