2011-06-01 21:14:23 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
require 'guard/jasmine-headless-webkit/runner'
|
|
|
|
require 'fakefs/spec_helpers'
|
|
|
|
|
|
|
|
describe Guard::JasmineHeadlessWebkitRunner do
|
|
|
|
describe '.notify' do
|
|
|
|
include FakeFS::SpecHelpers
|
|
|
|
|
|
|
|
let(:file) { 'temp.txt' }
|
|
|
|
|
|
|
|
before do
|
|
|
|
File.open(file, 'w') { |fh| fh.print data }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'system run not interrupted' do
|
2011-09-03 11:50:05 +00:00
|
|
|
let(:data) { 'TOTAL||1||0||5||F' }
|
2011-06-01 21:14:23 +00:00
|
|
|
|
|
|
|
it 'should notify with the right information' do
|
2011-09-03 11:50:05 +00:00
|
|
|
Guard::Notifier.expects(:notify).with("1 test, 0 failures, 5.0 secs.", { :title => 'Jasmine results', :image => :success })
|
2011-06-01 21:14:23 +00:00
|
|
|
|
2011-09-06 20:00:27 +00:00
|
|
|
Guard::JasmineHeadlessWebkitRunner.notify(file).should == []
|
2011-06-01 21:14:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-07-14 10:50:47 +00:00
|
|
|
context 'with failures' do
|
2011-09-06 20:00:27 +00:00
|
|
|
let(:data) { <<-REPORT }
|
|
|
|
FAIL||Test||Two||file.js:50
|
|
|
|
TOTAL||1||1||5||F
|
|
|
|
REPORT
|
2011-07-14 10:50:47 +00:00
|
|
|
|
|
|
|
it 'should notify with the right information' do
|
2011-09-03 11:50:05 +00:00
|
|
|
Guard::Notifier.expects(:notify).with("1 test, 1 failures, 5.0 secs.", { :title => 'Jasmine results', :image => :failed })
|
2011-07-14 10:50:47 +00:00
|
|
|
|
2011-09-06 20:00:27 +00:00
|
|
|
Guard::JasmineHeadlessWebkitRunner.notify(file).should == [ 'file.js' ]
|
2011-07-14 10:50:47 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-06-01 21:14:23 +00:00
|
|
|
context 'system run interrupted' do
|
|
|
|
let(:data) { '' }
|
|
|
|
|
|
|
|
it 'should notify failure' do
|
|
|
|
Guard::Notifier.expects(:notify).with("Spec runner interrupted!", { :title => 'Jasmine results', :image => :failed })
|
|
|
|
|
2011-09-06 20:00:27 +00:00
|
|
|
Guard::JasmineHeadlessWebkitRunner.notify(file).should be_nil
|
2011-06-01 21:14:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|