2011-09-02 19:52:19 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Jasmine::Headless::Report do
|
|
|
|
include FakeFS::SpecHelpers
|
|
|
|
|
2011-09-02 21:00:21 +00:00
|
|
|
let(:file) { 'report.txt' }
|
|
|
|
|
2011-09-02 19:52:19 +00:00
|
|
|
describe '.load' do
|
2011-09-02 21:00:21 +00:00
|
|
|
let(:report) { described_class.load(file) }
|
|
|
|
|
2011-09-02 19:52:19 +00:00
|
|
|
context 'no file' do
|
|
|
|
it 'should raise an exception' do
|
2011-09-02 21:00:21 +00:00
|
|
|
expect { report }.to raise_error(Errno::ENOENT)
|
2011-09-02 19:52:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'file' do
|
2011-09-02 21:00:21 +00:00
|
|
|
before do
|
|
|
|
File.open(file, 'wb') { |fh| fh.puts <<-REPORT }
|
|
|
|
PASS||Statement||One||file.js:23
|
2011-09-06 20:01:10 +00:00
|
|
|
FAIL||Statement||Two||file2.js:23
|
|
|
|
FAIL||Statement||Three||file2.js:23
|
2011-09-02 21:00:21 +00:00
|
|
|
CONSOLE||Yes
|
2011-09-06 20:01:10 +00:00
|
|
|
ERROR||Uh oh||file3.js:23
|
2011-09-02 21:00:21 +00:00
|
|
|
TOTAL||1||2||3||T
|
|
|
|
REPORT
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should read the report file' do
|
2011-09-06 20:01:10 +00:00
|
|
|
report.length.should == 6
|
2011-09-02 19:52:19 +00:00
|
|
|
|
2011-09-02 21:00:21 +00:00
|
|
|
report[0].should == Jasmine::Headless::ReportMessage::Pass.new("Statement One", "file.js:23")
|
2011-09-06 20:01:10 +00:00
|
|
|
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)
|
2011-09-02 21:00:21 +00:00
|
|
|
|
|
|
|
report.total.should == 1
|
|
|
|
report.failed.should == 2
|
|
|
|
report.should have_used_console
|
2011-09-03 11:54:52 +00:00
|
|
|
report.time.should == 3.0
|
|
|
|
|
|
|
|
report.should be_valid
|
2011-09-02 21:00:21 +00:00
|
|
|
|
|
|
|
report.should have_failed_on("Statement Two")
|
2011-09-06 20:01:10 +00:00
|
|
|
report.failed_files.should == [ 'file2.js' ]
|
2011-09-02 21:00:21 +00:00
|
|
|
end
|
2011-09-02 19:52:19 +00:00
|
|
|
end
|
2011-09-06 20:48:19 +00:00
|
|
|
|
|
|
|
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
|
2011-09-08 16:17:50 +00:00
|
|
|
|
|
|
|
context 'multi line console' do
|
|
|
|
before do
|
|
|
|
File.open(file, 'wb') { |fh| fh.puts <<-REPORT }
|
|
|
|
CONSOLE||test
|
|
|
|
test2
|
|
|
|
TOTAL||1||2||3||T
|
|
|
|
REPORT
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should read the report file' do
|
|
|
|
report[0].should == Jasmine::Headless::ReportMessage::Console.new("test\ntest2")
|
|
|
|
end
|
|
|
|
end
|
2011-09-02 19:52:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|