jasmine-headless-webkit 0.8.4 → 0.9.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/Gemfile +16 -8
  2. data/Guardfile +6 -1
  3. data/Rakefile +2 -1
  4. data/config/cucumber.yml +2 -0
  5. data/ext/jasmine-webkit-specrunner/Page.cpp +2 -3
  6. data/ext/jasmine-webkit-specrunner/Page.h +1 -0
  7. data/ext/jasmine-webkit-specrunner/Runner.cpp +37 -16
  8. data/ext/jasmine-webkit-specrunner/Runner.h +15 -5
  9. data/ext/jasmine-webkit-specrunner/specrunner.cpp +17 -7
  10. data/features/bin/failure.feature +7 -0
  11. data/features/bin/files.feature +7 -0
  12. data/features/bin/filtered_run/both_runs.feature +18 -0
  13. data/features/bin/filtered_run/no_full_run.feature +14 -0
  14. data/features/bin/help.feature +7 -0
  15. data/features/bin/quiet_messages.feature +8 -0
  16. data/features/bin/runner_out.feature +8 -0
  17. data/features/bin/spec_files_with_same_basename.feature +7 -0
  18. data/features/bin/success.feature +20 -0
  19. data/features/bin/success_with_js_error.feature +5 -0
  20. data/features/bin/tries_to_leave_page.feature +7 -0
  21. data/features/bin/try_to_click_a_button.feature +7 -0
  22. data/features/bin/two_files_from_src_files.feature +11 -0
  23. data/features/bin/with_coffeescript_error.feature +7 -0
  24. data/features/bin/with_console_log.feature +7 -0
  25. data/features/bin/with_server.feature +7 -0
  26. data/features/bin/with_window_prompt.feature +7 -0
  27. data/features/reporters.feature +24 -0
  28. data/features/runner.feature +34 -0
  29. data/features/steps/given/i_have_test_suite.rb +2 -0
  30. data/features/steps/given/no_existing_file.rb +4 -0
  31. data/features/steps/given/options/i_have_defaults.rb +4 -0
  32. data/features/steps/given/options/i_have_reporters.rb +10 -0
  33. data/features/steps/given/options/i_have_runner_options.rb +3 -0
  34. data/features/steps/then/bin/exit_status_should_be.rb +3 -0
  35. data/features/steps/then/bin/file_should_contain_runner.rb +4 -0
  36. data/features/steps/then/bin/following_files_loaded_in_order.rb +10 -0
  37. data/features/steps/then/bin/i_should_get_help_output.rb +4 -0
  38. data/features/steps/then/bin/output_should_include.rb +3 -0
  39. data/features/steps/then/bin/output_should_not_include.rb +4 -0
  40. data/features/steps/then/reporting/report_does_not_exist.rb +4 -0
  41. data/features/steps/then/reporting/report_should_exist.rb +3 -0
  42. data/features/steps/then/reporting/report_should_have.rb +7 -0
  43. data/features/steps/then/reporting/report_should_have_seed.rb +4 -0
  44. data/features/steps/then/runner/it_should_have_exit_status.rb +3 -0
  45. data/features/steps/then/runner/it_should_include_report_file.rb +4 -0
  46. data/features/steps/then/runner/it_should_not_include_report_file.rb +3 -0
  47. data/features/steps/then/templates/it_should_use_reporter.rb +6 -0
  48. data/features/steps/when/i_delete_file.rb +3 -0
  49. data/features/steps/when/i_get_runner.rb +4 -0
  50. data/features/steps/when/i_get_template_writer.rb +4 -0
  51. data/features/steps/when/i_run_executable.rb +4 -0
  52. data/features/steps/when/i_run_runner.rb +4 -0
  53. data/features/support/env.rb +7 -0
  54. data/lib/jasmine/headless/file_checker.rb +7 -3
  55. data/lib/jasmine/headless/files_list.rb +46 -19
  56. data/lib/jasmine/headless/options.rb +113 -5
  57. data/lib/jasmine/headless/report.rb +6 -1
  58. data/lib/jasmine/headless/report_message/console.rb +2 -4
  59. data/lib/jasmine/headless/report_message/seed.rb +14 -0
  60. data/lib/jasmine/headless/report_message/spec.rb +3 -5
  61. data/lib/jasmine/headless/report_message.rb +1 -0
  62. data/lib/jasmine/headless/runner.rb +169 -28
  63. data/lib/jasmine/headless/task.rb +0 -14
  64. data/lib/jasmine/headless/template_writer.rb +28 -4
  65. data/lib/jasmine/headless/unique_asset_list.rb +1 -1
  66. data/lib/jasmine/headless/version.rb +1 -1
  67. data/lib/jasmine/headless.rb +18 -0
  68. data/lib/jasmine-headless-webkit.rb +0 -4
  69. data/script/hooks/post-commit +4 -0
  70. data/script/hooks/pre-commit +2 -2
  71. data/script/initialize-environment +1 -1
  72. data/skel/template.html.erb +31 -2
  73. data/spec/jasmine/noisy/file.js.erb +0 -0
  74. data/spec/jasmine/noisy/noisy.yml +8 -0
  75. data/spec/jasmine/noisy/other_file.js +2 -0
  76. data/spec/jasmine/two_files_from_src_files/app/app-file.js +0 -0
  77. data/spec/jasmine/two_files_from_src_files/app/app.js +2 -0
  78. data/spec/jasmine/two_files_from_src_files/jasmine.yml +7 -0
  79. data/spec/jasmine/two_files_from_src_files/vendor/vendor-file.js +0 -0
  80. data/spec/jasmine/two_files_from_src_files/vendor/vendor.js +2 -0
  81. data/spec/jasmine/two_spec_files_same_basename/jasmine.yml +6 -0
  82. data/spec/jasmine/two_spec_files_same_basename/spec.coffee +4 -0
  83. data/spec/jasmine/two_spec_files_same_basename/spec.js +6 -0
  84. data/spec/jasmine/window_prompt/source.js +2 -0
  85. data/spec/jasmine/window_prompt/window_prompt.yml +4 -0
  86. data/spec/javascripts/headless_reporter_result_spec.coffee +22 -6
  87. data/spec/javascripts/helpers/spec_helper.coffee +2 -0
  88. data/spec/javascripts/{jasmine.HeadlessConsoleReporter_spec.coffee → jasmine-extensions_spec.coffee} +0 -35
  89. data/spec/javascripts/jasmine.HeadlessReporter.ConsoleBase_spec.coffee +35 -0
  90. data/spec/javascripts/jasmine.HeadlessReporter.Console_spec.coffee +3 -0
  91. data/spec/javascripts/jasmine.HeadlessReporter.Tap_spec.coffee +19 -0
  92. data/spec/javascripts/jasmine.HeadlessReporter_spec.coffee +27 -0
  93. data/spec/javascripts/support/jasmine.yml +6 -5
  94. data/spec/lib/jasmine/headless/file_checker_spec.rb +25 -9
  95. data/spec/lib/jasmine/headless/files_list_spec.rb +132 -158
  96. data/spec/lib/jasmine/headless/options_spec.rb +77 -0
  97. data/spec/lib/jasmine/headless/report_message/seed_spec.rb +18 -0
  98. data/spec/lib/jasmine/headless/report_spec.rb +16 -0
  99. data/spec/lib/jasmine/headless/runner_spec.rb +110 -33
  100. data/spec/lib/jasmine/headless/template_writer_spec.rb +31 -27
  101. data/spec/lib/jasmine/headless/unique_asset_list_spec.rb +3 -3
  102. data/spec/lib/jasmine/headless_spec.rb +36 -0
  103. data/spec/skel/template.html.erb_spec.rb +8 -0
  104. data/vendor/assets/coffeescripts/prolog.coffee +48 -21
  105. data/vendor/assets/javascripts/headless_reporter_result.js +3 -0
  106. data/vendor/assets/{coffeescripts → javascripts}/intense.coffee +0 -0
  107. data/vendor/assets/{coffeescripts → javascripts}/jasmine-extensions.coffee +4 -10
  108. data/vendor/assets/javascripts/jasmine.HeadlessReporter.Console.coffee +8 -0
  109. data/vendor/assets/javascripts/jasmine.HeadlessReporter.ConsoleBase.coffee +92 -0
  110. data/vendor/assets/javascripts/jasmine.HeadlessReporter.File.coffee +24 -0
  111. data/vendor/assets/javascripts/jasmine.HeadlessReporter.Tap.coffee +28 -0
  112. data/vendor/assets/javascripts/jasmine.HeadlessReporter.Verbose.coffee +64 -0
  113. data/vendor/assets/javascripts/jasmine.HeadlessReporter.coffee +58 -0
  114. data/vendor/assets/javascripts/prolog.js +44 -27
  115. metadata +157 -31
  116. data/ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner.pro +0 -19
  117. data/lib/digest/jasmine_test.rb +0 -20
  118. data/spec/bin/jasmine-headless-webkit_spec.rb +0 -142
  119. data/vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee +0 -118
  120. data/vendor/assets/javascripts/intense.js +0 -44
  121. data/vendor/assets/javascripts/jasmine-extensions.js +0 -129
  122. data/vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js +0 -136
@@ -36,14 +36,17 @@ describe Jasmine::Headless::Runner do
36
36
 
37
37
  context 'file exists' do
38
38
  before do
39
- File.open(Jasmine::Headless::Runner::RUNNER, 'w')
40
- File.open(config_filename, 'w') { |fh| fh.print YAML.dump('test' => 'hello') }
39
+ File.open(config_filename, 'w') { |fh| fh.print YAML.dump('test' => 'hello', 'erb' => '<%= "erb" %>') }
41
40
  end
42
41
 
43
42
  it 'should load the jasmine config' do
44
43
  runner.jasmine_config['test'].should == 'hello'
45
44
  runner.jasmine_config['spec_dir'].should == 'spec/javascripts'
46
45
  end
46
+
47
+ it 'should execute ERB in the config file' do
48
+ runner.jasmine_config['erb'].should == 'erb'
49
+ end
47
50
  end
48
51
 
49
52
  context 'file does not exist' do
@@ -54,51 +57,48 @@ describe Jasmine::Headless::Runner do
54
57
  end
55
58
 
56
59
  describe '#jasmine_command' do
57
- let(:opts) { {
58
- :colors => true,
59
- :report => 'test'
60
- } }
60
+ subject { runner.jasmine_command(target) }
61
61
 
62
- it 'should have the right options' do
63
- runner.jasmine_command.should match(/jasmine-webkit-specrunner/)
64
- runner.jasmine_command.should match(/-c/)
65
- runner.jasmine_command.should match(/-r test/)
66
- runner.jasmine_command('file.js').should match(/file.js/)
67
- end
68
- end
62
+ let(:target) { 'target' }
69
63
 
70
- context 'real tests' do
71
- let(:report) { 'spec/report.txt' }
64
+ let(:options) { {} }
65
+ let(:reporters) { [] }
72
66
 
73
67
  before do
74
- FileUtils.rm_f report
68
+ runner.stubs(:options).returns(options)
69
+ options.stubs(:file_reporters).returns(reporters)
75
70
  end
76
71
 
77
- after do
78
- FileUtils.rm_f report
72
+ def self.it_should_have_basics
73
+ it { should include(target) }
79
74
  end
80
75
 
81
- it 'should succeed with error code 0' do
82
- Jasmine::Headless::Runner.run(
83
- :jasmine_config => 'spec/jasmine/success/success.yml',
84
- :report => report
85
- ).should == 0
76
+ context 'colors' do
77
+ before do
78
+ options[:colors] = true
79
+ end
86
80
 
87
- report.should be_a_report_containing(1, 0, false)
81
+ it_should_have_basics
82
+ it { should include('-c') }
88
83
  end
89
84
 
90
- it 'should succeed but with javascript error' do
91
- Jasmine::Headless::Runner.run(:jasmine_config => 'spec/jasmine/success_with_error/success_with_error.yml').should == 1
85
+ context 'reporters' do
86
+ let(:reporter) { [ 'Reporter', 'identifier', file ] }
87
+ let(:reporters) { [ reporter ] }
88
+
89
+ let(:file) { 'file' }
90
+
91
+ it_should_have_basics
92
+ it { should include("-r #{file}") }
92
93
  end
93
94
 
94
- it 'should fail on one test' do
95
- Jasmine::Headless::Runner.run(
96
- :jasmine_config => 'spec/jasmine/failure/failure.yml',
97
- :report => report
98
- ).should == 1
95
+ context 'quiet' do
96
+ before do
97
+ options[:quiet] = true
98
+ end
99
99
 
100
- report.should be_a_report_containing(1, 1, false)
101
- report.should contain_a_failing_spec(['failure', 'should fail with error code of 1'])
100
+ it_should_have_basics
101
+ it { should include("-q") }
102
102
  end
103
103
  end
104
104
 
@@ -167,4 +167,81 @@ describe Jasmine::Headless::Runner do
167
167
  runner.jasmine_config['spec_files'].should == described_class::JASMINE_DEFAULTS['spec_files']
168
168
  end
169
169
  end
170
+
171
+ describe '#files_list' do
172
+ subject { runner.files_list }
173
+
174
+ let(:options) { { :files => only, :seed => seed } }
175
+
176
+ let(:only) { 'only' }
177
+ let(:seed) { 12345 }
178
+ let(:jasmine_config) { 'jasmine config' }
179
+ let(:reporters) { [] }
180
+
181
+ before do
182
+ runner.stubs(:options).returns(options)
183
+ runner.stubs(:jasmine_config).returns(jasmine_config)
184
+
185
+ options.stubs(:reporters).returns(reporters)
186
+ end
187
+
188
+ it { should be_a_kind_of(Jasmine::Headless::FilesList) }
189
+
190
+ it 'should have settings' do
191
+ subject.options[:config].should == jasmine_config
192
+ subject.options[:only].should == only
193
+ subject.options[:seed].should == seed
194
+ subject.options[:reporters].should == reporters
195
+ end
196
+ end
197
+
198
+ describe '.server_port' do
199
+ before do
200
+ described_class.instance_variable_set(:@server_port, nil)
201
+ end
202
+
203
+ context 'port in use' do
204
+ require 'socket'
205
+
206
+ before do
207
+ described_class.stubs(:select_server_port).returns(5000, 5001)
208
+ end
209
+
210
+ it 'should try another port' do
211
+ server = TCPServer.new(described_class.server_interface, 5000)
212
+
213
+ described_class.server_port.should == 5001
214
+ end
215
+ end
216
+ end
217
+
218
+ describe '#absolute_run_targets' do
219
+ let(:opts) { {} }
220
+
221
+ subject { runner.absolute_run_targets(targets) }
222
+
223
+ let(:targets) { [ target ] }
224
+ let(:target) { 'target' }
225
+
226
+ before do
227
+ runner.stubs(:options).returns(:use_server => use_server)
228
+ end
229
+
230
+ context 'server' do
231
+ let(:use_server) { true }
232
+ let(:server_spec_path) { 'server spec path' }
233
+
234
+ before do
235
+ described_class.stubs(:server_spec_path).returns(server_spec_path)
236
+ end
237
+
238
+ it { should == [ server_spec_path + target ] }
239
+ end
240
+
241
+ context 'no server' do
242
+ let(:use_server) { false }
243
+
244
+ it { should == [ 'file://' + File.expand_path(target) ] }
245
+ end
246
+ end
170
247
  end
@@ -43,46 +43,50 @@ describe Jasmine::Headless::TemplateWriter do
43
43
  end
44
44
  end
45
45
 
46
- describe '#write!' do
47
- include FakeFS::SpecHelpers
46
+ describe '#render' do
47
+ subject { template_writer.render }
48
+
49
+ let(:all_files) { 'all files' }
50
+ let(:template) { 'template' }
48
51
 
49
52
  before do
50
- Jasmine::Headless::FilesList.stubs(:default_files).returns([])
53
+ template_writer.stubs(:all_files).returns(all_files)
51
54
 
52
- File.stubs(:read).returns(nil)
55
+ template_writer.expects(:template_for).with(all_files).returns(template)
56
+ end
53
57
 
54
- runner.stubs(:keep_runner).returns(true)
55
- runner.stubs(:runner_filename).returns(false)
58
+ it { should == template }
59
+ end
56
60
 
57
- Sprockets::Environment.any_instance.stubs(:find_asset).returns(stub(:body => ''))
58
- end
61
+ describe '#all_files' do
62
+ subject { template_writer.all_files }
59
63
 
60
- let(:files_list) { Jasmine::Headless::FilesList.new }
64
+ let(:files_list) { stub }
65
+ let(:files) { 'files' }
61
66
 
62
67
  before do
63
- files_list.stubs(:files).returns([ 'file.js' ])
64
- files_list.stubs(:filtered_files).returns([ 'file.js' ])
65
- end
68
+ template_writer.stubs(:files_list).returns(files_list)
66
69
 
67
- context 'no filter' do
68
- it 'should write one file' do
69
- template_writer.write!(files_list).should == [
70
- "jhw.#{$$}.html"
71
- ]
72
- end
70
+ files_list.stubs(:files_to_html).returns(files)
73
71
  end
74
72
 
75
- context 'filtered files' do
76
- before do
77
- files_list.stubs(:files).returns([ 'file.js', 'file2.js' ])
78
- end
73
+ it { should == files }
74
+ end
79
75
 
80
- it 'should write two files' do
81
- template_writer.write!(files_list).should == [
82
- "jhw.#{$$}.filter.html", "jhw.#{$$}.html"
83
- ]
84
- end
76
+ describe '#jhw_reporters' do
77
+ subject { template_writer.jhw_reporters }
78
+
79
+ let(:reporter) { 'reporter' }
80
+ let(:output) { 'output' }
81
+
82
+ before do
83
+ template_writer.stubs(:reporters).returns([
84
+ [ reporter, output ]
85
+ ])
85
86
  end
87
+
88
+ it { should include(reporter) }
89
+ it { should include(output) }
86
90
  end
87
91
  end
88
92
 
@@ -3,9 +3,9 @@ require 'spec_helper'
3
3
  describe Jasmine::Headless::UniqueAssetList do
4
4
  let(:list) { described_class.new }
5
5
 
6
- let(:first) { stub(:logical_path => 'one') }
7
- let(:second) { stub(:logical_path => 'two') }
8
- let(:third) { stub(:logical_path => 'two') }
6
+ let(:first) { stub(:logical_path => 'one', :pathname => 'one') }
7
+ let(:second) { stub(:logical_path => 'two', :pathname => 'two') }
8
+ let(:third) { stub(:logical_path => 'two', :pathname => 'two') }
9
9
 
10
10
  it 'should raise an exception on a non-asset' do
11
11
  expect { list << "whatever" }.to raise_error(StandardError)
@@ -1,2 +1,38 @@
1
1
  require 'spec_helper'
2
2
 
3
+ describe Jasmine::Headless do
4
+ describe '.warn' do
5
+ let(:output) { StringIO.new }
6
+
7
+ before do
8
+ described_class.stubs(:output).returns(output)
9
+ end
10
+
11
+ context 'warnings enabled' do
12
+ before do
13
+ described_class.stubs(:show_warnings?).returns(true)
14
+ end
15
+
16
+ it 'should work' do
17
+ described_class.warn("warning")
18
+
19
+ output.rewind
20
+ output.read.should == "warning\n"
21
+ end
22
+ end
23
+
24
+ context 'warnings disabled' do
25
+ before do
26
+ described_class.stubs(:show_warnings?).returns(false)
27
+ end
28
+
29
+ it 'should work' do
30
+ described_class.warn("warning")
31
+
32
+ output.rewind
33
+ output.read.should == ""
34
+ end
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'skel/template.html.erb' do
4
+ describe 'reporters' do
5
+
6
+ end
7
+ end
8
+
@@ -26,47 +26,74 @@ if window.JHW
26
26
  console.log(data)
27
27
  data
28
28
 
29
+ puts = (message) ->
30
+ JHW.print('stdout', message + "\n")
31
+
32
+ warn = (message) ->
33
+ puts(message) if !JHW.isQuiet()
34
+
35
+ # handle unloading
29
36
  window.onbeforeunload = (e) ->
30
37
  e = e || window.event
31
38
 
32
39
  JHW.hasError()
33
- JHW.stdout.puts('The code tried to leave the test page. Check for unhandled form submits and link clicks.')
40
+ warn "The code tried to leave the test page. Check for unhandled form submits and link clicks."
34
41
 
35
- if e
36
- e.returnValue = 'string'
42
+ e.returnValue = 'string' if e
37
43
 
38
44
  return 'string'
39
45
 
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
-
46
+ # script errors
47
47
  JHW._hasErrors = false
48
48
  JHW._handleError = (message, lineNumber, sourceURL) ->
49
- JHW.stderr.puts(message)
49
+ JHW.print('stderr', message + "\n")
50
50
  JHW._hasErrors = true
51
51
  false
52
52
 
53
- JHW._setColors = (useColors) ->
54
- Intense.useColors = useColors
53
+ # dialogs
54
+ window.confirm = ->
55
+ warn "#{"[confirm]".foreground('red')} You should mock window.confirm. Returning true."
55
56
 
56
- createHandle = (handle) ->
57
- JHW[handle] =
58
- print: (content) -> JHW.print(handle, content)
59
- puts: (content) -> JHW.print(handle, content + "\n")
57
+ true
60
58
 
61
- createHandle(handle) for handle in [ 'stdout', 'stderr', 'report' ]
59
+ window.prompt = ->
60
+ warn "#{"[prompt]".foreground('red')} You should mock window.prompt. Returning true."
62
61
 
63
- JHW._usedConsole = false
62
+ true
63
+
64
+ window.alert = (message) ->
65
+ warn "[alert] ".foreground('red') + message
66
+
67
+ # color support
68
+ JHW._setColors = (useColors) -> Intense.useColors = useColors
64
69
 
70
+ # console.log support
71
+ JHW._usedConsole = false
65
72
  JHW.log = (msg) ->
66
73
  JHW.hasUsedConsole()
67
- JHW.report.puts("CONSOLE||#{msg}")
74
+
75
+ for reporter in jasmine.getEnv().reporter.subReporters_
76
+ reporter.consoleLogUsed(msg) if reporter.consoleLogUsed?
77
+
68
78
  JHW._usedConsole = true
69
- JHW.stdout.puts(msg)
79
+
80
+ puts msg
81
+
82
+ JHW.createCoffeeScriptFileException = (e) ->
83
+ if e and e.sourceURL
84
+ filename = e.sourceURL.split('/').pop()
85
+
86
+ e =
87
+ name: e.name
88
+ message: e.message
89
+ sourceURL: e.sourceURL
90
+ lineNumber: e.line
91
+
92
+ if window.CoffeeScriptToFilename and realFilename = window.CoffeeScriptToFilename[filename]
93
+ e.sourceURL = realFilename
94
+ e.lineNumber = "~" + String(e.line)
95
+
96
+ e
70
97
 
71
98
  window.CoffeeScriptToFilename = {}
72
99
  window.CSTF = window.CoffeeScriptToFilename
@@ -1,3 +1,4 @@
1
+ (function() {
1
2
 
2
3
  window.HeadlessReporterResult = (function() {
3
4
 
@@ -74,3 +75,5 @@
74
75
  return HeadlessReporterResult;
75
76
 
76
77
  })();
78
+
79
+ }).call(this);
@@ -30,15 +30,7 @@ if window.JHW
30
30
  this.env.reporter.reportSpecResults(this)
31
31
 
32
32
  jasmine.Spec.prototype.fail = (e) ->
33
- if e and e.sourceURL and window.CoffeeScriptToFilename
34
- filename = e.sourceURL.split('/').pop()
35
- if realFilename = window.CoffeeScriptToFilename[filename]
36
- e = {
37
- name: e.name,
38
- message: e.message,
39
- lineNumber: "~" + String(e.line),
40
- sourceURL: realFilename
41
- }
33
+ e = JHW.createCoffeeScriptFileException(e)
42
34
 
43
35
  expectationResult = new jasmine.ExpectationResult({
44
36
  passed: false,
@@ -47,6 +39,8 @@ if window.JHW
47
39
  })
48
40
  @results_.addResult(expectationResult)
49
41
 
42
+ this.env.reporter.reportException(e)
43
+
50
44
  jasmine.NestedResults.isValidSpecLine = (line) ->
51
45
  line.match(/^\s*expect/) != null || line.match(/^\s*return\s*expect/) != null
52
46
 
@@ -92,7 +86,7 @@ if window.JHW
92
86
 
93
87
  this.addResult_(result)
94
88
 
95
- for method in [ "reportSpecWaiting", "reportSpecRunning" ]
89
+ for method in [ "reportSpecWaiting", "reportSpecRunning", "reportException" ]
96
90
  generator = (method) ->
97
91
  (args...) ->
98
92
  for reporter in @subReporters_
@@ -0,0 +1,8 @@
1
+ #= require jasmine.HeadlessReporter.ConsoleBase
2
+ #
3
+ class jasmine.HeadlessReporter.Console extends jasmine.HeadlessReporter.ConsoleBase
4
+ displaySuccess: (spec) =>
5
+ this.print('.'.foreground('green'))
6
+
7
+ displayFailure: (spec) =>
8
+ this.print('F'.foreground('red'))
@@ -0,0 +1,92 @@
1
+ #= require jasmine.HeadlessReporter
2
+
3
+ class jasmine.HeadlessReporter.ConsoleBase extends jasmine.HeadlessReporter
4
+ constructor: (@callback = null) ->
5
+ super(@callback)
6
+
7
+ @position = 0
8
+ @positions = "|/-\\"
9
+
10
+ formatResultLine: (runtime) ->
11
+ line = []
12
+ line.push(@length)
13
+ line.push((if @length == 1 then "test" else "tests") + ',')
14
+
15
+ line.push(@failedCount)
16
+ line.push((if @failedCount == 1 then "failure" else "failures") + ',')
17
+
18
+ line.push(runtime)
19
+ line.push((if runtime == 1.0 then "sec" else "secs") + '.')
20
+
21
+ line.join(' ')
22
+
23
+ reportRunnerResults: (runner) ->
24
+ super()
25
+
26
+ this.print("\n")
27
+
28
+ resultLine = this.formatResultLine(this._runtime())
29
+
30
+ if @failedCount == 0
31
+ this.puts("PASS: #{resultLine}".foreground('green'))
32
+ else
33
+ this.puts("FAIL: #{resultLine}".foreground('red'))
34
+
35
+ for result in @results
36
+ this.puts(result.toString())
37
+
38
+ this.puts("\nTest ordering seed: --seed #{JHW.getSeed()}")
39
+
40
+ reportRunnerStarting: (runner) ->
41
+ super(runner)
42
+ this.puts("\nRunning Jasmine specs...".bright()) if !this.hasError()
43
+
44
+ reportSpecWaiting: ->
45
+ if !@timer
46
+ @timer = true
47
+ @first = true
48
+
49
+ this._waitRunner()
50
+
51
+ reportSpecRunning: ->
52
+ if @timer
53
+ clearTimeout(@timer)
54
+ @timer = null
55
+ this.print(Intense.moveBack())
56
+
57
+ reportSpecResults: (spec) ->
58
+ super(spec)
59
+
60
+ this._reportSpecResult(spec, {
61
+ success: (results) =>
62
+ this.displaySuccess(spec)
63
+ failure: (results) =>
64
+ this.displayFailure(spec)
65
+
66
+ this.reportFailureResult(results, new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName()))
67
+ })
68
+
69
+ reportFailureResult: (results, failureResult) ->
70
+ testCount = 1
71
+
72
+ for result in results.getItems()
73
+ if result.type == 'expect' and !result.passed_
74
+ if foundLine = result.expectations[testCount - 1]
75
+ [ result.line, result.lineNumber ] = foundLine
76
+ failureResult.addResult(result)
77
+ testCount += 1
78
+ @results.push(failureResult)
79
+
80
+ _waitRunner: =>
81
+ @timer = setTimeout(
82
+ =>
83
+ if @timer
84
+ this.print(Intense.moveBack()) if !@first
85
+ this.print(@positions.substr(@position, 1).foreground('yellow'))
86
+ @position += 1
87
+ @position %= @positions.length
88
+ @first = false
89
+ this._waitRunner()
90
+ , 750
91
+ )
92
+
@@ -0,0 +1,24 @@
1
+ #= require jasmine.HeadlessReporter
2
+ #
3
+ class jasmine.HeadlessReporter.File extends jasmine.HeadlessReporter
4
+ reportRunnerResults: (runner) ->
5
+ super(runner)
6
+
7
+ output = "TOTAL||#{@length}||#{@failedCount}||#{this._runtime()}||#{if JHW._hasErrors then "T" else "F"}"
8
+
9
+ this.puts(output)
10
+ this.puts("SEED||#{JHW.getSeed()}")
11
+
12
+ consoleLogUsed: (msg) ->
13
+ this.puts("CONSOLE||#{msg}")
14
+
15
+ reportSpecResults: (spec) ->
16
+ super(spec)
17
+
18
+ this._reportSpecResult(spec, {
19
+ success: (results) =>
20
+ this.puts("PASS||" + spec.getJHWSpecInformation())
21
+ failure: (results) =>
22
+ this.puts("FAIL||" + spec.getJHWSpecInformation())
23
+ })
24
+
@@ -0,0 +1,28 @@
1
+ #= require jasmine.HeadlessReporter
2
+
3
+ class jasmine.HeadlessReporter.Tap extends jasmine.HeadlessReporter
4
+ constructor: (@outputTarget = null) ->
5
+ super(@outputTarget)
6
+
7
+ @output = []
8
+
9
+ reportRunnerResults: (runner) ->
10
+ super(runner)
11
+
12
+ @output.unshift("1..#{@output.length}") if @output.length > 0
13
+
14
+ this.puts(@output.join("\n"))
15
+
16
+ reportSpecResults: (spec) ->
17
+ super(spec)
18
+
19
+ index = @output.length + 1
20
+ description = spec.getSpecSplitName().join(' ')
21
+
22
+ this._reportSpecResult(spec, {
23
+ success: (results) =>
24
+ @output.push("ok #{index} #{description}")
25
+ failure: (results) =>
26
+ @output.push("not ok #{index} #{description}")
27
+ })
28
+
@@ -0,0 +1,64 @@
1
+ #= require jasmine.HeadlessReporter.ConsoleBase
2
+ #
3
+ class jasmine.HeadlessReporter.Verbose extends jasmine.HeadlessReporter.ConsoleBase
4
+ @prereport = false
5
+
6
+ displaySuccess: (spec) =>
7
+ this.displaySpec(spec, 'green')
8
+
9
+ displayFailure: (spec) =>
10
+ this.displaySpec(spec, 'red')
11
+
12
+ displaySpec: (spec, color) =>
13
+ currentLastNames = (@lastNames || []).slice(0)
14
+ @lastNames = spec.getSpecSplitName()
15
+
16
+ for line in this.indentSpec(@lastNames, currentLastNames, color)
17
+ if line? and !_.isEmpty(line)
18
+ this.puts(line)
19
+
20
+ indentSpec: (current, last, color) =>
21
+ last = last.slice(0)
22
+
23
+ lines = []
24
+
25
+ for name in current
26
+ if last.shift() != name
27
+ lines.push(name)
28
+ else
29
+ lines.push(null)
30
+
31
+ this.indentLines(lines, color)
32
+
33
+ indentLines: (lines, color) =>
34
+ indent = ''
35
+
36
+ output = []
37
+
38
+ for line in lines
39
+ if line?
40
+ outputLine = indent
41
+ outputLine += this.colorLine(line, color)
42
+
43
+ output.push(outputLine)
44
+ indent += ' '
45
+
46
+ output
47
+
48
+ colorLine: (line, color) =>
49
+ line.foreground(color)
50
+
51
+ reportSpecStarting: (spec) =>
52
+ if jasmine.HeadlessReporter.Verbose.prereport
53
+ this.puts(spec.getSpecSplitName().join(' '))
54
+
55
+ reportException: (e) =>
56
+ e = JHW.createCoffeeScriptFileException(e)
57
+
58
+ if e.sourceURL && e.lineNumber
59
+ output = "#{e.sourceURL}:#{e.lineNumber} #{e.message}"
60
+ else
61
+ output = e.message ? e
62
+
63
+ this.puts(output.foreground('yellow'))
64
+