diff --git a/features/bin/failure.feature b/features/bin/failure.feature index aa59fdc..56e2aa5 100644 --- a/features/bin/failure.feature +++ b/features/bin/failure.feature @@ -1,7 +1,7 @@ Feature: Bin - Failure Scenario: Run a failing test Given there is no existing "spec/report.txt" file - When I run `bin/jasmine-headless-webkit -j spec/jasmine/failure/failure.yml --format HeadlessFileReporter --out spec/report.txt` + When I run `bin/jasmine-headless-webkit -j spec/jasmine/failure/failure.yml -f File:spec/report.txt` Then the exit status should be 1 And the report file "spec/report.txt" should have 1 total, 1 failure, no console usage diff --git a/features/bin/files.feature b/features/bin/files.feature new file mode 100644 index 0000000..37f3af3 --- /dev/null +++ b/features/bin/files.feature @@ -0,0 +1,7 @@ +Feature: Bin - Files + Scenario: List the files a test suite will use + Given I have a test suite + When I run `bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml -l` + Then the exit status should be 0 + And the output should include "spec/jasmine/success/success.js" + And the output should include "spec/jasmine/success/success_spec.js" diff --git a/features/bin/filtered_run/both_runs.feature b/features/bin/filtered_run/both_runs.feature index e23156c..03953a8 100644 --- a/features/bin/filtered_run/both_runs.feature +++ b/features/bin/filtered_run/both_runs.feature @@ -3,16 +3,16 @@ Feature: Bin - Filtered Run - Both Runs Given there is no existing "spec/report.txt" file Scenario: Run one and fail - When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_failure/filtered_failure.yml --format HeadlessFileReporter --out spec/report.txt ./spec/jasmine/filtered_failure/failure_spec.js` + When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_failure/filtered_failure.yml -f File:spec/report.txt ./spec/jasmine/filtered_failure/failure_spec.js` Then the exit status should be 1 And the report file "spec/report.txt" should have 1 total, 1 failure, no console usage Scenario: Run both and succeed - When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --format HeadlessFileReporter --out spec/report.txt ./spec/jasmine/filtered_success/success_one_spec.js` + When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml -f File:spec/report.txt ./spec/jasmine/filtered_success/success_one_spec.js` Then the exit status should be 0 And the report file "spec/report.txt" should have 2 total, 0 failures, no console usage Scenario: Run both with console.log - When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success_with_console/filtered_success.yml --format HeadlessFileReporter --out spec/report.txt ./spec/jasmine/filtered_success_with_console/success_one_spec.js` + When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success_with_console/filtered_success.yml -f File:spec/report.txt ./spec/jasmine/filtered_success_with_console/success_one_spec.js` Then the exit status should be 2 And the report file "spec/report.txt" should have 2 total, 0 failures, yes console usage diff --git a/features/bin/filtered_run/no_full_run.feature b/features/bin/filtered_run/no_full_run.feature index a16553e..0b1f1e8 100644 --- a/features/bin/filtered_run/no_full_run.feature +++ b/features/bin/filtered_run/no_full_run.feature @@ -3,12 +3,12 @@ Feature: Bin - No Full Run Given there is no existing "spec/report.txt" file Scenario: Only run the filtered run - When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --format HeadlessFileReporter --out spec/report.txt --no-full-run ./spec/jasmine/filtered_success/success_one_spec.js` + When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml -f File:spec/report.txt --no-full-run ./spec/jasmine/filtered_success/success_one_spec.js` Then the exit status should be 0 And the report file "spec/report.txt" should have 1 total, 0 failure, no console usage Scenario: Use a file outside of the normal test run - When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml --format HeadlessFileReporter --out spec/report.txt ./spec/jasmine/filtered_success/success_other_file.js` + When I run `bin/jasmine-headless-webkit -j spec/jasmine/filtered_success/filtered_success.yml -f File:spec/report.txt ./spec/jasmine/filtered_success/success_other_file.js` Then the exit status should be 0 And the report file "spec/report.txt" should have 1 total, 0 failure, no console usage diff --git a/features/bin/reporters.feature b/features/bin/reporters.feature deleted file mode 100644 index e69de29..0000000 diff --git a/features/bin/runner_out.feature b/features/bin/runner_out.feature new file mode 100644 index 0000000..bdafe76 --- /dev/null +++ b/features/bin/runner_out.feature @@ -0,0 +1,8 @@ +Feature: Bin - Runner Out + Scenario: Write out the runner to a specified file + Given I have a test suite + When I run `bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --runner-out spec/runner.html` + Then the exit status should be 0 + And the file "spec/runner.html" should contain a JHW runner + When I delete the file "spec/runner.html" + diff --git a/features/bin/success.feature b/features/bin/success.feature index 50d0a79..b87239e 100644 --- a/features/bin/success.feature +++ b/features/bin/success.feature @@ -1,7 +1,7 @@ Feature: Bin - Success - Scenario: Run a successful test + Scenario: Run a successful test with long format definition Given there is no existing "spec/report.txt" file - When I run `bin/jasmine-headless-webkit --seed 1234 -j spec/jasmine/success/success.yml --format HeadlessFileReporter --out spec/report.txt` + When I run `bin/jasmine-headless-webkit --seed 1234 -j spec/jasmine/success/success.yml --format File --out spec/report.txt` Then the exit status should be 0 And the report file "spec/report.txt" should have 1 total, 0 failures, no console usage And the report file "spec/report.txt" should have seed 1234 @@ -14,7 +14,7 @@ Feature: Bin - Success Scenario: Run a successful test with shortened format definition Given there is no existing "spec/report.txt" file - When I run `bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --format HeadlessFileReporter:spec/report.txt` + When I run `bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml -f File:spec/report.txt` Then the exit status should be 0 And the report file "spec/report.txt" should have 1 total, 0 failures, no console usage diff --git a/features/bin/success_with_js_error.feature b/features/bin/success_with_js_error.feature index 0cb3da4..b899e97 100644 --- a/features/bin/success_with_js_error.feature +++ b/features/bin/success_with_js_error.feature @@ -1,5 +1,5 @@ Feature: Bin - Success with JS Error Scenario: Succeed Given there is no existing "spec/report.txt" file - When I run `bin/jasmine-headless-webkit -j spec/jasmine/success_with_error/success_with_error.yml --format HeadlessFileReporter --out spec/report.txt` + When I run `bin/jasmine-headless-webkit -j spec/jasmine/success_with_error/success_with_error.yml -f File:spec/report.txt` Then the exit status should be 1 diff --git a/features/bin/tries_to_leave_page.feature b/features/bin/tries_to_leave_page.feature index 3334159..3e037c3 100644 --- a/features/bin/tries_to_leave_page.feature +++ b/features/bin/tries_to_leave_page.feature @@ -1,7 +1,7 @@ Feature: Bin - Try to Leave Page Scenario: Fail on trying to leave the page Given there is no existing "spec/report.txt" file - When I run `bin/jasmine-headless-webkit -j spec/jasmine/leave_page/leave_page.yml --format HeadlessFileReporter --out spec/report.txt` + When I run `bin/jasmine-headless-webkit -j spec/jasmine/leave_page/leave_page.yml -f File:spec/report.txt` Then the exit status should be 1 And the report file "spec/report.txt" should exist diff --git a/features/bin/try_to_click_a_button.feature b/features/bin/try_to_click_a_button.feature index 91ff051..f0824e0 100644 --- a/features/bin/try_to_click_a_button.feature +++ b/features/bin/try_to_click_a_button.feature @@ -1,7 +1,7 @@ Feature: Bin - Try to Click A Button Scenario: Don't leave page when clicking a button Given there is no existing "spec/report.txt" file - When I run `bin/jasmine-headless-webkit -j spec/jasmine/click_button/click_button.yml --format HeadlessFileReporter --out spec/report.txt` + When I run `bin/jasmine-headless-webkit -j spec/jasmine/click_button/click_button.yml -f File:spec/report.txt` Then the exit status should be 0 And the report file "spec/report.txt" should have 0 total, 0 failures, no console usage diff --git a/features/bin/with_coffeescript_error.feature b/features/bin/with_coffeescript_error.feature index 7b03252..442851b 100644 --- a/features/bin/with_coffeescript_error.feature +++ b/features/bin/with_coffeescript_error.feature @@ -1,7 +1,7 @@ Feature: Bin - With CoffeeScript error Scenario: Fail on CoffeeScript error Given there is no existing "spec/report.txt" file - When I run `bin/jasmine-headless-webkit -j spec/jasmine/coffeescript_error/coffeescript_error.yml --format HeadlessFileReporter --out spec/report.txt` + When I run `bin/jasmine-headless-webkit -j spec/jasmine/coffeescript_error/coffeescript_error.yml -f File:spec/report.txt` Then the exit status should be 1 And the report file "spec/report.txt" should not exist diff --git a/features/bin/with_console_log.feature b/features/bin/with_console_log.feature index 47ce1e8..734d983 100644 --- a/features/bin/with_console_log.feature +++ b/features/bin/with_console_log.feature @@ -1,7 +1,7 @@ -Feature: Bin - With console.log +Feature: Use console.log Scenario: Run a successful test that uses console.log Given there is no existing "spec/report.txt" file - When I run `bin/jasmine-headless-webkit -j spec/jasmine/console_log/console_log.yml --format HeadlessFileReporter --out spec/report.txt` + When I run `bin/jasmine-headless-webkit -j spec/jasmine/console_log/console_log.yml -f File:spec/report.txt` Then the exit status should be 2 And the report file "spec/report.txt" should have 1 total, 0 failures, yes console usage diff --git a/features/reporters.feature b/features/reporters.feature index fe10131..76dfdd7 100644 --- a/features/reporters.feature +++ b/features/reporters.feature @@ -7,18 +7,18 @@ Feature: Reporters Given I have the default runner options When I get a runner And I get a template writer - Then the template should use the "HeadlessConsoleReporter" reporter to "stdout" + Then the template should use the "Console" reporter to "stdout" And the command to run the runner should not include a report file Scenario: Use a file reporter Given I have the default runner options And I have the following reporters: | Name | File | - | ConsoleReporter | | - | FileReporter | file | + | Console | | + | File | file | When I get a runner And I get a template writer - Then the template should use the "ConsoleReporter" reporter to "stdout" - And the template should use the "FileReporter" reporter to "report:0" + Then the template should use the "Console" reporter to "stdout" + And the template should use the "File" reporter to "report:0" And the command to run the runner should include the report file "file" diff --git a/features/runner.feature b/features/runner.feature new file mode 100644 index 0000000..81f69d4 --- /dev/null +++ b/features/runner.feature @@ -0,0 +1,34 @@ +Feature: Using the Runner directly + Scenario: Succeed + Given I have the following runner options: + """ + :jasmine_config: spec/jasmine/success/success.yml + :reporters: + - [ 'File', 'spec/report.txt' ] + """ + When I get a runner + And I run the runner + Then the runner should have an exit status of 0 + And the report file "spec/report.txt" should have 1 total, 0 failures, no console usage + + Scenario: JavaScript Error + Given I have the following runner options: + """ + :jasmine_config: spec/jasmine/success_with_error/success_with_error.yml + """ + When I get a runner + And I run the runner + Then the runner should have an exit status of 1 + + Scenario: Failure + Given I have the following runner options: + """ + :jasmine_config: spec/jasmine/failure/failure.yml + :reporters: + - [ 'File', 'spec/report.txt' ] + """ + When I get a runner + And I run the runner + Then the runner should have an exit status of 1 + And the report file "spec/report.txt" should have 1 total, 1 failure, no console usage + diff --git a/features/steps/given/i_have_test_suite.rb b/features/steps/given/i_have_test_suite.rb new file mode 100644 index 0000000..5efab54 --- /dev/null +++ b/features/steps/given/i_have_test_suite.rb @@ -0,0 +1,2 @@ +Given /^I have a test suite$/ do +end diff --git a/features/steps/given/options/i_have_runner_options.rb b/features/steps/given/options/i_have_runner_options.rb new file mode 100644 index 0000000..93b76d9 --- /dev/null +++ b/features/steps/given/options/i_have_runner_options.rb @@ -0,0 +1,3 @@ +Given /^I have the following runner options:$/ do |string| + @options = YAML.load(string) +end diff --git a/features/steps/then/bin/file_should_contain_runner.rb b/features/steps/then/bin/file_should_contain_runner.rb new file mode 100644 index 0000000..7904498 --- /dev/null +++ b/features/steps/then/bin/file_should_contain_runner.rb @@ -0,0 +1,4 @@ +Then /^the file "([^"]*)" should contain a JHW runner$/ do |file| + File.read(file).should include('jasmine.HeadlessReporter') +end + diff --git a/features/steps/then/bin/output_should_include.rb b/features/steps/then/bin/output_should_include.rb new file mode 100644 index 0000000..d52cb68 --- /dev/null +++ b/features/steps/then/bin/output_should_include.rb @@ -0,0 +1,3 @@ +Then /^the output should include "([^"]*)"$/ do |string| + @output.should include(string) +end diff --git a/features/steps/then/runner/it_should_have_exit_status.rb b/features/steps/then/runner/it_should_have_exit_status.rb new file mode 100644 index 0000000..a788e4a --- /dev/null +++ b/features/steps/then/runner/it_should_have_exit_status.rb @@ -0,0 +1,3 @@ +Then /^the runner should have an exit status of (\d+)$/ do |exit_status| + @result.should == exit_status.to_i +end diff --git a/features/steps/then/templates/it_should_use_reporter.rb b/features/steps/then/templates/it_should_use_reporter.rb index 5e9e99e..d9a98cc 100644 --- a/features/steps/then/templates/it_should_use_reporter.rb +++ b/features/steps/then/templates/it_should_use_reporter.rb @@ -1,6 +1,6 @@ Then /^the template should use the "([^"]*)" reporter to "([^"]*)"$/ do |reporter, target| output = @template_writer.render - output.should include(%{jasmine.#{reporter}("#{target}")}) + output.should include(%{jasmine.HeadlessReporter.#{reporter}("#{target}")}) end diff --git a/features/steps/when/i_delete_file.rb b/features/steps/when/i_delete_file.rb new file mode 100644 index 0000000..c22c5d0 --- /dev/null +++ b/features/steps/when/i_delete_file.rb @@ -0,0 +1,3 @@ +When /^I delete the file "([^"]*)"$/ do |file| + FileUtils.rm_f(file) +end diff --git a/features/steps/when/i_run_executable.rb b/features/steps/when/i_run_executable.rb index 553ef51..06faa72 100644 --- a/features/steps/when/i_run_executable.rb +++ b/features/steps/when/i_run_executable.rb @@ -1,4 +1,4 @@ When /^I run `(.*)`$/ do |command| - system command + @output = `#{command}` end diff --git a/features/steps/when/i_run_runner.rb b/features/steps/when/i_run_runner.rb new file mode 100644 index 0000000..717bf6f --- /dev/null +++ b/features/steps/when/i_run_runner.rb @@ -0,0 +1,4 @@ +When /^I run the runner$/ do + @result = @runner.run +end + diff --git a/features/support/env.rb b/features/support/env.rb index db7b786..0545a30 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,2 +1,7 @@ require 'jasmine-headless-webkit' +After do + FileUtils.rm_f 'spec/report.txt' + FileUtils.rm_f 'spec/runner.html' +end + diff --git a/lib/jasmine/headless/files_list.rb b/lib/jasmine/headless/files_list.rb index 5a5a9eb..f35d21f 100644 --- a/lib/jasmine/headless/files_list.rb +++ b/lib/jasmine/headless/files_list.rb @@ -72,8 +72,8 @@ module Jasmine::Headless def default_files %w{jasmine.js jasmine-html jasmine.css jasmine-extensions intense headless_reporter_result jasmine.HeadlessReporter - jasmine.HeadlessFileReporter jasmine.HeadlessConsoleReporter - jasmine.HeadlessTAPReporter + jasmine.HeadlessReporter.File jasmine.HeadlessReporter.Console + jasmine.HeadlessReporter.Tap jsDump beautify-html} end diff --git a/lib/jasmine/headless/options.rb b/lib/jasmine/headless/options.rb index 7f85f2c..4cdfe8a 100644 --- a/lib/jasmine/headless/options.rb +++ b/lib/jasmine/headless/options.rb @@ -18,7 +18,7 @@ module Jasmine :enable_cache => true, :files => [], :reporters => [ - [ 'HeadlessConsoleReporter' ] + [ 'Console' ] ] } @@ -59,8 +59,8 @@ module Jasmine when '--report' warn REPORT_DEPRECATED_MESSAGE - add_reporter('HeadlessFileReporter', arg) - add_reporter('HeadlessConsoleReporter') + add_reporter('File', arg) + add_reporter('Console') when '--runner-out' @options[:runner_output_filename] = arg when '--jasmine-config', '-j' diff --git a/lib/jasmine/headless/runner.rb b/lib/jasmine/headless/runner.rb index 946fe71..a389223 100644 --- a/lib/jasmine/headless/runner.rb +++ b/lib/jasmine/headless/runner.rb @@ -28,12 +28,13 @@ module Jasmine class << self def run(options = {}) - options = Options.new(options) if !options.kind_of?(Options) new(options).run end end def initialize(options) + options = Options.new(options) if !options.kind_of?(Options) + @options = options end diff --git a/lib/jasmine/headless/template_writer.rb b/lib/jasmine/headless/template_writer.rb index 1592265..cbc5ac4 100644 --- a/lib/jasmine/headless/template_writer.rb +++ b/lib/jasmine/headless/template_writer.rb @@ -48,7 +48,7 @@ module Jasmine::Headless def jhw_reporters reporters.collect do |reporter, output| - %{jasmine.getEnv().addReporter(new jasmine.#{reporter}("#{output}"));} + %{jasmine.getEnv().addReporter(new jasmine.HeadlessReporter.#{reporter}("#{output}"));} end.join("\n") end diff --git a/spec/bin/jasmine-headless-webkit_spec.rb b/spec/bin/jasmine-headless-webkit_spec.rb deleted file mode 100644 index c864a2b..0000000 --- a/spec/bin/jasmine-headless-webkit_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' -require 'tempfile' - -describe "jasmine-headless-webkit" do - let(:report) { 'spec/report.txt' } - - before do - FileUtils.rm_f report - end - - after do - FileUtils.rm_f report - end - - describe 'files' do - it 'should list all the files that will be found' do - files = %x{bin/jasmine-headless-webkit -l -j spec/jasmine/success/success.yml} - $?.exitstatus.should == 0 - - files.lines.to_a.should include(File.expand_path("./spec/jasmine/success/success.js\n")) - files.lines.to_a.should include(File.expand_path("./spec/jasmine/success/success_spec.js\n")) - end - end - - describe 'runner-out' do - it 'should write out the runner HTML to the specified path and not run the test' do - runner_path = Tempfile.new('jhw') - runner_path.close - - system %{bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml --runner-out #{runner_path.path}} - - File.size(runner_path.path).should_not == 0 - end - end -end - diff --git a/spec/javascripts/jasmine.HeadlessConsoleReporter_spec.coffee b/spec/javascripts/jasmine.HeadlessReporter.Console_spec.coffee similarity index 87% rename from spec/javascripts/jasmine.HeadlessConsoleReporter_spec.coffee rename to spec/javascripts/jasmine.HeadlessReporter.Console_spec.coffee index 31a4a78..767609c 100644 --- a/spec/javascripts/jasmine.HeadlessConsoleReporter_spec.coffee +++ b/spec/javascripts/jasmine.HeadlessReporter.Console_spec.coffee @@ -1,10 +1,8 @@ -describe 'HeadlessReporterResult', -> - -describe 'jasmine.HeadlessConsoleReporter', -> +describe 'jasmine.HeadlessReporter', -> reporter = null beforeEach -> - reporter = new jasmine.HeadlessConsoleReporter() + reporter = new jasmine.HeadlessReporter.Console() describe '#formatResultLine', -> context 'length = 1', -> diff --git a/spec/javascripts/jasmine.HeadlessTAPReporter_spec.coffee b/spec/javascripts/jasmine.HeadlessReporter.Tap_spec.coffee similarity index 80% rename from spec/javascripts/jasmine.HeadlessTAPReporter_spec.coffee rename to spec/javascripts/jasmine.HeadlessReporter.Tap_spec.coffee index 603d3a2..47408db 100644 --- a/spec/javascripts/jasmine.HeadlessTAPReporter_spec.coffee +++ b/spec/javascripts/jasmine.HeadlessReporter.Tap_spec.coffee @@ -1,6 +1,6 @@ -describe 'jasmine.HeadlessTAPReporter', -> +describe 'jasmine.HeadlessReporter.Tap', -> beforeEach -> - @reporter = new jasmine.HeadlessTAPReporter() + @reporter = new jasmine.HeadlessReporter.Tap() describe '#reportRunnerResults', -> it 'should write nothing for nothing', -> diff --git a/spec/lib/jasmine/headless/files_list_spec.rb b/spec/lib/jasmine/headless/files_list_spec.rb index f582ae3..13c1854 100644 --- a/spec/lib/jasmine/headless/files_list_spec.rb +++ b/spec/lib/jasmine/headless/files_list_spec.rb @@ -15,9 +15,9 @@ describe Jasmine::Headless::FilesList do File.expand_path('vendor/assets/javascripts/intense.js'), File.expand_path('vendor/assets/javascripts/headless_reporter_result.js'), File.expand_path('vendor/assets/javascripts/jasmine.HeadlessReporter.js'), - File.expand_path('vendor/assets/javascripts/jasmine.HeadlessFileReporter.js'), - File.expand_path('vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js'), - File.expand_path('vendor/assets/javascripts/jasmine.HeadlessTAPReporter.js'), + File.expand_path('vendor/assets/javascripts/jasmine.HeadlessReporter.File.js'), + File.expand_path('vendor/assets/javascripts/jasmine.HeadlessReporter.Console.js'), + File.expand_path('vendor/assets/javascripts/jasmine.HeadlessReporter.Tap.js'), File.expand_path('vendor/assets/javascripts/jsDump.js'), File.expand_path('vendor/assets/javascripts/beautify-html.js'), ] diff --git a/spec/lib/jasmine/headless/options_spec.rb b/spec/lib/jasmine/headless/options_spec.rb index b4af64e..0a14222 100644 --- a/spec/lib/jasmine/headless/options_spec.rb +++ b/spec/lib/jasmine/headless/options_spec.rb @@ -56,7 +56,7 @@ describe Jasmine::Headless::Options do options.process_option("--report", file) - options[:reporters].should == [ [ 'HeadlessFileReporter', file ], [ 'HeadlessConsoleReporter' ] ] + options[:reporters].should == [ [ 'File', file ], [ 'Console' ] ] end end @@ -144,7 +144,7 @@ describe Jasmine::Headless::Options do context 'no reporters' do it 'should have the default reporter' do - options[:reporters].should == [ [ 'HeadlessConsoleReporter' ] ] + options[:reporters].should == [ [ 'Console' ] ] end end diff --git a/spec/lib/jasmine/headless/runner_spec.rb b/spec/lib/jasmine/headless/runner_spec.rb index b75215c..4d2a996 100644 --- a/spec/lib/jasmine/headless/runner_spec.rb +++ b/spec/lib/jasmine/headless/runner_spec.rb @@ -93,45 +93,6 @@ describe Jasmine::Headless::Runner do end end - context 'real tests' do - let(:report) { 'spec/report.txt' } - - before do - FileUtils.rm_f report - end - - after do - FileUtils.rm_f report - end - - it 'should succeed with error code 0' do - Jasmine::Headless::Runner.run( - :jasmine_config => 'spec/jasmine/success/success.yml', - :reporters => [ - [ 'HeadlessFileReporter', report ] - ] - ).should == 0 - - report.should be_a_report_containing(1, 0, false) - end - - it 'should succeed but with javascript error' do - Jasmine::Headless::Runner.run(:jasmine_config => 'spec/jasmine/success_with_error/success_with_error.yml').should == 1 - end - - it 'should fail on one test' do - Jasmine::Headless::Runner.run( - :jasmine_config => 'spec/jasmine/failure/failure.yml', - :reporters => [ - [ 'HeadlessFileReporter', report ] - ] - ).should == 1 - - report.should be_a_report_containing(1, 1, false) - report.should contain_a_failing_spec(['failure', 'should fail with error code of 1']) - end - end - describe '#runner_filename' do let(:runner_filename) { runner.runner_filename } let(:yaml_output) { 'yaml output' } diff --git a/vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee b/vendor/assets/coffeescripts/jasmine.HeadlessReporter.Console.coffee similarity index 96% rename from vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee rename to vendor/assets/coffeescripts/jasmine.HeadlessReporter.Console.coffee index 7fcf01a..11c51f3 100644 --- a/vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee +++ b/vendor/assets/coffeescripts/jasmine.HeadlessReporter.Console.coffee @@ -1,6 +1,6 @@ #= require jasmine.HeadlessReporter.js # -class jasmine.HeadlessConsoleReporter extends jasmine.HeadlessReporter +class jasmine.HeadlessReporter.Console extends jasmine.HeadlessReporter constructor: (@callback = null) -> super(@callback) diff --git a/vendor/assets/coffeescripts/jasmine.HeadlessFileReporter.coffee b/vendor/assets/coffeescripts/jasmine.HeadlessReporter.File.coffee similarity index 83% rename from vendor/assets/coffeescripts/jasmine.HeadlessFileReporter.coffee rename to vendor/assets/coffeescripts/jasmine.HeadlessReporter.File.coffee index 26bb0a5..424a0ea 100644 --- a/vendor/assets/coffeescripts/jasmine.HeadlessFileReporter.coffee +++ b/vendor/assets/coffeescripts/jasmine.HeadlessReporter.File.coffee @@ -1,4 +1,6 @@ -class jasmine.HeadlessFileReporter extends jasmine.HeadlessReporter +#= require jasmine.HeadlessReporter.js +# +class jasmine.HeadlessReporter.File extends jasmine.HeadlessReporter reportRunnerResults: (runner) -> super(runner) diff --git a/vendor/assets/coffeescripts/jasmine.HeadlessTAPReporter.coffee b/vendor/assets/coffeescripts/jasmine.HeadlessReporter.Tap.coffee similarity index 84% rename from vendor/assets/coffeescripts/jasmine.HeadlessTAPReporter.coffee rename to vendor/assets/coffeescripts/jasmine.HeadlessReporter.Tap.coffee index f03a694..ccd0015 100644 --- a/vendor/assets/coffeescripts/jasmine.HeadlessTAPReporter.coffee +++ b/vendor/assets/coffeescripts/jasmine.HeadlessReporter.Tap.coffee @@ -1,4 +1,6 @@ -class jasmine.HeadlessTAPReporter extends jasmine.HeadlessReporter +#= require jasmine.HeadlessReporter.js + +class jasmine.HeadlessReporter.Tap extends jasmine.HeadlessReporter constructor: (@outputTarget = null) -> super(@outputTarget) diff --git a/vendor/assets/coffeescripts/prolog.coffee b/vendor/assets/coffeescripts/prolog.coffee index 8088521..da892df 100644 --- a/vendor/assets/coffeescripts/prolog.coffee +++ b/vendor/assets/coffeescripts/prolog.coffee @@ -26,35 +26,41 @@ if window.JHW console.log(data) data + puts = (message) -> + JHW.print('stdout', message + "\n") + + # handle unloading window.onbeforeunload = (e) -> e = e || window.event JHW.hasError() - JHW.print('stdout', "The code tried to leave the test page. Check for unhandled form submits and link clicks.\n") + puts "The code tried to leave the test page. Check for unhandled form submits and link clicks." - if e - e.returnValue = 'string' + e.returnValue = 'string' if e return 'string' - window.confirm = (message) -> - JHW.print('stdout', "#{"[confirm]".foreground('red')} jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm. Returning true.\n") - true - - window.alert = (message) -> - JHW.print('stdout', "[alert] ".foreground('red') + message + "\n") - + # script errors JHW._hasErrors = false JHW._handleError = (message, lineNumber, sourceURL) -> JHW.print('stderr', message + "\n") JHW._hasErrors = true false - JHW._setColors = (useColors) -> - Intense.useColors = useColors + # dialogs + window.confirm = (message) -> + puts "#{"[confirm]".foreground('red')} jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm. Returning true." + true + + window.alert = (message) -> + puts "[alert] ".foreground('red') + message + + # color support + JHW._setColors = (useColors) -> Intense.useColors = useColors + + # console.log support JHW._usedConsole = false - JHW.log = (msg) -> JHW.hasUsedConsole() @@ -62,7 +68,8 @@ if window.JHW reporter.consoleLogUsed(msg) if reporter.consoleLogUsed? JHW._usedConsole = true - JHW.print('stdout', msg + "\n") + + puts msg window.CoffeeScriptToFilename = {} window.CSTF = window.CoffeeScriptToFilename diff --git a/vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js b/vendor/assets/javascripts/jasmine.HeadlessReporter.Console.js similarity index 76% rename from vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js rename to vendor/assets/javascripts/jasmine.HeadlessReporter.Console.js index 49edd27..a28481a 100644 --- a/vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js +++ b/vendor/assets/javascripts/jasmine.HeadlessReporter.Console.js @@ -1,21 +1,21 @@ (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; - jasmine.HeadlessConsoleReporter = (function() { + jasmine.HeadlessReporter.Console = (function() { - __extends(HeadlessConsoleReporter, jasmine.HeadlessReporter); + __extends(Console, jasmine.HeadlessReporter); - function HeadlessConsoleReporter(callback) { + function Console(callback) { this.callback = callback != null ? callback : null; this._waitRunner = __bind(this._waitRunner, this); - HeadlessConsoleReporter.__super__.constructor.call(this, this.callback); + Console.__super__.constructor.call(this, this.callback); this.position = 0; this.positions = "|/-\\"; } - HeadlessConsoleReporter.prototype.reportRunnerResults = function(runner) { + Console.prototype.reportRunnerResults = function(runner) { var result, resultLine, _i, _len, _ref; - HeadlessConsoleReporter.__super__.reportRunnerResults.call(this); + Console.__super__.reportRunnerResults.call(this); this.print("\n"); resultLine = this.formatResultLine(this._runtime()); if (this.failedCount === 0) { @@ -31,16 +31,16 @@ return this.puts("\nTest ordering seed: --seed " + (JHW.getSeed())); }; - HeadlessConsoleReporter.prototype.reportRunnerStarting = function(runner) { - HeadlessConsoleReporter.__super__.reportRunnerStarting.call(this, runner); + Console.prototype.reportRunnerStarting = function(runner) { + Console.__super__.reportRunnerStarting.call(this, runner); if (!this.hasError()) { return this.puts("\nRunning Jasmine specs...".bright()); } }; - HeadlessConsoleReporter.prototype.reportSpecResults = function(spec) { + Console.prototype.reportSpecResults = function(spec) { var _this = this; - HeadlessConsoleReporter.__super__.reportSpecResults.call(this, spec); + Console.__super__.reportSpecResults.call(this, spec); return this._reportSpecResult(spec, { success: function(results) { return _this.print('.'.foreground('green')); @@ -66,7 +66,7 @@ }); }; - HeadlessConsoleReporter.prototype.reportSpecWaiting = function() { + Console.prototype.reportSpecWaiting = function() { if (!this.timer) { this.timer = true; this.first = true; @@ -74,7 +74,7 @@ } }; - HeadlessConsoleReporter.prototype.reportSpecRunning = function() { + Console.prototype.reportSpecRunning = function() { if (this.timer) { clearTimeout(this.timer); this.timer = null; @@ -82,7 +82,7 @@ } }; - HeadlessConsoleReporter.prototype.formatResultLine = function(runtime) { + Console.prototype.formatResultLine = function(runtime) { var line; line = []; line.push(this.length); @@ -94,7 +94,7 @@ return line.join(' '); }; - HeadlessConsoleReporter.prototype._waitRunner = function() { + Console.prototype._waitRunner = function() { var _this = this; return this.timer = setTimeout(function() { if (_this.timer) { @@ -108,7 +108,7 @@ }, 750); }; - return HeadlessConsoleReporter; + return Console; })(); diff --git a/vendor/assets/javascripts/jasmine.HeadlessFileReporter.js b/vendor/assets/javascripts/jasmine.HeadlessReporter.File.js similarity index 61% rename from vendor/assets/javascripts/jasmine.HeadlessFileReporter.js rename to vendor/assets/javascripts/jasmine.HeadlessReporter.File.js index 28be293..126d40b 100644 --- a/vendor/assets/javascripts/jasmine.HeadlessFileReporter.js +++ b/vendor/assets/javascripts/jasmine.HeadlessReporter.File.js @@ -1,29 +1,29 @@ (function() { var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; - jasmine.HeadlessFileReporter = (function() { + jasmine.HeadlessReporter.File = (function() { - __extends(HeadlessFileReporter, jasmine.HeadlessReporter); + __extends(File, jasmine.HeadlessReporter); - function HeadlessFileReporter() { - HeadlessFileReporter.__super__.constructor.apply(this, arguments); + function File() { + File.__super__.constructor.apply(this, arguments); } - HeadlessFileReporter.prototype.reportRunnerResults = function(runner) { + File.prototype.reportRunnerResults = function(runner) { var output; - HeadlessFileReporter.__super__.reportRunnerResults.call(this, runner); + File.__super__.reportRunnerResults.call(this, runner); output = "TOTAL||" + this.length + "||" + this.failedCount + "||" + (this._runtime()) + "||" + (JHW._hasErrors ? "T" : "F"); this.puts(output); return this.puts("SEED||" + (JHW.getSeed())); }; - HeadlessFileReporter.prototype.consoleLogUsed = function(msg) { + File.prototype.consoleLogUsed = function(msg) { return this.puts("CONSOLE||" + msg); }; - HeadlessFileReporter.prototype.reportSpecResults = function(spec) { + File.prototype.reportSpecResults = function(spec) { var _this = this; - HeadlessFileReporter.__super__.reportSpecResults.call(this, spec); + File.__super__.reportSpecResults.call(this, spec); return this._reportSpecResult(spec, { success: function(results) { return _this.puts("PASS||" + spec.getJHWSpecInformation()); @@ -34,7 +34,7 @@ }); }; - return HeadlessFileReporter; + return File; })(); diff --git a/vendor/assets/javascripts/jasmine.HeadlessTAPReporter.js b/vendor/assets/javascripts/jasmine.HeadlessReporter.Tap.js similarity index 65% rename from vendor/assets/javascripts/jasmine.HeadlessTAPReporter.js rename to vendor/assets/javascripts/jasmine.HeadlessReporter.Tap.js index 417c667..f2ed49c 100644 --- a/vendor/assets/javascripts/jasmine.HeadlessTAPReporter.js +++ b/vendor/assets/javascripts/jasmine.HeadlessReporter.Tap.js @@ -1,26 +1,26 @@ (function() { var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; - jasmine.HeadlessTAPReporter = (function() { + jasmine.HeadlessReporter.Tap = (function() { - __extends(HeadlessTAPReporter, jasmine.HeadlessReporter); + __extends(Tap, jasmine.HeadlessReporter); - function HeadlessTAPReporter(outputTarget) { + function Tap(outputTarget) { this.outputTarget = outputTarget != null ? outputTarget : null; - HeadlessTAPReporter.__super__.constructor.call(this, this.outputTarget); + Tap.__super__.constructor.call(this, this.outputTarget); this.output = []; } - HeadlessTAPReporter.prototype.reportRunnerResults = function(runner) { - HeadlessTAPReporter.__super__.reportRunnerResults.call(this, runner); + Tap.prototype.reportRunnerResults = function(runner) { + Tap.__super__.reportRunnerResults.call(this, runner); if (this.output.length > 0) this.output.unshift("1.." + this.output.length); return this.puts(this.output.join("\n")); }; - HeadlessTAPReporter.prototype.reportSpecResults = function(spec) { + Tap.prototype.reportSpecResults = function(spec) { var description, index; var _this = this; - HeadlessTAPReporter.__super__.reportSpecResults.call(this, spec); + Tap.__super__.reportSpecResults.call(this, spec); index = this.output.length + 1; description = spec.getSpecSplitName().join(' '); return this._reportSpecResult(spec, { @@ -33,7 +33,7 @@ }); }; - return HeadlessTAPReporter; + return Tap; })(); diff --git a/vendor/assets/javascripts/prolog.js b/vendor/assets/javascripts/prolog.js index 8a03b88..5405669 100644 --- a/vendor/assets/javascripts/prolog.js +++ b/vendor/assets/javascripts/prolog.js @@ -1,3 +1,5 @@ +(function() { + var puts; if (window.JHW) { window.console = { @@ -35,26 +37,29 @@ return data; } }; + puts = function(message) { + return JHW.print('stdout', message + "\n"); + }; window.onbeforeunload = function(e) { e = e || window.event; JHW.hasError(); - JHW.print('stdout', "The code tried to leave the test page. Check for unhandled form submits and link clicks.\n"); + puts("The code tried to leave the test page. Check for unhandled form submits and link clicks."); if (e) e.returnValue = 'string'; return 'string'; }; - window.confirm = function(message) { - JHW.print('stdout', "" + ("[confirm]".foreground('red')) + " jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm. Returning true.\n"); - return true; - }; - window.alert = function(message) { - return JHW.print('stdout', "[alert] ".foreground('red') + message + "\n"); - }; JHW._hasErrors = false; JHW._handleError = function(message, lineNumber, sourceURL) { JHW.print('stderr', message + "\n"); JHW._hasErrors = true; return false; }; + window.confirm = function(message) { + puts("" + ("[confirm]".foreground('red')) + " jasmine-headless-webkit can't handle confirm() yet! You should mock window.confirm. Returning true."); + return true; + }; + window.alert = function(message) { + return puts("[alert] ".foreground('red') + message); + }; JHW._setColors = function(useColors) { return Intense.useColors = useColors; }; @@ -68,10 +73,12 @@ if (reporter.consoleLogUsed != null) reporter.consoleLogUsed(msg); } JHW._usedConsole = true; - return JHW.print('stdout', msg + "\n"); + return puts(msg); }; } window.CoffeeScriptToFilename = {}; window.CSTF = window.CoffeeScriptToFilename; + +}).call(this);