guard-jasmine-headless-webkit/spec/lib/guard/jasmine-headless-webkit_spe...

106 lines
2.7 KiB
Ruby
Raw Normal View History

2011-05-24 01:28:01 +00:00
require 'spec_helper'
require 'guard/jasmine-headless-webkit'
describe Guard::JasmineHeadlessWebkit do
let(:guard) { Guard::JasmineHeadlessWebkit.new([], options) }
let(:options) { {} }
describe "#start" do
context 'no all on start' do
let(:options) { { :all_on_start => false } }
it "should not run all" do
guard.expects(:run_all).never
guard.start
end
end
context 'all on start' do
let(:options) { { :all_on_start => true } }
it "should not run all" do
guard.expects(:run_all).once
guard.start
end
end
end
describe '#run_on_change' do
context 'two files' do
it "should only run one" do
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(%w{test.js}).returns(1)
guard.expects(:run_all).never
guard.run_on_change(%w{test.js test.js})
end
end
2011-05-24 01:28:01 +00:00
context 'jhw call fails' do
it "should not run all" do
Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(1)
guard.expects(:run_all).never
guard.run_on_change(%w{test.js})
2011-05-24 01:28:01 +00:00
end
end
context 'succeed, but still do not run all' do
2011-05-24 01:28:01 +00:00
it "should run all" do
Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(0)
guard.expects(:run_all).never
2011-05-24 01:28:01 +00:00
guard.run_on_change(%w{test.js})
2011-05-24 01:28:01 +00:00
end
end
2011-06-03 20:25:00 +00:00
context 'no files given, just run all' do
it 'should run all but not run once' do
Guard::JasmineHeadlessWebkitRunner.expects(:run).never
guard.expects(:run_all).once
guard.run_on_change([])
end
end
context "Files I don't care about given, ignore" do
it 'should run all but not run once' do
Guard::JasmineHeadlessWebkitRunner.expects(:run).never
guard.expects(:run_all).once
guard.run_on_change(%w{test.jst})
end
end
2011-05-24 01:28:01 +00:00
end
context 'with run_before' do
context 'with failing command' do
before do
Guard::JasmineHeadlessWebkitRunner.expects(:run).never
Guard::UI.expects(:info).with(regexp_matches(/false/))
2011-06-10 15:50:25 +00:00
Guard::UI.expects(:info).with(regexp_matches(/running all/))
end
let(:options) { { :run_before => 'false' } }
it "should run the command first" do
guard.run_all
end
end
context 'with succeeding command' do
before do
Guard::JasmineHeadlessWebkitRunner.expects(:run).once
Guard::UI.expects(:info).with(regexp_matches(/true/))
2011-06-10 15:50:25 +00:00
Guard::UI.expects(:info).with(regexp_matches(/running all/))
end
let(:options) { { :run_before => 'true' } }
it "should run the command first" do
guard.run_all
end
end
end
2011-05-24 01:28:01 +00:00
end