better support for when we don't know spec line location

This commit is contained in:
John Bintz 2011-09-06 16:48:19 -04:00
parent 6bf64edb32
commit 363ee91b6b
7 changed files with 50 additions and 9 deletions

View File

@ -18,7 +18,10 @@ jasmine.Spec.prototype.getSplitName = getSplitName
jasmine.Spec.prototype.getJHWSpecInformation = ->
parts = this.getSpecSplitName()
specLineInfo = HeadlessReporterResult.findSpecLine(parts)
parts.push("#{specLineInfo.file}:#{specLineInfo.lineNumber}")
if specLineInfo.file
parts.push("#{specLineInfo.file}:#{specLineInfo.lineNumber}")
else
parts.push('')
parts.join("||")
if !jasmine.WaitsBlock.prototype._execute

View File

@ -19,7 +19,11 @@
var parts, specLineInfo;
parts = this.getSpecSplitName();
specLineInfo = HeadlessReporterResult.findSpecLine(parts);
parts.push("" + specLineInfo.file + ":" + specLineInfo.lineNumber);
if (specLineInfo.file) {
parts.push("" + specLineInfo.file + ":" + specLineInfo.lineNumber);
} else {
parts.push('');
}
return parts.join("||");
};
if (!jasmine.WaitsBlock.prototype._execute) {

View File

@ -21,7 +21,8 @@ module Jasmine::Headless
def process
@report = File.readlines(file).collect do |line|
type, *parts = line.split('||')
type, *parts = line.split('||', -1)
parts.last.strip!
Jasmine::Headless::ReportMessage.const_get(
Jasmine::Headless::ReportMessage.constants.find { |k| k.to_s.downcase == type.downcase }
@ -49,7 +50,7 @@ module Jasmine::Headless
def failed_files
@report.find_all { |entry|
entry.kind_of?(Jasmine::Headless::ReportMessage::Fail)
}.collect(&:filename).uniq
}.collect(&:filename).uniq.compact
end
private

View File

@ -19,7 +19,11 @@ module Jasmine::Headless::ReportMessage
end
def filename
file_info.split(":").first
if name = file_info.split(":").first
name
else
nil
end
end
end
end

View File

@ -61,6 +61,13 @@ describe 'jasmine.Spec.prototype.getSuiteSplitName', ->
spec.description = 1
expect(spec.getSpecSplitName()).toEqual([ "1" ])
describe 'jasmine.Spec.prototype.getJHWSpecInformation', ->
it 'should append null when there is no file information', ->
spec = new jasmine.Spec({}, {})
spyOn(spec, 'getSpecSplitName').andReturn(["one"])
spyOn(HeadlessReporterResult, 'findSpecLine').andReturn({})
expect(spec.getJHWSpecInformation()).toEqual("one||")
describe 'jasmine.WaitsBlock and jasmine.WaitsForBlock', ->
beforeEach ->
it 'should notify JHW of waiting', ->

View File

@ -1,11 +1,20 @@
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 }
context 'with filename' do
let(:filename) { 'file.js' }
let(:spec) { described_class.new("Test", "#{filename}:23") }
its(:filename) { should == filename }
end
context 'without filename' do
let(:filename) { 'file.js' }
let(:spec) { described_class.new("Test", "") }
its(:filename) { should be_nil }
end
end

View File

@ -47,6 +47,19 @@ REPORT
report.failed_files.should == [ 'file2.js' ]
end
end
context 'nil filed file' do
before do
File.open(file, 'wb') { |fh| fh.puts <<-REPORT }
FAIL||Statement||Two||
TOTAL||1||2||3||T
REPORT
end
it 'should read the report file' do
report.failed_files.should == []
end
end
end
end