diff --git a/.gitignore b/.gitignore index b523b09..359df28 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ moc_*.* hydra-runner.log jhw-test .jhw-cache/ +_site/ diff --git a/Guardfile b/Guardfile index 1a2ca0d..38e4233 100644 --- a/Guardfile +++ b/Guardfile @@ -27,7 +27,7 @@ end def compile #system %{cd ext/jasmine-webkit-specrunner && ruby test.rb && ruby extconf.rb} - system %{cd ext/jasmine-webkit-specrunner && ruby extconf.rb} + system %{cd ext/jasmine-webkit-specrunner && ruby test.rb && ruby extconf.rb} end compile diff --git a/lib/jasmine/headless/errors.rb b/lib/jasmine/headless/errors.rb index ac3487b..632377c 100644 --- a/lib/jasmine/headless/errors.rb +++ b/lib/jasmine/headless/errors.rb @@ -10,6 +10,7 @@ module Jasmine class ConsoleLogUsage < StandardError ; end class JasmineConfigNotFound < Errno::ENOENT ; end + class InvalidReport < StandardError ; end end end diff --git a/lib/jasmine/headless/report.rb b/lib/jasmine/headless/report.rb index 4b7f130..4e2b5ae 100644 --- a/lib/jasmine/headless/report.rb +++ b/lib/jasmine/headless/report.rb @@ -31,12 +31,12 @@ module Jasmine::Headless end def has_used_console? - @report.any? { |entry| entry.class == Jasmine::Headless::ReportMessage::Console } + @report.any? { |entry| entry.kind_of?(Jasmine::Headless::ReportMessage::Console) } end def has_failed_on?(statement) @report.any? { |entry| - if entry.class == Jasmine::Headless::ReportMessage::Fail + if entry.kind_of?(Jasmine::Headless::ReportMessage::Fail) entry.statement == statement end } @@ -46,6 +46,12 @@ module Jasmine::Headless last_total != nil end + def failed_files + @report.find_all { |entry| + entry.kind_of?(Jasmine::Headless::ReportMessage::Fail) + }.collect(&:filename).uniq + end + private def last_total diff --git a/lib/jasmine/headless/report_message/spec.rb b/lib/jasmine/headless/report_message/spec.rb index 1af14fd..099f444 100644 --- a/lib/jasmine/headless/report_message/spec.rb +++ b/lib/jasmine/headless/report_message/spec.rb @@ -17,6 +17,10 @@ module Jasmine::Headless::ReportMessage def ==(other) self.statement == other.statement && self.file_info == other.file_info end + + def filename + file_info.split(":").first + end end end diff --git a/spec/lib/jasmine/headless/report_message/spec_spec.rb b/spec/lib/jasmine/headless/report_message/spec_spec.rb new file mode 100644 index 0000000..8642f2e --- /dev/null +++ b/spec/lib/jasmine/headless/report_message/spec_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe Jasmine::Headless::ReportMessage::Spec do + let(:filename) { 'file.js' } + let(:spec) { described_class.new("Test", "#{filename}:23") } + + subject { spec } + + its(:filename) { should == filename } +end + diff --git a/spec/lib/jasmine/headless/report_spec.rb b/spec/lib/jasmine/headless/report_spec.rb index 6588060..2f4d9c4 100644 --- a/spec/lib/jasmine/headless/report_spec.rb +++ b/spec/lib/jasmine/headless/report_spec.rb @@ -18,21 +18,23 @@ describe Jasmine::Headless::Report do before do File.open(file, 'wb') { |fh| fh.puts <<-REPORT } PASS||Statement||One||file.js:23 -FAIL||Statement||Two||file.js:23 +FAIL||Statement||Two||file2.js:23 +FAIL||Statement||Three||file2.js:23 CONSOLE||Yes -ERROR||Uh oh||file.js:23 +ERROR||Uh oh||file3.js:23 TOTAL||1||2||3||T REPORT end it 'should read the report file' do - report.length.should == 5 + report.length.should == 6 report[0].should == Jasmine::Headless::ReportMessage::Pass.new("Statement One", "file.js:23") - report[1].should == Jasmine::Headless::ReportMessage::Fail.new("Statement Two", "file.js:23") - report[2].should == Jasmine::Headless::ReportMessage::Console.new("Yes") - report[3].should == Jasmine::Headless::ReportMessage::Error.new("Uh oh", "file.js:23") - report[4].should == Jasmine::Headless::ReportMessage::Total.new(1, 2, 3, true) + report[1].should == Jasmine::Headless::ReportMessage::Fail.new("Statement Two", "file2.js:23") + report[2].should == Jasmine::Headless::ReportMessage::Fail.new("Statement Three", "file2.js:23") + report[3].should == Jasmine::Headless::ReportMessage::Console.new("Yes") + report[4].should == Jasmine::Headless::ReportMessage::Error.new("Uh oh", "file3.js:23") + report[5].should == Jasmine::Headless::ReportMessage::Total.new(1, 2, 3, true) report.total.should == 1 report.failed.should == 2 @@ -42,6 +44,7 @@ REPORT report.should be_valid report.should have_failed_on("Statement Two") + report.failed_files.should == [ 'file2.js' ] end end end