jasmine-headless-webkit 0.7.3.1 → 0.7.3.2

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -4,6 +4,6 @@ QMAKE_INFO_PLIST = Info.plist
4
4
  QMAKESPEC = macx-g++
5
5
  QT += network webkit
6
6
 
7
- SOURCES = Page.cpp Runner.cpp ConsoleOutput.cpp ReportFileOutput.cpp
8
- HEADERS = Page.h Runner.h ConsoleOutput.h ReportFileOutput.h
7
+ SOURCES = Page.cpp Runner.cpp
8
+ HEADERS = Page.h Runner.h
9
9
 
@@ -21,7 +21,6 @@
21
21
  THE SOFTWARE.
22
22
  */
23
23
 
24
- #include "Page.h"
25
24
  #include "Runner.h"
26
25
 
27
26
  #if QT_VERSION < QT_VERSION_CHECK(4, 7, 0)
@@ -2,3 +2,4 @@ include(common.pri)
2
2
 
3
3
  SOURCES += specrunner.cpp
4
4
  TARGET = jasmine-webkit-specrunner
5
+
@@ -6,14 +6,30 @@ module Jasmine
6
6
  class FilesList
7
7
  attr_reader :files, :spec_files, :filtered_files, :spec_outside_scope
8
8
 
9
+ class << self
10
+ def find_vendored_asset_paths(*names)
11
+ require 'rubygems'
12
+
13
+ raise StandardError.new("A newer version of Rubygems is required to use vendored assets. Please upgrade.") if !Gem::Specification.respond_to?(:map)
14
+ all_spec_files.find_all do |file|
15
+ names.any? { |name| file["/#{name}.js"] }
16
+ end
17
+ end
18
+
19
+ def all_spec_files
20
+ @all_spec_files ||= Gem::Specification.map { |spec| spec.files.find_all { |file|
21
+ file["vendor/assets/javascripts"]
22
+ }.compact.collect { |file| File.join(spec.gem_dir, file) } }.flatten
23
+ end
24
+ end
25
+
9
26
  DEFAULT_FILES = [
10
27
  File.join(Jasmine::Core.path, "jasmine.js"),
11
28
  File.join(Jasmine::Core.path, "jasmine-html.js"),
12
- File.join(Jasmine::Core.path, "jasmine.css"),
13
- Jasmine::Headless.root.join('jasmine/jasmine.headless-reporter.js').to_s,
14
- Jasmine::Headless.root.join('js-lib/jsDump.js').to_s,
15
- Jasmine::Headless.root.join('js-lib/beautify-html.js').to_s
16
- ]
29
+ File.join(Jasmine::Core.path, "jasmine.css")
30
+ ] + %w{jasmine-extensions intense headless_reporter_result jasmine.HeadlessConsoleReporter jsDump beautify-html}.collect { |name|
31
+ Jasmine::Headless.root.join("vendor/assets/javascripts/#{name}.js").to_s
32
+ }
17
33
 
18
34
  PLEASE_WAIT_IM_WORKING_TIME = 2
19
35
 
@@ -72,13 +88,10 @@ module Jasmine
72
88
  cache = Jasmine::Headless::CoffeeScriptCache.new(file)
73
89
  source = cache.handle
74
90
  if cache.cached?
75
- %{
76
- <script type="text/javascript" src="#{cache.cache_file}"></script>S
91
+ %{<script type="text/javascript" src="#{cache.cache_file}"></script>
77
92
  <script type="text/javascript">
78
- window.CoffeeScriptToFilename = window.CoffeeScriptToFilename || {};
79
- window.CoffeeScriptToFilename['#{File.split(cache.cache_file).last}'] = '#{file}';
80
- </script>
81
- }
93
+ window.CSTF['#{File.split(cache.cache_file).last}'] = '#{file}';
94
+ </script>}
82
95
  else
83
96
  %{<script type="text/javascript">#{source}</script>}
84
97
  end
@@ -158,19 +171,6 @@ module Jasmine
158
171
  def expanded_dir(path)
159
172
  Dir[path].collect { |file| File.expand_path(file) }
160
173
  end
161
-
162
- def self.find_vendored_asset_path(name)
163
- require 'rubygems'
164
-
165
- raise StandardError.new("A newer version of Rubygems is required to use vendored assets. Please upgrade.") if !Gem::Specification.respond_to?(:map)
166
- all_spec_files.find_all { |file| file["vendor/assets/javascripts/#{name}.js"] }
167
- end
168
-
169
- def self.all_spec_files
170
- @all_spec_files ||= Gem::Specification.map { |spec| spec.files.find_all { |file|
171
- file["vendor/assets/javascripts"]
172
- }.compact.collect { |file| File.join(spec.gem_dir, file) } }.flatten
173
- end
174
174
  end
175
175
  end
176
176
 
@@ -16,7 +16,7 @@ module Jasmine::Headless
16
16
 
17
17
  class << self
18
18
  def root
19
- @root ||= Pathname.new(File.expand_path('../../..', __FILE__))
19
+ @root ||= Pathname(File.expand_path('../../..', __FILE__))
20
20
  end
21
21
  end
22
22
  end
@@ -14,7 +14,7 @@ module Jasmine::Headless
14
14
  data = File.read(file)
15
15
 
16
16
  if data.respond_to?(:encode)
17
- data.encode!('US-ASCII', 'UTF-8', :invalid => :replace)
17
+ data.encode!('US-ASCII', 'UTF-8', :invalid => :replace, :undef => :replace)
18
18
  else
19
19
  require 'iconv'
20
20
  ic = Iconv.new('UTF-8//IGNORE', 'US-ASCII')
@@ -1,5 +1,5 @@
1
1
  module Jasmine
2
2
  module Headless
3
- VERSION = "0.7.3.1"
3
+ VERSION = "0.7.3.2"
4
4
  end
5
5
  end
data/lib/qt/qmake.rb CHANGED
@@ -39,11 +39,7 @@ module Qt
39
39
 
40
40
  system command(project_file)
41
41
 
42
- system %{make #{make_options}}
43
- end
44
-
45
- def make_options
46
- ""
42
+ system %{make}
47
43
  end
48
44
 
49
45
  #
@@ -3,47 +3,7 @@
3
3
  <head>
4
4
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
5
5
  <title>Jasmine Test Runner - Generated by jasmine-headless-webkit</title>
6
- <script type="text/javascript">
7
- if (window.JHW) {
8
- window.console = { log: function(data) {
9
- if (typeof(jQuery) !== 'undefined' && data instanceof jQuery) {
10
- JHW.log(style_html($("<div />").append(data).html(), { indent_size: 2 }));
11
- } else {
12
- var usejsDump = true;
13
- try {
14
- if (typeof data.toJSON == 'function') {
15
- JHW.log("JSON: " + JSON.stringify(data, null, 2));
16
- usejsDump = false;
17
- }
18
- } catch (e) {}
19
-
20
- if (usejsDump) {
21
- var dump = jsDump.doParse(data);
22
- if (dump.indexOf("\\n") == -1) {
23
- JHW.log(dump);
24
- } else {
25
- JHW.log("jsDump: " + dump);
26
- }
27
- }
28
- }
29
- }, pp: function(data) {
30
- JHW.log(jasmine ? jasmine.pp(data) : JSON.stringify(data));
31
- }, peek: function(data) {
32
- console.log(data);
33
- return data;
34
- } };
35
-
36
- window.onbeforeunload = function(e) {
37
- JHW.leavePageAttempt('The code tried to leave the test page. Check for unhandled form submits and link clicks.');
38
-
39
- if (e = e || window.event) {
40
- e.returnValue = "leaving";
41
- }
42
-
43
- return "leaving";
44
- };
45
- }
46
- </script>
6
+ <script type="text/javascript" src="<%= Jasmine::Headless.root.join('vendor/assets/javascripts/prolog.js') %>"></script>
47
7
  <%= files.join("\n") %>
48
8
  <script type="text/javascript">
49
9
  if (window.JHW) { HeadlessReporterResult.specLineNumbers = <%= MultiJson.encode(spec_lines) %>; }
@@ -51,18 +11,21 @@
51
11
  </head>
52
12
  <body>
53
13
  <script type="text/javascript">
14
+ jasmine.getEnv().console = {
15
+ log: function(msg) { JHW.stdout.puts(msg) }
16
+ }
17
+
54
18
  window._onload = window.onload
55
19
 
56
20
  window.onload = function() {
57
21
  if (window._onload) { window._onload() }
22
+
58
23
  if (window.JHW) {
59
- jasmine.getEnv().addReporter(new jasmine.HeadlessReporter(function() {
60
- window.onbeforeunload = null;
61
- }));
24
+ jasmine.getEnv().addReporter(new jasmine.HeadlessConsoleReporter());
62
25
  } else {
63
26
  jasmine.getEnv().addReporter(new jasmine.HtmlReporter());
64
27
  }
65
-
28
+
66
29
  jasmine.getEnv().execute();
67
30
  }
68
31
  </script>
Binary file
@@ -0,0 +1,14 @@
1
+ describe 'HeadlessReporterResult', ->
2
+ result = null
3
+ name = "name"
4
+ splitName = "splitName"
5
+ message = 'message'
6
+
7
+ beforeEach ->
8
+ result = new HeadlessReporterResult(name, splitName)
9
+
10
+ describe '#addResult', ->
11
+ it 'should add a message', ->
12
+ result.addResult(message)
13
+
14
+ expect(result.results).toEqual([ message ])
@@ -12,11 +12,11 @@ describe 'HeadlessReporterResult', ->
12
12
  expect(HeadlessReporterResult.findSpecLine([ 'name', 'of', 'test' ]).lineNumber).toEqual(3)
13
13
  expect(HeadlessReporterResult.findSpecLine([ 'other', 'of', 'test' ]).lineNumber).toEqual(10)
14
14
 
15
- describe 'jasmine.HeadlessReporter', ->
15
+ describe 'jasmine.HeadlessConsoleReporter', ->
16
16
  reporter = null
17
17
 
18
18
  beforeEach ->
19
- reporter = new jasmine.HeadlessReporter()
19
+ reporter = new jasmine.HeadlessConsoleReporter()
20
20
 
21
21
  it 'should stop running specs if there are errors reported', ->
22
22
  # otherwise it gets really confusing!
@@ -1,4 +1,4 @@
1
- src_files: [ 'jasmine/*.coffee' ]
1
+ src_files: [ 'vendor/assets/coffeescripts/*.coffee' ]
2
2
  spec_files: [ 'spec/javascripts/*_spec.coffee' ]
3
3
  src_dir: .
4
4
  spec_dir: .
@@ -14,9 +14,12 @@ describe Jasmine::FilesList do
14
14
  File.join(Jasmine::Core.path, "jasmine.js"),
15
15
  File.join(Jasmine::Core.path, "jasmine-html.js"),
16
16
  File.join(Jasmine::Core.path, "jasmine.css"),
17
- File.expand_path('jasmine/jasmine.headless-reporter.js'),
18
- File.expand_path('js-lib/jsDump.js'),
19
- File.expand_path('js-lib/beautify-html.js'),
17
+ File.expand_path('vendor/assets/javascripts/jasmine-extensions.js'),
18
+ File.expand_path('vendor/assets/javascripts/intense.js'),
19
+ File.expand_path('vendor/assets/javascripts/headless_reporter_result.js'),
20
+ File.expand_path('vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js'),
21
+ File.expand_path('vendor/assets/javascripts/jsDump.js'),
22
+ File.expand_path('vendor/assets/javascripts/beautify-html.js'),
20
23
  ]
21
24
  end
22
25
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Jasmine::Headless::SpecFileAnalyzer do
4
- include FakeFS::SpecHelpers
5
4
 
6
5
  let(:file) { 'file' }
7
6
  let(:analyzer) { described_class.new(file) }
@@ -11,45 +10,57 @@ describe Jasmine::Headless::SpecFileAnalyzer do
11
10
  analyzer.action
12
11
  end
13
12
 
14
- before do
15
- File.open(file, 'wb') { |fh| fh.print file_data }
16
- end
13
+ context 'fake files' do
14
+ include FakeFS::SpecHelpers
17
15
 
18
- context 'coffeescript' do
19
- let(:file_data) do
20
- <<-SPEC
21
- describe 'test', ->
22
- context 'yes', ->
23
- it 'should do something', ->
24
- "yes"
25
- "PR.registerLangHandler(PR.createSimpleLexer([[\"com\",/^#[^\\n\\r]*/,null,\"#\"],[\"pln\",/^[\\t\\n\\r \\xa0]+/,null,\"\\t\\n\\r \xC2\\xa0\"],[\"str\",/^\"(?:[^\"\\\\]|\\\\[\\S\\s])*(?:\"|$)/,null,'\"']],[[\"kwd\",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\\s/,\n"
26
- SPEC
16
+ before do
17
+ File.open(file, 'wb') { |fh| fh.print file_data }
27
18
  end
28
19
 
29
- it 'should get the line numbers' do
30
- line_numbers['test'].should == [ 1 ]
31
- line_numbers['yes'].should == [ 2 ]
32
- line_numbers['should do something'].should == [ 3 ]
20
+ context 'coffeescript' do
21
+ let(:file_data) do
22
+ <<-SPEC
23
+ describe 'test', ->
24
+ context 'yes', ->
25
+ it 'should do something', ->
26
+ "yes"
27
+ SPEC
28
+ end
29
+
30
+ it 'should get the line numbers' do
31
+ line_numbers['test'].should == [ 1 ]
32
+ line_numbers['yes'].should == [ 2 ]
33
+ line_numbers['should do something'].should == [ 3 ]
34
+ end
33
35
  end
34
- end
35
36
 
36
- context 'javascript' do
37
- let(:file_data) do
38
- <<-SPEC
39
- describe('test', function() {
40
- context('yes', function() {
41
- it('should do something', function() {
37
+ context 'javascript' do
38
+ let(:file_data) do
39
+ <<-SPEC
40
+ describe('test', function() {
41
+ context('yes', function() {
42
+ it('should do something', function() {
42
43
 
44
+ });
43
45
  });
44
46
  });
45
- });
46
- SPEC
47
+ SPEC
48
+ end
49
+
50
+ it 'should get the line numbers' do
51
+ line_numbers['test'].should == [ 1 ]
52
+ line_numbers['yes'].should == [ 2 ]
53
+ line_numbers['should do something'].should == [ 3 ]
54
+ end
47
55
  end
56
+ end
57
+
58
+ context 'utf 8' do
59
+ let(:analyzer) { described_class.new('spec/files/UTF-8-test.txt') }
60
+ let(:file_data) { '' }
48
61
 
49
- it 'should get the line numbers' do
50
- line_numbers['test'].should == [ 1 ]
51
- line_numbers['yes'].should == [ 2 ]
52
- line_numbers['should do something'].should == [ 3 ]
62
+ it 'should not explode' do
63
+ line_numbers
53
64
  end
54
65
  end
55
66
  end
@@ -138,11 +138,5 @@ describe Qt::Qmake do
138
138
  end
139
139
  end
140
140
  end
141
-
142
- describe '.make_options' do
143
- subject { Qt::Qmake.make_options }
144
-
145
- it { should == "" }
146
- end
147
141
  end
148
142
 
@@ -0,0 +1,46 @@
1
+ # Try to get the line number of a failed spec
2
+ class window.HeadlessReporterResult
3
+ constructor: (@name, @splitName) ->
4
+ @results = []
5
+
6
+ addResult: (message) ->
7
+ @results.push(message)
8
+
9
+ print: ->
10
+ output = @name.foreground('red')
11
+ bestChoice = HeadlessReporterResult.findSpecLine(@splitName)
12
+ output += " (#{bestChoice.file}:#{bestChoice.lineNumber})".foreground('blue') if bestChoice.file
13
+
14
+ JHW.stdout.puts "\n\n#{output}"
15
+ for result in @results
16
+ output = result.message.foreground('red')
17
+ if result.lineNumber
18
+ output += " (line ~#{bestChoice.lineNumber + result.lineNumber})".foreground('red').bright()
19
+ JHW.stdout.puts(" " + output)
20
+
21
+ if result.line?
22
+ JHW.stdout.puts(" #{result.line}".foreground('yellow'))
23
+
24
+ @findSpecLine: (splitName) ->
25
+ bestChoice = { accuracy: 0, file: null, lineNumber: null }
26
+
27
+ for file, lines of HeadlessReporterResult.specLineNumbers
28
+ index = 0
29
+ lineNumber = 0
30
+ while newLineNumberInfo = lines[splitName[index]]
31
+ if newLineNumberInfo.length == 0
32
+ lineNumber = newLineNumberInfo[0]
33
+ else
34
+ lastLine = null
35
+ for line in newLineNumberInfo
36
+ lastLine = line
37
+ break if line > lineNumber
38
+
39
+ lineNumber = lastLine
40
+
41
+ index++
42
+
43
+ if index > bestChoice.accuracy
44
+ bestChoice = { accuracy: index, file: file, lineNumber: lineNumber }
45
+
46
+ bestChoice
@@ -0,0 +1,27 @@
1
+ window.Intense = {
2
+ colors:
3
+ black: 0
4
+ red: 1
5
+ green: 2
6
+ yellow: 3
7
+ blue: 4
8
+ magenta: 5
9
+ cyan: 6
10
+ white: 7
11
+ methods:
12
+ foreground: (color) ->
13
+ if Intense.useColors
14
+ "\033[3#{Intense.colors[color]}m#{this}\033[0m"
15
+ else
16
+ this
17
+ bright: ->
18
+ if Intense.useColors
19
+ "\033[1m#{this}\033[0m"
20
+ else
21
+ this
22
+ useColors: true
23
+ }
24
+
25
+ for method, code of Intense.methods
26
+ String.prototype[method] = code
27
+