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 'jhw call fails' do
|
|
|
|
it "should not run all" do
|
|
|
|
Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(1)
|
|
|
|
guard.expects(:run_all).never
|
|
|
|
|
2011-06-03 20:45:19 +00:00
|
|
|
guard.run_on_change(%w{test.js})
|
2011-05-24 01:28:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-06-10 15:33:27 +00:00
|
|
|
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)
|
2011-06-10 15:33:27 +00:00
|
|
|
guard.expects(:run_all).never
|
2011-05-24 01:28:01 +00:00
|
|
|
|
2011-06-03 20:45:19 +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
|
2011-06-03 20:45:19 +00:00
|
|
|
|
|
|
|
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
|
2011-05-29 12:53:33 +00:00
|
|
|
|
|
|
|
context 'with run_before' do
|
|
|
|
context 'with failing command' do
|
|
|
|
before do
|
|
|
|
Guard::JasmineHeadlessWebkitRunner.expects(:run).never
|
2011-06-01 21:14:23 +00:00
|
|
|
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/))
|
2011-05-29 12:53:33 +00:00
|
|
|
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
|
2011-06-01 21:14:23 +00:00
|
|
|
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/))
|
2011-05-29 12:53:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
let(:options) { { :run_before => 'true' } }
|
|
|
|
|
|
|
|
it "should run the command first" do
|
|
|
|
guard.run_all
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-06-01 21:14:23 +00:00
|
|
|
|
|
|
|
describe 'run jammit first' do
|
|
|
|
context 'run on run_all if called first' do
|
|
|
|
before do
|
2011-06-12 17:44:10 +00:00
|
|
|
guard.expects(:run_program).once.with('Jammit', regexp_matches(/jammit/)).returns(true)
|
2011-06-01 21:14:23 +00:00
|
|
|
Guard::JasmineHeadlessWebkitRunner.expects(:run).once
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:options) { { :jammit => true } }
|
|
|
|
|
|
|
|
it "should run jammit first" do
|
|
|
|
guard.run_all
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'only run once if run_on_change is successful' do
|
|
|
|
before do
|
2011-06-12 17:44:10 +00:00
|
|
|
guard.expects(:run_program).once.with('Jammit', regexp_matches(/jammit/)).returns(true)
|
2011-06-10 15:33:27 +00:00
|
|
|
Guard::JasmineHeadlessWebkitRunner.expects(:run).once.returns(0)
|
2011-06-01 21:14:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
let(:options) { { :jammit => true } }
|
|
|
|
|
|
|
|
it "should run jammit only once" do
|
2011-06-03 20:45:19 +00:00
|
|
|
guard.run_on_change(%w{path.js})
|
2011-06-01 21:14:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-06-12 17:44:10 +00:00
|
|
|
|
|
|
|
describe 'run rails_assets first' do
|
|
|
|
context 'run on run_all if called first' do
|
|
|
|
before do
|
|
|
|
guard.expects(:run_program).with('Rails Assets', regexp_matches(/assets:precompile:for_testing/)).once.returns(true)
|
|
|
|
Guard::JasmineHeadlessWebkitRunner.expects(:run).once
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:options) { { :rails_assets => true } }
|
|
|
|
|
|
|
|
it "should run rails assets first" do
|
|
|
|
guard.run_all
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'only run once if run_on_change is successful' do
|
|
|
|
before do
|
|
|
|
guard.expects(:run_program).with('Rails Assets', regexp_matches(/assets:precompile:for_testing/)).once.returns(true)
|
|
|
|
Guard::JasmineHeadlessWebkitRunner.expects(:run).once.returns(0)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:options) { { :rails_assets => true } }
|
|
|
|
|
|
|
|
it "should run rails assets only once" do
|
|
|
|
guard.run_on_change(%w{path.js})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-05-24 01:28:01 +00:00
|
|
|
end
|