gaffo-jasmine_webos 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2
+ <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
5
+ <title>Jasmine suite</title>
6
+ <% css_files.each do |css_file| %>
7
+ <link rel="stylesheet" href="<%= css_file %>" type="text/css" media="screen" />
8
+ <% end %>
9
+
10
+ <% jasmine_files.each do |jasmine_file| %>
11
+ <script src="<%= jasmine_file %>" type="text/javascript"></script>
12
+ <% end %>
13
+
14
+ <script type="text/javascript">
15
+ var jsApiReporter;
16
+ (function() {
17
+ var jasmineEnv = jasmine.getEnv();
18
+ jasmineEnv.updateInterval = 1000;
19
+
20
+ jsApiReporter = new jasmine.JsApiReporter();
21
+ var trivialReporter = new jasmine.TrivialReporter();
22
+
23
+ jasmineEnv.addReporter(jsApiReporter);
24
+ jasmineEnv.addReporter(trivialReporter);
25
+
26
+ jasmineEnv.specFilter = function(spec) {
27
+ return trivialReporter.specFilter(spec);
28
+ };
29
+
30
+ window.onload = function() {
31
+ jasmineEnv.execute();
32
+ };
33
+ })();
34
+ </script>
35
+
36
+ <% spec_files.each do |spec_file| %>
37
+ <script src="<%= spec_file %>" type="text/javascript"></script>
38
+ <% end %>
39
+
40
+ </head>
41
+ <body>
42
+ <div id="jasmine_content"></div>
43
+ </body>
44
+ </html>
@@ -0,0 +1,51 @@
1
+ require 'spec'
2
+ require 'open-uri'
3
+ require File.dirname(__FILE__) + '/../jasmine_runner'
4
+
5
+ describe Jasmine::SimpleServer do
6
+ before do
7
+ @port = Jasmine::find_unused_port
8
+ end
9
+
10
+ after do
11
+ Jasmine::kill_process_group(@jasmine_server_pid) if @jasmine_server_pid
12
+ end
13
+
14
+ it "should start and print script tags" do
15
+ @jasmine_server_pid = fork do
16
+ Process.setpgrp
17
+ Jasmine::SimpleServer.start(@port, ["file1", "file2"], {})
18
+ exit! 0
19
+ end
20
+
21
+ Jasmine::wait_for_listener(@port)
22
+
23
+ run_html = open("http://localhost:#{@port}/").read
24
+ run_html.should =~ /<script src="file1"/
25
+ run_html.should =~ /<script src="file2"/
26
+ end
27
+
28
+ it "should take a proc that returns a list of spec files" do
29
+ spec_fileses = [["file1", "file2"], ["file1", "file2", "file3"]]
30
+ spec_files_proc = lambda do
31
+ spec_fileses.shift
32
+ end
33
+
34
+ @jasmine_server_pid = fork do
35
+ Process.setpgrp
36
+ Jasmine::SimpleServer.start(@port, spec_files_proc, {})
37
+ exit! 0
38
+ end
39
+
40
+ Jasmine::wait_for_listener(@port)
41
+
42
+ run_html = open("http://localhost:#{@port}/").read
43
+ run_html.should =~ /<script src="file1"/
44
+ run_html.should =~ /<script src="file2"/
45
+
46
+ run_html = open("http://localhost:#{@port}/").read
47
+ run_html.should =~ /<script src="file1"/
48
+ run_html.should =~ /<script src="file2"/
49
+ run_html.should =~ /<script src="file3"/
50
+ end
51
+ end
@@ -0,0 +1,125 @@
1
+ jasmine.TrivialReporter = function(doc) {
2
+ this.document = doc || document;
3
+ this.suiteDivs = {};
4
+ };
5
+
6
+ jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
7
+ var el = document.createElement(type);
8
+
9
+ for (var i = 2; i < arguments.length; i++) {
10
+ var child = arguments[i];
11
+
12
+ if (typeof child === 'string') {
13
+ el.appendChild(document.createTextNode(child));
14
+ } else {
15
+ el.appendChild(child);
16
+ }
17
+ }
18
+
19
+ for (var attr in attrs) {
20
+ if (attr == 'className') {
21
+ el.setAttribute('class', attrs[attr]);
22
+ } else {
23
+ el[attr] = attrs[attr];
24
+ }
25
+ }
26
+
27
+ return el;
28
+ };
29
+
30
+ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
31
+ var suites = runner.suites();
32
+
33
+ this.runnerDiv = this.createDom('div', { className: 'runner running' },
34
+ this.createDom('a', { className: 'runSpec', href: '?' }, "run all"),
35
+ this.runnerMessageSpan = this.createDom('span', {}, "Running..."));
36
+ this.document.body.appendChild(this.runnerDiv);
37
+
38
+ for (var i = 0; i < suites.length; i++) {
39
+ var suite = suites[i];
40
+ var suiteDiv = this.createDom('div', { className: 'suite' },
41
+ this.createDom('a', { className: 'runSpec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
42
+ suite.description);
43
+ this.suiteDivs[suite.getFullName()] = suiteDiv;
44
+ var parentDiv = this.document.body;
45
+ if (suite.parentSuite) {
46
+ parentDiv = this.suiteDivs[suite.parentSuite.getFullName()];
47
+ }
48
+ parentDiv.appendChild(suiteDiv);
49
+ }
50
+
51
+ this.startedAt = new Date();
52
+ };
53
+
54
+ jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
55
+ var results = runner.getResults();
56
+ var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
57
+ this.runnerDiv.setAttribute("class", className);
58
+ var message = results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
59
+ message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
60
+ this.runnerMessageSpan.replaceChild(this.document.createTextNode(message), this.runnerMessageSpan.firstChild);
61
+ };
62
+
63
+ jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
64
+ var results = suite.getResults();
65
+ var status = results.passed() ? 'passed' : 'failed';
66
+ if (results.totalCount == 0) { // todo: change this to check results.skipped
67
+ status = 'skipped';
68
+ }
69
+ this.suiteDivs[suite.getFullName()].className += " " + status;
70
+ };
71
+
72
+ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
73
+ var results = spec.getResults();
74
+ var status = results.passed() ? 'passed' : 'failed';
75
+ if (results.skipped) {
76
+ status = 'skipped';
77
+ }
78
+ var specDiv = this.createDom('div', { className: 'spec ' + status },
79
+ this.createDom('a', { className: 'runSpec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
80
+ spec.getFullName());
81
+
82
+
83
+ var resultItems = results.getItems();
84
+ for (var i = 0; i < resultItems.length; i++) {
85
+ var result = resultItems[i];
86
+ if (result.passed && !result.passed()) {
87
+ var resultMessageDiv = this.createDom('div', {className: 'resultMessage fail'});
88
+ resultMessageDiv.innerHTML = result.message; // todo: lame; mend
89
+ specDiv.appendChild(resultMessageDiv);
90
+ specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
91
+ }
92
+ }
93
+
94
+ this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv);
95
+ };
96
+
97
+ jasmine.TrivialReporter.prototype.log = function() {
98
+ console.log.apply(console, arguments);
99
+ };
100
+
101
+ jasmine.TrivialReporter.prototype.getLocation = function() {
102
+ return this.document.location;
103
+ };
104
+
105
+ jasmine.TrivialReporter.prototype.specFilter = function(spec) {
106
+ var paramMap = {};
107
+ var params = this.getLocation().search.substring(1).split('&');
108
+ for (var i = 0; i < params.length; i++) {
109
+ var p = params[i].split('=');
110
+ paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
111
+ }
112
+
113
+ if (!paramMap["spec"]) return true;
114
+ return spec.getFullName().indexOf(paramMap["spec"]) == 0;
115
+ };
116
+
117
+ //protect against console.log incidents
118
+ if (!("console" in window) || !("firebug" in console)) {
119
+ var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
120
+ window.console = {};
121
+ for (var i = 0, len = names.length; i < len; ++i) {
122
+ window.console[names[i]] = function() {
123
+ };
124
+ }
125
+ }