jasmine-headless-webkit 0.7.1 → 0.7.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.
data/.gitignore CHANGED
@@ -13,3 +13,4 @@ hydra-runner.log
13
13
  jhw-test
14
14
  .jhw-cache/
15
15
  _site/
16
+ jhw.*.html
data/CHANGELOG.md CHANGED
@@ -1,3 +1,30 @@
1
+ ## 0.7.2
2
+
3
+ * Improved finding of CoffeeScript spec line locations
4
+ * Improved Runner reporting of which expectations failed
5
+ * Initial vendored helper support, paving the way for Sprockets integratioon (maybe!)
6
+ * Add 1.9.3-rc1 test support and fixes
7
+ * Add console.peek()
8
+
9
+ ## 0.7.1
10
+
11
+ * Bugfix for missing digest/sha1 import
12
+
13
+ ## 0.7.0
14
+
15
+ * Major C++ cleanup, now much more modular
16
+ * Greatly improved object inspection and printing provided by jsDump and beautify-js
17
+
18
+ ## 0.6.3
19
+
20
+ * Ensure Rubygems is available before doing version comparison
21
+ * Fix other build problems
22
+ * Better output for jQuery nodes
23
+
24
+ ## 0.6.2
25
+
26
+ * Clean up C++ and test running
27
+
1
28
  ## 0.6.1
2
29
 
3
30
  * Ensure YAML is loaded before use
data/Rakefile CHANGED
@@ -14,12 +14,23 @@ require 'jasmine/headless/task'
14
14
 
15
15
  Jasmine::Headless::Task.new
16
16
 
17
+ PLATFORMS = %w{1.8.7 1.9.2 ree 1.9.3-rc1}
18
+
19
+ def rvm_bundle(command = '')
20
+ Bundler.with_clean_env do
21
+ system %{bash -c 'unset BUNDLE_BIN_PATH && unset BUNDLE_GEMFILE && rvm #{PLATFORMS.join(',')} do bundle #{command}'}
22
+ end
23
+ end
24
+
25
+ class SpecFailure < StandardError; end
26
+ class BundleFailure < StandardError; end
27
+
17
28
  namespace :spec do
18
29
  desc "Run on three Rubies"
19
30
  task :platforms do
20
- system %{rvm 1.8.7,1.9.2,ree ruby bundle}
21
- system %{rvm 1.8.7,1.9.2,ree ruby bundle exec rake spec}
22
- raise StandardError.new if $?.exitstatus != 0
31
+ rvm_bundle
32
+ rvm_bundle "exec rspec spec"
33
+ raise SpecError.new if $?.exitstatus != 0
23
34
  end
24
35
  end
25
36
 
@@ -31,3 +42,4 @@ task :build_runner do
31
42
  system %{ruby extconf.rb}
32
43
  end
33
44
  end
45
+
@@ -10,19 +10,12 @@ end
10
10
  $:.unshift(File.join(gem_dir, 'lib'))
11
11
  require 'jasmine-headless-webkit'
12
12
 
13
- require 'jasmine/headless/errors'
14
- require 'jasmine/headless/runner'
15
- require 'jasmine/headless/options'
16
-
17
13
  begin
18
14
  options = Jasmine::Headless::Options.from_command_line
19
15
  runner = Jasmine::Headless::Runner.new(options)
20
16
 
21
17
  if options[:do_list]
22
- files_list = Jasmine::FilesList.new(
23
- :config => runner.jasmine_config
24
- )
25
-
18
+ files_list = Jasmine::FilesList.new(:config => runner.jasmine_config)
26
19
  files_list.files.each { |file| puts file }
27
20
  else
28
21
  puts "Running Jasmine specs...".color(:white)
@@ -82,8 +82,17 @@ void ConsoleOutput::logSpecFilename(const QString &name) {
82
82
  }
83
83
 
84
84
  void ConsoleOutput::logSpecResult(const QString &result) {
85
+ QStringList lines = result.split("\n");
86
+ QStringListIterator linesIterator(lines);
87
+
85
88
  red();
86
- *outputIO << " " << qPrintable(result) << std::endl;
89
+ while (linesIterator.hasNext()) {
90
+ QString line = linesIterator.next();
91
+ if (!linesIterator.hasNext())
92
+ yellow();
93
+ *outputIO << " " << qPrintable(line) << std::endl;
94
+ }
95
+
87
96
  clear();
88
97
  }
89
98
 
@@ -4,6 +4,7 @@
4
4
  #include <QObject>
5
5
  #include <iostream>
6
6
  #include <QStack>
7
+ #include <QStringList>
7
8
 
8
9
  class ConsoleOutput : public QObject {
9
10
  public:
@@ -7,6 +7,8 @@ system %{make clean}
7
7
  $: << File.expand_path("../../../lib", __FILE__)
8
8
  require 'qt/qmake'
9
9
 
10
+ result = 0
11
+
10
12
  Dir['*_test.pro'].each do |test|
11
13
  FileUtils.rm_f('jhw-test')
12
14
 
@@ -15,10 +17,15 @@ Dir['*_test.pro'].each do |test|
15
17
  if File.file?('jhw-test')
16
18
  system %{./jhw-test}
17
19
  if $?.exitstatus != 0
18
- exit 1
20
+ result = 1
21
+ break
19
22
  end
20
23
  else
21
- exit 1
24
+ result = 1
25
+ break
22
26
  end
23
27
  end
24
28
 
29
+ Qt::Qmake.make!('jasmine-headless-webkit', 'specrunner.pro')
30
+
31
+ exit result
@@ -1,120 +1,175 @@
1
1
  if !jasmine?
2
2
  throw new Error("jasmine not laoded!")
3
3
 
4
+ if window.JHW
4
5
  # Jasmine extensions
5
- getSplitName = (parts) ->
6
- parts.push(String(@description).replace(/[\n\r]/g, ' '))
7
- parts
6
+ getSplitName = (parts) ->
7
+ parts.push(String(@description).replace(/[\n\r]/g, ' '))
8
+ parts
8
9
 
9
- jasmine.Suite.prototype.getSuiteSplitName = ->
10
- this.getSplitName(if @parentSuite then @parentSuite.getSuiteSplitName() else [])
10
+ jasmine.Suite.prototype.getSuiteSplitName = ->
11
+ this.getSplitName(if @parentSuite then @parentSuite.getSuiteSplitName() else [])
11
12
 
12
- jasmine.Spec.prototype.getSpecSplitName = ->
13
- this.getSplitName(@suite.getSuiteSplitName())
13
+ jasmine.Spec.prototype.getSpecSplitName = ->
14
+ this.getSplitName(@suite.getSuiteSplitName())
14
15
 
15
- jasmine.Suite.prototype.getSplitName = getSplitName
16
- jasmine.Spec.prototype.getSplitName = getSplitName
16
+ jasmine.Suite.prototype.getSplitName = getSplitName
17
+ jasmine.Spec.prototype.getSplitName = getSplitName
17
18
 
18
- jasmine.Spec.prototype.getJHWSpecInformation = ->
19
- parts = this.getSpecSplitName()
20
- specLineInfo = HeadlessReporterResult.findSpecLine(parts)
21
- if specLineInfo.file
22
- parts.push("#{specLineInfo.file}:#{specLineInfo.lineNumber}")
23
- else
24
- parts.push('')
25
- parts.join("||")
26
-
27
- if !jasmine.WaitsBlock.prototype._execute
28
- jasmine.WaitsBlock.prototype._execute = jasmine.WaitsBlock.prototype.execute
29
- jasmine.WaitsForBlock.prototype._execute = jasmine.WaitsForBlock.prototype.execute
30
-
31
- pauseAndRun = (onComplete) ->
32
- JHW.timerPause()
33
- this._execute ->
34
- JHW.timerDone()
35
- onComplete()
36
-
37
- jasmine.WaitsBlock.prototype.execute = pauseAndRun
38
- jasmine.WaitsForBlock.prototype.execute = pauseAndRun
19
+ jasmine.Spec.prototype.getJHWSpecInformation = ->
20
+ parts = this.getSpecSplitName()
21
+ specLineInfo = HeadlessReporterResult.findSpecLine(parts)
22
+ if specLineInfo.file
23
+ parts.push("#{specLineInfo.file}:#{specLineInfo.lineNumber}")
24
+ else
25
+ parts.push('')
26
+ parts.join("||")
27
+
28
+ jasmine.Spec.prototype.fail = (e) ->
29
+ if e and e.sourceURL and window.CoffeeScriptToFilename
30
+ filename = e.sourceURL.split('/').pop()
31
+ if realFilename = window.CoffeeScriptToFilename[filename]
32
+ e = {
33
+ name: e.name,
34
+ message: e.message,
35
+ lineNumber: "~" + String(e.line),
36
+ sourceURL: realFilename
37
+ }
38
+
39
+ expectationResult = new jasmine.ExpectationResult({
40
+ passed: false,
41
+ message: if e then jasmine.util.formatException(e) else 'Exception',
42
+ trace: { stack: e.stack }
43
+ })
44
+ @results_.addResult(expectationResult)
45
+
46
+ jasmine.NestedResults.isValidSpecLine = (line) ->
47
+ line.match(/^\s*expect/) != null || line.match(/^\s*return\s*expect/) != null
48
+
49
+ jasmine.NestedResults.parseFunction = (func) ->
50
+ lines = []
51
+ lineCount = 0
52
+ for line in func.split("\n")
53
+ if jasmine.NestedResults.isValidSpecLine(line)
54
+ line = line.replace(/^\s*/, '').replace(/\s*$/, '').replace(/^return\s*/, '')
55
+ lines.push([line, lineCount])
56
+ lineCount += 1
57
+ lines
58
+
59
+ jasmine.NestedResults.parseAndStore = (func) ->
60
+ if !jasmine.NestedResults.ParsedFunctions[func]
61
+ jasmine.NestedResults.ParsedFunctions[func] = jasmine.NestedResults.parseFunction(func)
62
+ jasmine.NestedResults.ParsedFunctions[func]
63
+
64
+ jasmine.NestedResults.ParsedFunctions = []
65
+
66
+ if !jasmine.WaitsBlock.prototype._execute
67
+ jasmine.WaitsBlock.prototype._execute = jasmine.WaitsBlock.prototype.execute
68
+ jasmine.WaitsForBlock.prototype._execute = jasmine.WaitsForBlock.prototype.execute
69
+
70
+ pauseAndRun = (onComplete) ->
71
+ JHW.timerPause()
72
+ this._execute ->
73
+ JHW.timerDone()
74
+ onComplete()
75
+
76
+ jasmine.WaitsBlock.prototype.execute = pauseAndRun
77
+ jasmine.WaitsForBlock.prototype.execute = pauseAndRun
78
+
79
+ jasmine.NestedResults.prototype.addResult_ = jasmine.NestedResults.prototype.addResult
80
+ jasmine.NestedResults.prototype.addResult = (result) ->
81
+ result.expectations = []
82
+ # always three up?
83
+
84
+ result.expectations = jasmine.NestedResults.parseAndStore(arguments.callee.caller.caller.caller.toString())
85
+
86
+ this.addResult_(result)
39
87
 
40
88
  # Try to get the line number of a failed spec
41
- class window.HeadlessReporterResult
42
- constructor: (@name, @splitName) ->
43
- @results = []
44
- addResult: (message) ->
45
- @results.push(message)
46
- print: ->
47
- output = @name
48
- bestChoice = HeadlessReporterResult.findSpecLine(@splitName)
49
- output += " (#{bestChoice.file}:#{bestChoice.lineNumber})" if bestChoice.file
50
-
51
- JHW.printName(output)
52
- for result in @results
53
- JHW.printResult(result)
54
- @findSpecLine: (splitName) ->
55
- bestChoice = { accuracy: 0, file: null, lineNumber: null }
56
-
57
- for file, lines of HeadlessReporterResult.specLineNumbers
58
- index = 0
59
- lineNumber = 0
60
- while newLineNumberInfo = lines[splitName[index]]
61
- if newLineNumberInfo.length == 0
62
- lineNumber = newLineNumberInfo[0]
63
- else
64
- lastLine = null
65
- for line in newLineNumberInfo
66
- lastLine = line
67
- break if line > lineNumber
68
-
69
- lineNumber = lastLine
70
-
71
- index++
72
-
73
- if index > bestChoice.accuracy
74
- bestChoice = { accuracy: index, file: file, lineNumber: lineNumber }
75
-
76
- bestChoice
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
77
128
 
78
129
  # The reporter itself.
79
- class jasmine.HeadlessReporter
80
- constructor: (@callback = null) ->
81
- @results = []
82
- @failedCount = 0
83
- @length = 0
84
- reportRunnerResults: (runner) ->
85
- return if this.hasError()
86
-
87
- for result in @results
88
- result.print()
89
-
90
- this.callback() if @callback
91
- JHW.finishSuite((new Date() - @startTime) / 1000.0, @length, @failedCount)
92
-
93
- reportRunnerStarting: (runner) ->
94
- @startTime = new Date()
95
-
96
- reportSpecResults: (spec) ->
97
- return if this.hasError()
98
-
99
- results = spec.results()
100
- @length++
101
- if results.passed()
102
- JHW.specPassed(spec.getJHWSpecInformation())
103
- else
104
- JHW.specFailed(spec.getJHWSpecInformation())
105
- @failedCount++
106
- failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName())
107
- for result in results.getItems()
108
- if result.type == 'expect' and !result.passed_
109
- failureResult.addResult(result.message)
110
- @results.push(failureResult)
111
-
112
- reportSpecStarting: (spec) ->
113
- if this.hasError()
114
- spec.finish()
115
- spec.suite.finish()
116
-
117
- reportSuiteResults: (suite) ->
118
- hasError: ->
119
- JHW.hasError()
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()
120
175