guard-jasmine-headless-webkit/spec/lib/guard/jasmine-headless-webkit/runner_spec.rb

57 lines
1.6 KiB
Ruby
Raw Normal View History

require 'spec_helper'
require 'guard/jasmine-headless-webkit/runner'
require 'fakefs/spec_helpers'
describe Guard::JasmineHeadlessWebkitRunner do
2011-09-14 14:06:55 +00:00
describe '.run' do
it 'should pass along options' do
Jasmine::Headless::Runner.expects(:run).with(has_key(:full_run))
Guard::JasmineHeadlessWebkitRunner.run([], :full_run => false)
end
end
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
let(:data) { 'TOTAL||1||0||5||F' }
it 'should notify with the right information' do
Guard::Notifier.expects(:notify).with("1 test, 0 failures, 5.0 secs.", { :title => 'Jasmine results', :image => :success })
Guard::JasmineHeadlessWebkitRunner.notify(file).should == []
end
end
context 'with failures' do
let(:data) { <<-REPORT }
FAIL||Test||Two||file.js:50
TOTAL||1||1||5||F
REPORT
it 'should notify with the right information' do
Guard::Notifier.expects(:notify).with("1 test, 1 failures, 5.0 secs.", { :title => 'Jasmine results', :image => :failed })
Guard::JasmineHeadlessWebkitRunner.notify(file).should == [ 'file.js' ]
end
end
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 })
Guard::JasmineHeadlessWebkitRunner.notify(file).should be_false
end
end
end
end