jasmine-headless-webkit 0.7.3.1 → 0.7.3.2

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.
Files changed (53) hide show
  1. data/Guardfile +3 -2
  2. data/bin/jasmine-headless-webkit +1 -1
  3. data/ext/jasmine-webkit-specrunner/Page.cpp +8 -21
  4. data/ext/jasmine-webkit-specrunner/Page.h +11 -15
  5. data/ext/jasmine-webkit-specrunner/Runner.cpp +86 -110
  6. data/ext/jasmine-webkit-specrunner/Runner.h +23 -26
  7. data/ext/jasmine-webkit-specrunner/common.pri +2 -2
  8. data/ext/jasmine-webkit-specrunner/specrunner.cpp +0 -1
  9. data/ext/jasmine-webkit-specrunner/specrunner.pro +1 -0
  10. data/lib/jasmine/files_list.rb +24 -24
  11. data/lib/jasmine/headless.rb +1 -1
  12. data/lib/jasmine/headless/spec_file_analyzer.rb +1 -1
  13. data/lib/jasmine/headless/version.rb +1 -1
  14. data/lib/qt/qmake.rb +1 -5
  15. data/skel/template.html.erb +8 -45
  16. data/spec/files/UTF-8-test.txt +0 -0
  17. data/spec/javascripts/headless_reporter_result_spec.coffee +14 -0
  18. data/spec/javascripts/{jasmine.headless-reporter_spec.coffee → jasmine.HeadlessConsoleReporter_spec.coffee} +2 -2
  19. data/spec/javascripts/support/jasmine.yml +1 -1
  20. data/spec/lib/jasmine/files_list_spec.rb +6 -3
  21. data/spec/lib/jasmine/headless/spec_file_analyzer_spec.rb +41 -30
  22. data/spec/lib/qt/qmake_spec.rb +0 -6
  23. data/vendor/assets/coffeescripts/headless_reporter_result.coffee +46 -0
  24. data/vendor/assets/coffeescripts/intense.coffee +27 -0
  25. data/{jasmine/jasmine.headless-reporter.coffee → vendor/assets/coffeescripts/jasmine-extensions.coffee} +5 -90
  26. data/vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee +86 -0
  27. data/vendor/assets/coffeescripts/prolog.coffee +73 -0
  28. data/{js-lib → vendor/assets/javascripts}/beautify-html.js +0 -0
  29. data/vendor/assets/javascripts/headless_reporter_result.js +72 -0
  30. data/vendor/assets/javascripts/intense.js +37 -0
  31. data/vendor/assets/javascripts/jasmine-extensions.js +101 -0
  32. data/vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js +96 -0
  33. data/{js-lib → vendor/assets/javascripts}/jsDump.js +0 -0
  34. data/vendor/assets/javascripts/prolog.js +89 -0
  35. metadata +28 -33
  36. data/dev-bin/hooks/pre-commit +0 -5
  37. data/dev-bin/install-hooks +0 -6
  38. data/ext/jasmine-webkit-specrunner/ConsoleOutput.cpp +0 -149
  39. data/ext/jasmine-webkit-specrunner/ConsoleOutput.h +0 -39
  40. data/ext/jasmine-webkit-specrunner/ConsoleOutput_test.cpp +0 -129
  41. data/ext/jasmine-webkit-specrunner/ConsoleOutput_test.h +0 -32
  42. data/ext/jasmine-webkit-specrunner/ConsoleOutput_test.pro +0 -7
  43. data/ext/jasmine-webkit-specrunner/Page_test.cpp +0 -43
  44. data/ext/jasmine-webkit-specrunner/Page_test.h +0 -27
  45. data/ext/jasmine-webkit-specrunner/Page_test.pro +0 -6
  46. data/ext/jasmine-webkit-specrunner/ReportFileOutput.cpp +0 -54
  47. data/ext/jasmine-webkit-specrunner/ReportFileOutput.h +0 -37
  48. data/ext/jasmine-webkit-specrunner/ReportFileOutput_test.cpp +0 -88
  49. data/ext/jasmine-webkit-specrunner/ReportFileOutput_test.h +0 -26
  50. data/ext/jasmine-webkit-specrunner/ReportFileOutput_test.pro +0 -7
  51. data/ext/jasmine-webkit-specrunner/test.pri +0 -3
  52. data/ext/jasmine-webkit-specrunner/test.rb +0 -31
  53. data/jasmine/jasmine.headless-reporter.js +0 -231
@@ -2,7 +2,7 @@ if !jasmine?
2
2
  throw new Error("jasmine not laoded!")
3
3
 
4
4
  if window.JHW
5
- # Jasmine extensions
5
+ # Jasmine extensions
6
6
  getSplitName = (parts) ->
7
7
  parts.push(String(@description).replace(/[\n\r]/g, ' '))
8
8
  parts
@@ -25,6 +25,10 @@ if window.JHW
25
25
  parts.push('')
26
26
  parts.join("||")
27
27
 
28
+ jasmine.Spec.prototype.finishCallback = ->
29
+ JHW.ping()
30
+ this.env.reporter.reportSpecResults(this)
31
+
28
32
  jasmine.Spec.prototype.fail = (e) ->
29
33
  if e and e.sourceURL and window.CoffeeScriptToFilename
30
34
  filename = e.sourceURL.split('/').pop()
@@ -84,92 +88,3 @@ if window.JHW
84
88
  result.expectations = jasmine.NestedResults.parseAndStore(arguments.callee.caller.caller.caller.toString())
85
89
 
86
90
  this.addResult_(result)
87
-
88
- # Try to get the line number of a failed spec
89
- class window.HeadlessReporterResult
90
- constructor: (@name, @splitName) ->
91
- @results = []
92
- addResult: (message) ->
93
- @results.push(message)
94
- print: ->
95
- output = @name
96
- bestChoice = HeadlessReporterResult.findSpecLine(@splitName)
97
- output += " (#{bestChoice.file}:#{bestChoice.lineNumber})" if bestChoice.file
98
-
99
- JHW.printName(output)
100
- for result in @results
101
- output = result.message
102
- if result.lineNumber
103
- output += " (line ~#{bestChoice.lineNumber + result.lineNumber})\n #{result.line}"
104
- JHW.printResult(output)
105
- @findSpecLine: (splitName) ->
106
- bestChoice = { accuracy: 0, file: null, lineNumber: null }
107
-
108
- for file, lines of HeadlessReporterResult.specLineNumbers
109
- index = 0
110
- lineNumber = 0
111
- while newLineNumberInfo = lines[splitName[index]]
112
- if newLineNumberInfo.length == 0
113
- lineNumber = newLineNumberInfo[0]
114
- else
115
- lastLine = null
116
- for line in newLineNumberInfo
117
- lastLine = line
118
- break if line > lineNumber
119
-
120
- lineNumber = lastLine
121
-
122
- index++
123
-
124
- if index > bestChoice.accuracy
125
- bestChoice = { accuracy: index, file: file, lineNumber: lineNumber }
126
-
127
- bestChoice
128
-
129
- # The reporter itself.
130
- class jasmine.HeadlessReporter
131
- constructor: (@callback = null) ->
132
- @results = []
133
- @failedCount = 0
134
- @length = 0
135
- reportRunnerResults: (runner) ->
136
- return if this.hasError()
137
-
138
- for result in @results
139
- result.print()
140
-
141
- this.callback() if @callback
142
- JHW.finishSuite((new Date() - @startTime) / 1000.0, @length, @failedCount)
143
-
144
- reportRunnerStarting: (runner) ->
145
- @startTime = new Date()
146
-
147
- reportSpecResults: (spec) ->
148
- return if this.hasError()
149
-
150
- results = spec.results()
151
- @length++
152
- if results.passed()
153
- JHW.specPassed(spec.getJHWSpecInformation())
154
- else
155
- JHW.specFailed(spec.getJHWSpecInformation())
156
- @failedCount++
157
- failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName())
158
- testCount = 1
159
- for result in results.getItems()
160
- if result.type == 'expect' and !result.passed_
161
- if foundLine = result.expectations[testCount - 1]
162
- [ result.line, result.lineNumber ] = foundLine
163
- failureResult.addResult(result)
164
- testCount += 1
165
- @results.push(failureResult)
166
-
167
- reportSpecStarting: (spec) ->
168
- if this.hasError()
169
- spec.finish()
170
- spec.suite.finish()
171
-
172
- reportSuiteResults: (suite) ->
173
- hasError: ->
174
- JHW.hasError()
175
-
@@ -0,0 +1,86 @@
1
+ if !jasmine?
2
+ throw new Error("jasmine not loaded!")
3
+
4
+ class jasmine.HeadlessConsoleReporter
5
+ constructor: (@callback = null) ->
6
+ @results = []
7
+ @failedCount = 0
8
+ @length = 0
9
+
10
+ reportRunnerResults: (runner) ->
11
+ return if this.hasError()
12
+
13
+ runtime = (new Date() - @startTime) / 1000.0
14
+
15
+ JHW.stdout.print("\n")
16
+
17
+ resultLine = this._formatResultLine(runtime)
18
+
19
+ if @failedCount == 0
20
+ JHW.stdout.puts("PASS: #{resultLine}".foreground('green'))
21
+ else
22
+ JHW.stdout.puts("FAIL: #{resultLine}".foreground('red'))
23
+ JHW.hasSpecFailure()
24
+
25
+ output = "TOTAL||#{@length}||#{@failedCount}||#{runtime}||#{if JHW._hasErrors then "T" else "F"}"
26
+
27
+ JHW.report.puts(output)
28
+ result.print() for result in @results
29
+
30
+ if window.JHW
31
+ window.onbeforeunload = null
32
+
33
+ JHW.finishSuite()
34
+
35
+ reportRunnerStarting: (runner) ->
36
+ @startTime = new Date()
37
+ JHW.stdout.puts("\nRunning Jasmine specs...".bright())
38
+
39
+ reportSpecResults: (spec) ->
40
+ return if this.hasError()
41
+ JHW.ping()
42
+
43
+ results = spec.results()
44
+
45
+ @length++
46
+ if results.passed()
47
+ JHW.stdout.print('.'.foreground('green'))
48
+ JHW.report.puts("PASS||" + spec.getJHWSpecInformation())
49
+ else
50
+ JHW.stdout.print('F'.foreground('red'))
51
+ JHW.report.puts("FAIL||" + spec.getJHWSpecInformation())
52
+
53
+ @failedCount++
54
+ failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName())
55
+ testCount = 1
56
+
57
+ for result in results.getItems()
58
+ if result.type == 'expect' and !result.passed_
59
+ if foundLine = result.expectations[testCount - 1]
60
+ [ result.line, result.lineNumber ] = foundLine
61
+ failureResult.addResult(result)
62
+ testCount += 1
63
+ @results.push(failureResult)
64
+
65
+ reportSpecStarting: (spec) ->
66
+ if this.hasError()
67
+ spec.finish()
68
+ spec.suite.finish()
69
+
70
+ reportSuiteResults: (suite) ->
71
+ hasError: ->
72
+ JHW._hasErrors
73
+
74
+ _formatResultLine: (runtime) ->
75
+ line = []
76
+ line.push(@length)
77
+ line.push((if @length == 1 then "test" else "tests") + ',')
78
+
79
+ line.push(@failedCount)
80
+ line.push((if @failedCount == 1 then "failure" else "failures") + ',')
81
+
82
+ line.push(runtime)
83
+ line.push((if runtime == 1.0 then "sec" else "secs") + '.')
84
+
85
+ line.join(' ')
86
+
@@ -0,0 +1,73 @@
1
+ if window.JHW
2
+ window.console =
3
+ log: (data) ->
4
+ if typeof(jQuery) != 'undefined' && data instanceof jQuery
5
+ JHW.log(style_html($("<div />").append(data).html(), { indent_size: 2 }))
6
+ else
7
+ useJsDump = true
8
+
9
+ try
10
+ if typeof data.toJSON == 'function'
11
+ JHW.log("JSON: #{JSON.stringify(data, null, 2)}")
12
+ useJsDump = false
13
+ catch e
14
+
15
+ if useJsDump
16
+ dump = jsDump.doParse(data)
17
+ if dump.indexOf("\n") == -1
18
+ JHW.log(dump)
19
+ else
20
+ JHW.log("jsDump: #{dump}")
21
+
22
+ pp: (data) ->
23
+ JHW.log(if jasmine then jasmine.pp(data) else console.log(data))
24
+
25
+ peek: (data) ->
26
+ console.log(data)
27
+ data
28
+
29
+ window.onbeforeunload = (e) ->
30
+ e = e || window.event
31
+
32
+ JHW.hasError()
33
+ JHW.stdout.puts('The code tried to leave the test page. Check for unhandled form submits and link clicks.')
34
+
35
+ if e
36
+ e.returnValue = 'string'
37
+
38
+ return 'string'
39
+
40
+ window.confirm = (message) ->
41
+ JHW.stderr.puts("#{"[confirm]".foreground('red')} jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm. Returning true.")
42
+ true
43
+
44
+ window.alert = (message) ->
45
+ JHW.stderr.puts("[alert] ".foreground('red') + message)
46
+
47
+ JHW._hasErrors = false
48
+ JHW._handleError = (message, lineNumber, sourceURL) ->
49
+ JHW.stderr.puts(message)
50
+ JHW._hasErrors = true
51
+ false
52
+
53
+ JHW._setColors = (useColors) ->
54
+ Intense.useColors = useColors
55
+
56
+ createHandle = (handle) ->
57
+ JHW[handle] =
58
+ print: (content) -> JHW.print(handle, content)
59
+ puts: (content) -> JHW.print(handle, content + "\n")
60
+
61
+ createHandle(handle) for handle in [ 'stdout', 'stderr', 'report' ]
62
+
63
+ JHW._usedConsole = false
64
+
65
+ JHW.log = (msg) ->
66
+ JHW.hasUsedConsole()
67
+ JHW.report.puts("CONSOLE||#{msg}")
68
+ JHW._usedConsole = true
69
+ JHW.stdout.puts(msg)
70
+
71
+ window.CoffeeScriptToFilename = {}
72
+ window.CSTF = window.CoffeeScriptToFilename
73
+
@@ -0,0 +1,72 @@
1
+ (function() {
2
+ window.HeadlessReporterResult = (function() {
3
+ function HeadlessReporterResult(name, splitName) {
4
+ this.name = name;
5
+ this.splitName = splitName;
6
+ this.results = [];
7
+ }
8
+ HeadlessReporterResult.prototype.addResult = function(message) {
9
+ return this.results.push(message);
10
+ };
11
+ HeadlessReporterResult.prototype.print = function() {
12
+ var bestChoice, output, result, _i, _len, _ref, _results;
13
+ output = this.name.foreground('red');
14
+ bestChoice = HeadlessReporterResult.findSpecLine(this.splitName);
15
+ if (bestChoice.file) {
16
+ output += (" (" + bestChoice.file + ":" + bestChoice.lineNumber + ")").foreground('blue');
17
+ }
18
+ JHW.stdout.puts("\n\n" + output);
19
+ _ref = this.results;
20
+ _results = [];
21
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
22
+ result = _ref[_i];
23
+ output = result.message.foreground('red');
24
+ if (result.lineNumber) {
25
+ output += (" (line ~" + (bestChoice.lineNumber + result.lineNumber) + ")").foreground('red').bright();
26
+ }
27
+ JHW.stdout.puts(" " + output);
28
+ _results.push(result.line != null ? JHW.stdout.puts((" " + result.line).foreground('yellow')) : void 0);
29
+ }
30
+ return _results;
31
+ };
32
+ HeadlessReporterResult.findSpecLine = function(splitName) {
33
+ var bestChoice, file, index, lastLine, line, lineNumber, lines, newLineNumberInfo, _i, _len, _ref;
34
+ bestChoice = {
35
+ accuracy: 0,
36
+ file: null,
37
+ lineNumber: null
38
+ };
39
+ _ref = HeadlessReporterResult.specLineNumbers;
40
+ for (file in _ref) {
41
+ lines = _ref[file];
42
+ index = 0;
43
+ lineNumber = 0;
44
+ while (newLineNumberInfo = lines[splitName[index]]) {
45
+ if (newLineNumberInfo.length === 0) {
46
+ lineNumber = newLineNumberInfo[0];
47
+ } else {
48
+ lastLine = null;
49
+ for (_i = 0, _len = newLineNumberInfo.length; _i < _len; _i++) {
50
+ line = newLineNumberInfo[_i];
51
+ lastLine = line;
52
+ if (line > lineNumber) {
53
+ break;
54
+ }
55
+ }
56
+ lineNumber = lastLine;
57
+ }
58
+ index++;
59
+ }
60
+ if (index > bestChoice.accuracy) {
61
+ bestChoice = {
62
+ accuracy: index,
63
+ file: file,
64
+ lineNumber: lineNumber
65
+ };
66
+ }
67
+ }
68
+ return bestChoice;
69
+ };
70
+ return HeadlessReporterResult;
71
+ })();
72
+ }).call(this);
@@ -0,0 +1,37 @@
1
+ (function() {
2
+ var code, method, _ref;
3
+ window.Intense = {
4
+ colors: {
5
+ black: 0,
6
+ red: 1,
7
+ green: 2,
8
+ yellow: 3,
9
+ blue: 4,
10
+ magenta: 5,
11
+ cyan: 6,
12
+ white: 7
13
+ },
14
+ methods: {
15
+ foreground: function(color) {
16
+ if (Intense.useColors) {
17
+ return "\033[3" + Intense.colors[color] + "m" + this + "\033[0m";
18
+ } else {
19
+ return this;
20
+ }
21
+ },
22
+ bright: function() {
23
+ if (Intense.useColors) {
24
+ return "\033[1m" + this + "\033[0m";
25
+ } else {
26
+ return this;
27
+ }
28
+ }
29
+ },
30
+ useColors: true
31
+ };
32
+ _ref = Intense.methods;
33
+ for (method in _ref) {
34
+ code = _ref[method];
35
+ String.prototype[method] = code;
36
+ }
37
+ }).call(this);
@@ -0,0 +1,101 @@
1
+ (function() {
2
+ var getSplitName, pauseAndRun;
3
+ if (!(typeof jasmine !== "undefined" && jasmine !== null)) {
4
+ throw new Error("jasmine not laoded!");
5
+ }
6
+ if (window.JHW) {
7
+ getSplitName = function(parts) {
8
+ parts.push(String(this.description).replace(/[\n\r]/g, ' '));
9
+ return parts;
10
+ };
11
+ jasmine.Suite.prototype.getSuiteSplitName = function() {
12
+ return this.getSplitName(this.parentSuite ? this.parentSuite.getSuiteSplitName() : []);
13
+ };
14
+ jasmine.Spec.prototype.getSpecSplitName = function() {
15
+ return this.getSplitName(this.suite.getSuiteSplitName());
16
+ };
17
+ jasmine.Suite.prototype.getSplitName = getSplitName;
18
+ jasmine.Spec.prototype.getSplitName = getSplitName;
19
+ jasmine.Spec.prototype.getJHWSpecInformation = function() {
20
+ var parts, specLineInfo;
21
+ parts = this.getSpecSplitName();
22
+ specLineInfo = HeadlessReporterResult.findSpecLine(parts);
23
+ if (specLineInfo.file) {
24
+ parts.push("" + specLineInfo.file + ":" + specLineInfo.lineNumber);
25
+ } else {
26
+ parts.push('');
27
+ }
28
+ return parts.join("||");
29
+ };
30
+ jasmine.Spec.prototype.finishCallback = function() {
31
+ JHW.ping();
32
+ return this.env.reporter.reportSpecResults(this);
33
+ };
34
+ jasmine.Spec.prototype.fail = function(e) {
35
+ var expectationResult, filename, realFilename;
36
+ if (e && e.sourceURL && window.CoffeeScriptToFilename) {
37
+ filename = e.sourceURL.split('/').pop();
38
+ if (realFilename = window.CoffeeScriptToFilename[filename]) {
39
+ e = {
40
+ name: e.name,
41
+ message: e.message,
42
+ lineNumber: "~" + String(e.line),
43
+ sourceURL: realFilename
44
+ };
45
+ }
46
+ }
47
+ expectationResult = new jasmine.ExpectationResult({
48
+ passed: false,
49
+ message: e ? jasmine.util.formatException(e) : 'Exception',
50
+ trace: {
51
+ stack: e.stack
52
+ }
53
+ });
54
+ return this.results_.addResult(expectationResult);
55
+ };
56
+ jasmine.NestedResults.isValidSpecLine = function(line) {
57
+ return line.match(/^\s*expect/) !== null || line.match(/^\s*return\s*expect/) !== null;
58
+ };
59
+ jasmine.NestedResults.parseFunction = function(func) {
60
+ var line, lineCount, lines, _i, _len, _ref;
61
+ lines = [];
62
+ lineCount = 0;
63
+ _ref = func.split("\n");
64
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
65
+ line = _ref[_i];
66
+ if (jasmine.NestedResults.isValidSpecLine(line)) {
67
+ line = line.replace(/^\s*/, '').replace(/\s*$/, '').replace(/^return\s*/, '');
68
+ lines.push([line, lineCount]);
69
+ }
70
+ lineCount += 1;
71
+ }
72
+ return lines;
73
+ };
74
+ jasmine.NestedResults.parseAndStore = function(func) {
75
+ if (!jasmine.NestedResults.ParsedFunctions[func]) {
76
+ jasmine.NestedResults.ParsedFunctions[func] = jasmine.NestedResults.parseFunction(func);
77
+ }
78
+ return jasmine.NestedResults.ParsedFunctions[func];
79
+ };
80
+ jasmine.NestedResults.ParsedFunctions = [];
81
+ if (!jasmine.WaitsBlock.prototype._execute) {
82
+ jasmine.WaitsBlock.prototype._execute = jasmine.WaitsBlock.prototype.execute;
83
+ jasmine.WaitsForBlock.prototype._execute = jasmine.WaitsForBlock.prototype.execute;
84
+ pauseAndRun = function(onComplete) {
85
+ JHW.timerPause();
86
+ return this._execute(function() {
87
+ JHW.timerDone();
88
+ return onComplete();
89
+ });
90
+ };
91
+ jasmine.WaitsBlock.prototype.execute = pauseAndRun;
92
+ jasmine.WaitsForBlock.prototype.execute = pauseAndRun;
93
+ jasmine.NestedResults.prototype.addResult_ = jasmine.NestedResults.prototype.addResult;
94
+ jasmine.NestedResults.prototype.addResult = function(result) {
95
+ result.expectations = [];
96
+ result.expectations = jasmine.NestedResults.parseAndStore(arguments.callee.caller.caller.caller.toString());
97
+ return this.addResult_(result);
98
+ };
99
+ }
100
+ }
101
+ }).call(this);